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, ScramChannelBindingMode, TlsConfig, TlsMode, spawn_pool_maintenance,
29};
30pub use protocol::PgEncoder;
31pub use types::{
32    Cidr, Date, FromPg, Inet, Json, MacAddr, Numeric, Time, Timestamp, ToPg, TypeError, Uuid,
33};
34
35/// Generate the RLS SQL string for pipelined execution.
36///
37/// Returns the `BEGIN; SET LOCAL statement_timeout = ...; SELECT set_config(...)`
38/// string that can be passed to `PooledConnection::fetch_all_with_rls()`.
39pub fn rls_sql_with_timeout(ctx: &qail_core::rls::RlsContext, timeout_ms: u32) -> String {
40    driver::rls::context_to_sql_with_timeout(ctx, timeout_ms)
41}
42
43/// Generate the RLS SQL string with both statement and lock timeouts.
44///
45/// When `lock_timeout_ms` is 0, the lock_timeout clause is omitted.
46pub fn rls_sql_with_timeouts(
47    ctx: &qail_core::rls::RlsContext,
48    statement_timeout_ms: u32,
49    lock_timeout_ms: u32,
50) -> String {
51    driver::rls::context_to_sql_with_timeouts(ctx, statement_timeout_ms, lock_timeout_ms)
52}