waxing gibbous · a statute of moondb
moonpostgres
The PostgreSQL implementation of the Driver contract — extended query, a statement cache, server-side cursors, and COPY streamed in both directions.
Enactment
What it is
moonpostgres connects to a PostgreSQL server and implements Driver against it. It speaks the $1, $2, … placeholder token and binds parameters out-of-band.
Install
moon add moonbitstack/moonpostgres
Placeholder
$1, $2, … positional — PostgreSQL's native numbered placeholders, bound server-side. A :name statement is rewritten to them at prepare time and the slot names are kept, so bind_named takes a map.
Prepared statements
prepare sends Parse under a name cached by SQL text, so a repeated statement binds instead of re-parsing; Close reclaims it and drops the cache entry.
Streaming
PgRowStream reads one response off the wire; PgCursor is a DECLARE/FETCH cursor the server holds open, a batch per round trip; copy_in_stream and copy_out_stream move COPY data one chunk at a time, so a 100 MB load never sits in memory.
Auth
trust cleartext MD5 SCRAM-SHA-256, with SASLprep, channel binding and server-signature verification TLS.
Coverage
execute query transaction close query_stream (live) prepare dialect LISTEN/NOTIFY CancelRequest ping (default).