Expand description
oxisql-postgres — Pure-Rust PostgreSQL backend for OxiSQL.
Provides PgConnection, which implements oxisql_core::Connection
over tokio-postgres (no libpq, no C bindings) with TLS support via
rustls + the pure-Rust RustCrypto provider from oxitls
(no ring, no openssl-sys).
§Wire protocol compliance
This crate uses the PostgreSQL Frontend/Backend Protocol version 3
(introduced in PostgreSQL 7.4) as implemented by tokio-postgres. All
client–server communication is framed according to that specification:
| API path | Wire mode |
|---|---|
execute / query | Extended-query protocol (Parse → Bind → Execute → Sync) |
execute_batch / begin_txn | Simple-query protocol (Query message) |
query_binary | Extended-query with explicit type OIDs; results decoded in binary format (format code 1) |
prepare / describe | Extended-query Parse + Describe only (no Execute) |
pipeline | Multiple extended-query cycles flushed as a single send buffer |
§Limitations
- Logical replication via the
pgoutputplugin is available behind thereplicationfeature (see [PgReplicationConnection]); this is an MVP: no in-progress-transaction streaming, no two-phase commit, and no physical replication. (Binary-format tuple values and array-typed columns are decoded, in both text and binary format, even though this MVP never actually negotiatesbinary 'true'with the server.) - Cancellation via the
CancelRequestflow is available throughPgConnection::cancel_token→PostgresCancelToken::cancel_query. It is not exposed at theConnectiontrait level; individual queries can also be cancelled by dropping theFuture. - Notification delivery via
LISTENis only available on connections created throughPgConnection::connect(notfrom_client), because the backgroundConnectiondriver that routesNotificationResponsemessages is only spawned in that code path. - PostgreSQL protocol v2 (pre-7.4) servers are not supported.
§Quick start (no TLS)
use oxisql_postgres::{PgConnection, TlsMode};
use oxisql_core::Connection;
let conn = PgConnection::connect(
"host=localhost port=5432 user=postgres password=secret",
TlsMode::Disabled,
).await?;
conn.execute("CREATE TABLE IF NOT EXISTS t (id BIGINT)", &[]).await?;§Quick start (TLS via OxiTLS)
use oxisql_postgres::{PgConnection, TlsMode};
// Build a ClientConfig trusting the Mozilla CA bundle.
// Requires the "pure" + "webpki-roots" features of oxitls (the defaults).
let root_store = oxitls::webpki_root_certs();
let client_cfg = oxitls::client_config(root_store)
.map_err(|e| format!("TLS cfg: {e}"))?;
let conn = PgConnection::connect(
"host=db.example.com port=5432 user=postgres sslmode=require",
TlsMode::Rustls(client_cfg),
).await?;Re-exports§
pub use types::pg_row_to_row;pub use types::value_to_param;pub use types::OwnedParam;
Modules§
- types
- Type conversion between
tokio-postgresvalues andoxisql_coretypes.
Structs§
- Column
Description - Metadata for a single output column from a prepared statement.
- Notification
Stream - A live subscription to a PostgreSQL notification channel.
- PgConn
Parts - Parsed fields extracted from a PostgreSQL connection string.
- PgConnection
- An asynchronous PostgreSQL connection backed by
tokio-postgres(Pure Rust, nolibpq). - PgConnection
Builder - Builder for configuring and establishing a PostgreSQL connection.
- PgNotification
- A notification received via the PostgreSQL
LISTEN/NOTIFYmechanism. - PgPipeline
- A batched-dispatch pipeline for PostgreSQL.
- PgPrepared
- A compiled PostgreSQL prepared statement.
- PgTransaction
- A PostgreSQL transaction that holds exclusive access to the client for the duration of the transaction scope.
- Pipeline
Result - Collected results from a completed
PgPipeline. - Postgres
Cancel Token - A token that can be used to cancel a running query on a
PgConnection.
Enums§
- PgError
- Errors that can arise within the
oxisql-postgresbackend. - TlsMode
- TLS mode to use when connecting to PostgreSQL.
Functions§
- parse_
pg_ conn_ str - Parse a PostgreSQL connection string into its constituent parts.