bsql-driver-postgres 0.16.0

PostgreSQL wire protocol driver for bsql — binary protocol, arena allocation, zero-copy
Documentation

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};

# async fn example() -> Result<(), bsql_driver_postgres::DriverError> {
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));
# Ok(())
# }