Repository navigation
v1.0.0-rc.15
Pre-release
Pre-release
Added
read_rowsRPC,insert_recordsRPC, and thetable_copycapability
(#207): a lossless table-to-table copy path.read_rowsreturns
full-precision values —timestamp(6)/timekeep fractional seconds,
timestamptzkeeps the+00:00UTC offset, andbyteais base64-encoded in
full (not the 10 KB preview) — plus the PostgreSQL type name and OID per
column so the host can plan the conversion. With asession_id, the first
page opens aREPEATABLE READ READ ONLYtransaction on a pinned connection
that subsequent pages reuse, so rows are not skipped or repeated when the
source table changes mid-copy; release withrelease_session.insert_records
is the batch typed insert for the write side: it reuses thebind_pg_value
typed cascade with column types discovered once per batch, in one transaction
on a one-shot connection (BEGIN/COMMIT/ROLLBACK), so a batch that fails
writes none of its rows. TheBLOB:...:base64format fromread_rows
round-trips throughbind_pg_value'sdecode_blob_wire_format, so a PG→PG
copy preserves every value. The host gates the Transfer feature on the
table_copycapability (companion to the tabularis host change,
tabularis#1625). Arrays, ranges, and composites of temporals stay lossy in
this PR (documented limitation; the copy acceptance criteria are scalar
columns).read_rowssession-pinned cursor paging (#214, #216): with asession_id,
the read DECLAREs aSCROLLserver-side cursor and FETCHes per page — linear,
one stable order, noLIMIT/OFFSETre-read. A retriedpage=1reuses the
cursor (keyed off the pinned connection, not the page number). The cursor
lives and dies with the pinnedREPEATABLE READtransaction;release_session
(ROLLBACK) drops it.insert_recordson_conflict: "skip"(#214, #216): optionalon_conflict
param ("fail"default,"skip"→ON CONFLICT DO NOTHING). Response reports
{ affected_rows, skipped }.get_columns,get_view_columns,get_materialized_view_columns, and the
batch fetch now returntype(pg_type.typname— the short internal name
matchingread_rows'Type::name()) andoid(#214, #216), so the host can
plan the conversion with one type vocabulary.execute_read_only_queryand theread_only_queriescapability (#202):
protected read-only queries. Each call runs asBEGIN READ ONLY, the query,
ROLLBACK, so PostgreSQL itself refusesINSERT,UPDATE,DELETE, DDL and
writing functions; the plugin readstransaction_read_onlyback and fails the
call if protection is not in effect. Transaction-control statements are
refused, including ones hidden behind a--comment that ends at a carriage
return.PREPARE,DEALLOCATE,COPY,ANALYZE,CLUSTER,REINDEX,
CHECKPOINT,LOADandDISCARDare refused too, because a read-only transaction does
not stop them from changing state outside it. The connection returns to the
pool only afterROLLBACKsucceeded and the session holds no prepared
statement or session-level advisory lock the call created; otherwise, and on
a cancellation or a dropped call, it is detached, its running statement is
cancelled and it is closed, so protection and session state never leak to a
writable caller of the same pool. Acancelthat lands before the query runs
stops the call. Role privileges still bound the protection (see the README).- A connection with
read_only = truenow opens on its own pool whose new
sessions runSET default_transaction_read_only = on, and the plugin never
runs itsstartup_script(the host omits it), so connection testing and
metadata discovery cannot write. It is a statement and not a startup option,
because PgBouncer rejects the option in every pool mode. Behind a transaction
pooler the statement is not run and the per-call transaction protects there;
pooler_modeis part of such a pool's key. There a closed client connection
does not close the server backend, so a call also releases the session-level
advisory locks andPREPAREd statements it created in the same message as its
ROLLBACK, which a real PgBouncer test confirms. import_database_sql(#201): imports a.sqlfile in a single transaction on
a dedicated connection, so a failing statement rolls the whole import back
instead of leaving the database half-imported. Applies the built-in driver's
session setup with one difference: the requested schema (defaultpublic) is
prepended onto the connection'ssearch_pathinstead of replacing it. Also
setsSET CONSTRAINTS ALL DEFERREDandSET LOCAL synchronous_commit = OFF,
runs deferred constraint checks beforeCOMMIT, reports the failing
statement's number, line and text, and honorscancelbetween statements and
beforeCOMMIT. Statements are streamed and split correctly around quotes,
dollar quoting, comments andBEGIN ATOMICbodies, and each runs as exactly
one command.BEGIN/COMMITlines in the file are skipped so the import
stays atomic;ROLLBACK,COPY ... FROM STDIN/TO STDOUT, anything that
could turnstandard_conforming_stringsoff, and psql meta-commands are
rejected with an explanation (usepg_dump --inserts). The database the user
picked wins over the one named in a legacy connection string. Session
settings from the dump are reset beforeCOMMITso they do not leak through
a transaction pooler. No progress events are emitted.get_foreign_keysandget_all_foreign_keys_batchnow returnref_schema,
the schema of the referenced table. A foreign key into another schema
(billing.carry_forwards.organization_id → core.organizations.id) no longer
makes the Related Records panel querybilling.organizations. Byte-for-byte
parity with the built-in driver (companion to the tabularis host change).
Changed
- A statement that reads now takes one network round trip on a direct
connection, where it took four: thesearch_pathis set in one statement
instead of a read and aSET, and it goes out together with the statement's
prepare and its data fetch. On a link with a 200 ms round trip, running a
query, opening a table, a next page and a row count each drop from about
0.8 s to 0.2 s. A statement that writes still waits for itssearch_path
first. Connections in transaction pooler mode are unchanged. tokio-postgres0.7.18 is vendored undervendor/tokio-postgreswith one
change: a typed query receives its rows before it looks up a column type the
connection has not met. Without it, a large result with an enum, domain,
composite or extension-type column could hang unless the statement was
prepared first, which is the round trip the plugin used to spend. See
vendor/tokio-postgres/README.tabularis.md.
Fixed
- Wide
NUMERIC/DECIMALvalues andNaNno longer silently decode tonull
on theread_rowslossless path (#214, #216). A newPgNumericFromSql
decodes the base-10000 wire bytes directly, reproducing PG16's
numeric_out/get_str_from_var— values over 29 significant digits and
NaN/Infinitysurvive. The write side (bind_pg_numeric_string) always
binds viaTEXT+CAST($N AS numeric), notDecimal::parse(which silently
rounds high-scale values to 28 significant digits). - A
read_rowssession-cursor response is now bounded by a 16 MB byte budget
(MAX_RESPONSE_BYTES) so a table with largebyteavalues can be copied
without exhausting memory (#215, #217). The cursor DECLAREsSCROLLand
FETCHes in a batch; when the byte budget is hit, the over-budget rows are
rewound withMOVE BACKWARD(viaquery_typed, extended protocol) so the
next page re-fetches them — no data loss, no host change. A single row
larger than the budget still goes out as its own response (always at least
one row). The one-shot path (nosession_id) is unchanged: at mostlimit
rows, no byte budget.limitis capped atMAX_PAGE_SIZE = 100,000to
prevent runaway round-trips on small-row tables. - Data-modifying CTE statements (
WITH ... INSERT/UPDATE/DELETE ...) no
longer get SQL pagination appended (#212). AWITH ... INSERT ... RETURNING
with alimitparam gotLIMITappended afterRETURNING, causing a syntax
error; aWITH changed AS (UPDATE ... RETURNING ...) SELECT ...re-executed
the update on every page, doubling writes. The plugin now parses the CTE
structure and pages only read-only CTEs (every body and the outer command are
SELECT/VALUES/TABLE). Data-modifying CTEs and unparseable statements
fall back to client-side row capping withpagination: null. DATE,TIMESTAMPandTIMESTAMPTZvalues beyond year 9999 no longer decode
tonull(#200). The interimjiffport (RUSTSEC-2026-0543) bounded years to
±9999, so valid PostgreSQL dates up to ~5.88M AD (DATE) / ~294276 AD
(TIMESTAMP) silently becamenullwhere the oldchronopath produced a
formatted string, and BC dates with 1-3 digit years padded as-050where
chrono padded to-0050. The four temporal types now decode via custom
FromSqlimpls that read the raw wire bytes and format with chrono-matching
output over the full PostgreSQL range:%Yputs the sign outside the 4-digit
field (-0050,+10000), Howard Hinnant'scivil_from_daysalgorithm
covers 4713 BC to ~5.88M AD, and infinity sentinels (i32::MAX/i64::MAX/
MIN) decode tonullas the oldchronopath did. Thejiffdependency
is removed entirely (no calendar-library dependency remains).
clause was appended to the end of the text, so after a trailing-- noteit
sat inside the comment, PostgreSQL ignored it, and every page returned the
first rows withhas_morestill true: an export of such a query repeated
the first page until cancelled. Pagination now reads the query with a lexer
that knows--and nested/* */comments, strings (includingE'..'),
quoted identifiers and dollar quotes, and treats every non-ASCII character
as part of a name, as PostgreSQL does. Comments after the code move after
the paging clause. When a line comment sits before the user's own
LIMIT/OFFSET, the clause starts on a new line so the comment cannot
swallow it. That trailingLIMIT/OFFSETis found even when a comment
follows it, andLIMIT +5(a signed number) is still read. ALIMIT ALL,
FETCH FIRST, orOFFSETwritten beforeLIMITis still not understood
and PostgreSQL rejects the doubled clause, as before.- A very large
limitorpageno longer breaks a paginated query. The page
size plus one and the page offset were computed in 32 bits: a debug build
panicked and left the request unanswered, and a release build wrapped to
LIMIT 0and silently returned no rows. They are now 64-bit, and the offset
stops at the largest value PostgreSQL'sbigintaccepts. - A
--comment now ends at a carriage return as well as a newline, as it does
in PostgreSQL. A statement that follows a comment ended by\rwas read as
part of the comment, which hid its leading keyword from the transaction-control
and result-set checks. - A
bigintormoneyvalue of-9223372036854775808no longer overflows
when it is converted for the grid. A debug build panicked on it and left the
request unanswered; a release build sent it as a JSON number, which loses
precision. It is now sent as a string, like every other value outside
JavaScript's safe integer range.