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
10#![deny(deprecated)]
11
12pub mod driver;
13pub mod protocol;
14pub mod types;
15
16pub use driver::explain;
17#[cfg(all(feature = "enterprise-gssapi", target_os = "linux"))]
18pub use driver::gss::{
19    LinuxKrb5PreflightReport, LinuxKrb5ProviderConfig, linux_krb5_preflight,
20    linux_krb5_token_provider,
21};
22pub use driver::{
23    AuthSettings, ConnectOptions, EnterpriseAuthMechanism, GssEncMode, GssTokenProvider,
24    GssTokenProviderEx, GssTokenRequest, IdentifySystem, Notification, PgConnection, PgDriver,
25    PgDriverBuilder, PgError, PgPool, PgResult, PgRow, PgServerError, PoolConfig, PoolStats,
26    PooledConnection, QailRow, QueryResult, ReplicationKeepalive, ReplicationOption,
27    ReplicationSlotInfo, ReplicationStreamMessage, ReplicationStreamStart, ReplicationXLogData,
28    ResultFormat, ScopedPoolFuture, ScramChannelBindingMode, TlsConfig, TlsMode, scope,
29    spawn_pool_maintenance,
30};
31pub use protocol::PgEncoder;
32pub use types::{
33    Cidr, Date, FromPg, Inet, Json, MacAddr, Numeric, Time, Timestamp, ToPg, TypeError, Uuid,
34};
35
36/// Generate the RLS SQL string for pipelined execution.
37///
38/// Returns the `BEGIN; SET LOCAL statement_timeout = ...; SELECT set_config(...)`
39/// string that can be passed to `PooledConnection::fetch_all_with_rls()`.
40pub fn rls_sql_with_timeout(ctx: &qail_core::rls::RlsContext, timeout_ms: u32) -> String {
41    driver::rls::context_to_sql_with_timeout(ctx, timeout_ms)
42}
43
44/// Generate the RLS SQL string with both statement and lock timeouts.
45///
46/// When `lock_timeout_ms` is 0, the lock_timeout clause is omitted.
47pub fn rls_sql_with_timeouts(
48    ctx: &qail_core::rls::RlsContext,
49    statement_timeout_ms: u32,
50    lock_timeout_ms: u32,
51) -> String {
52    driver::rls::context_to_sql_with_timeouts(ctx, statement_timeout_ms, lock_timeout_ms)
53}