Expand description
PostgreSQL wire protocol driver for bsql.
bsql-driver-postgres is a purpose-built PostgreSQL driver optimized for bsql’s
architecture: binary protocol only, arena allocation for row data, pipelined
extended query protocol, LIFO connection pool with fail-fast semantics.
§Design
- Binary protocol only — numeric types are memcpy, not parsed from ASCII.
- Arena allocation — all row data from one query shares a single bump allocator.
- Pipelined messages — Parse+Bind+Execute+Sync in one TCP write.
- Statement cache — keyed by rapidhash of SQL text. Second query skips Parse.
- LIFO pool — returns the warmest connection (best PG backend cache locality).
- Fail-fast — pool exhaustion returns an error immediately, never blocks.
- No unsafe code —
#![forbid(unsafe_code)].
§Example
use bsql_driver_postgres::{Pool, Arena};
let pool = Pool::connect("postgres://user:pass@localhost/db").await?;
let mut conn = pool.acquire().await?;
let mut arena = Arena::new();
let hash = bsql_driver_postgres::hash_sql("SELECT $1::int4 + $2::int4 AS sum");
let result = conn.query(
"SELECT $1::int4 + $2::int4 AS sum",
hash,
&[&1i32, &2i32],
&mut arena,
).await?;
let row = result.row(0, &arena);
assert_eq!(row.get_i32(0), Some(3));Re-exports§
pub use codec::Encode;pub use pool::Pool;pub use pool::PoolBuilder;pub use pool::PoolGuard;pub use pool::PoolStatus;pub use pool::Transaction;
Modules§
- arena
- Re-export from
bsql-arena— the arena is a shared crate used by all drivers. - codec
- Binary encode/decode for PostgreSQL types.
- pool
- Connection pool — LIFO ordering, fail-fast acquire, no timeouts.
Structs§
- Arena
- A bump allocator for row data.
- Column
Desc - Description of a result column.
- Config
- Connection configuration parsed from a URL.
- Connection
- A PostgreSQL connection with statement cache and inline message processing.
- Notification
- A notification received during normal query processing.
- PgData
Row - A temporary view of a single PostgreSQL DataRow message.
- Prepare
Result - Result of a
prepare_describecall — column and parameter metadata without executing the query. - Query
Result - Result of a query execution. Owns the row offset metadata.
- Row
- A view into a single result row, borrowing data from the arena.
- Sync
Connection - A synchronous PostgreSQL connection over a Unix domain socket.
Enums§
- Driver
Error - Error type for all bsql-driver-postgres operations.
- SslMode
- SSL/TLS connection mode.
Functions§
- hash_
sql - Compute a rapidhash of a SQL string.
Type Aliases§
- Simple
Row - A single row of text values returned by
simple_query_rows.