Skip to main content

qail_pg/
lib.rs

1//! PostgreSQL driver with AST-native wire encoding.
2//!
3//! **Features:** Zero-alloc encoding, LRU cache (100 max), connection pooling, COPY protocol.
4//!
5//! ```ignore
6//! let mut driver = PgDriver::connect("localhost", 5432, "user", "db").await?;
7//! let rows = driver.fetch_all(&Qail::get("users").limit(10)).await?;
8//! ```
9
10pub mod driver;
11pub mod protocol;
12pub mod types;
13
14pub use driver::explain;
15#[cfg(all(feature = "enterprise-gssapi", target_os = "linux"))]
16pub use driver::gss::{
17    LinuxKrb5PreflightReport, LinuxKrb5ProviderConfig, linux_krb5_preflight,
18    linux_krb5_token_provider,
19};
20pub use driver::{
21    AuthSettings, ConnectOptions, EnterpriseAuthMechanism, GssEncMode, GssTokenProvider,
22    GssTokenProviderEx, GssTokenRequest, Notification, PgConnection, PgDriver, PgDriverBuilder,
23    PgError, PgPool, PgResult, PgRow, PgServerError, PoolConfig, PoolStats, PooledConnection,
24    QailRow, QueryResult, ResultFormat, ScramChannelBindingMode, TlsConfig, TlsMode,
25};
26pub use protocol::PgEncoder;
27pub use types::{
28    Cidr, Date, FromPg, Inet, Json, MacAddr, Numeric, Time, Timestamp, ToPg, TypeError, Uuid,
29};
30
31/// Generate the RLS SQL string for pipelined execution.
32///
33/// Returns the `BEGIN; SET LOCAL statement_timeout = ...; SELECT set_config(...)`
34/// string that can be passed to `PooledConnection::fetch_all_with_rls()`.
35pub fn rls_sql_with_timeout(ctx: &qail_core::rls::RlsContext, timeout_ms: u32) -> String {
36    driver::rls::context_to_sql_with_timeout(ctx, timeout_ms)
37}
38
39/// Generate the RLS SQL string with both statement and lock timeouts.
40///
41/// When `lock_timeout_ms` is 0, the lock_timeout clause is omitted.
42pub fn rls_sql_with_timeouts(
43    ctx: &qail_core::rls::RlsContext,
44    statement_timeout_ms: u32,
45    lock_timeout_ms: u32,
46) -> String {
47    driver::rls::context_to_sql_with_timeouts(ctx, statement_timeout_ms, lock_timeout_ms)
48}