Skip to main content

Crate oxisql_postgres

Crate oxisql_postgres 

Source
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 pathWire mode
execute / queryExtended-query protocol (Parse → Bind → Execute → Sync)
execute_batch / begin_txnSimple-query protocol (Query message)
query_binaryExtended-query with explicit type OIDs; results decoded in binary format (format code 1)
prepare / describeExtended-query Parse + Describe only (no Execute)
pipelineMultiple extended-query cycles flushed as a single send buffer

§Limitations

  • Logical replication via the pgoutput plugin is available behind the replication feature (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 negotiates binary 'true' with the server.)
  • Cancellation via the CancelRequest flow is available through PgConnection::cancel_token → PostgresCancelToken::cancel_query. It is not exposed at the Connection trait level; individual queries can also be cancelled by dropping the Future.
  • Notification delivery via LISTEN is only available on connections created through PgConnection::connect (not from_client), because the background Connection driver that routes NotificationResponse messages 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-postgres values and oxisql_core types.

Structs§

ColumnDescription
Metadata for a single output column from a prepared statement.
NotificationStream
A live subscription to a PostgreSQL notification channel.
PgConnParts
Parsed fields extracted from a PostgreSQL connection string.
PgConnection
An asynchronous PostgreSQL connection backed by tokio-postgres (Pure Rust, no libpq).
PgConnectionBuilder
Builder for configuring and establishing a PostgreSQL connection.
PgNotification
A notification received via the PostgreSQL LISTEN/NOTIFY mechanism.
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.
PipelineResult
Collected results from a completed PgPipeline.
PostgresCancelToken
A token that can be used to cancel a running query on a PgConnection.

Enums§

PgError
Errors that can arise within the oxisql-postgres backend.
TlsMode
TLS mode to use when connecting to PostgreSQL.

Functions§

parse_pg_conn_str
Parse a PostgreSQL connection string into its constituent parts.