Skip to content

v1.0.0-rc.15

Pre-release
Pre-release

Choose a tag to compare

@aesslinger aesslinger released this 02 Dec 15:14
· 7 commits to main since this release
de1fffd

Added

  • read_rows RPC, insert_records RPC, and the table_copy capability
    (#207): a lossless table-to-table copy path. read_rows returns
    full-precision values — timestamp(6)/time keep fractional seconds,
    timestamptz keeps the +00:00 UTC offset, and bytea is 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 a session_id, the first
    page opens a REPEATABLE READ READ ONLY transaction on a pinned connection
    that subsequent pages reuse, so rows are not skipped or repeated when the
    source table changes mid-copy; release with release_session. insert_records
    is the batch typed insert for the write side: it reuses the bind_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. The BLOB:...:base64 format from read_rows
    round-trips through bind_pg_value's decode_blob_wire_format, so a PG→PG
    copy preserves every value. The host gates the Transfer feature on the
    table_copy capability (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_rows session-pinned cursor paging (#214, #216): with a session_id,
    the read DECLAREs a SCROLL server-side cursor and FETCHes per page — linear,
    one stable order, no LIMIT/OFFSET re-read. A retried page=1 reuses the
    cursor (keyed off the pinned connection, not the page number). The cursor
    lives and dies with the pinned REPEATABLE READ transaction; release_session
    (ROLLBACK) drops it.
  • insert_records on_conflict: "skip" (#214, #216): optional on_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 return type (pg_type.typname — the short internal name
    matching read_rows' Type::name()) and oid (#214, #216), so the host can
    plan the conversion with one type vocabulary.
  • execute_read_only_query and the read_only_queries capability (#202):
    protected read-only queries. Each call runs as BEGIN READ ONLY, the query,
    ROLLBACK, so PostgreSQL itself refuses INSERT, UPDATE, DELETE, DDL and
    writing functions; the plugin reads transaction_read_only back 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, LOAD and DISCARD are refused too, because a read-only transaction does
    not stop them from changing state outside it. The connection returns to the
    pool only after ROLLBACK succeeded 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. A cancel that lands before the query runs
    stops the call. Role privileges still bound the protection (see the README).
  • A connection with read_only = true now opens on its own pool whose new
    sessions run SET default_transaction_read_only = on, and the plugin never
    runs its startup_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_mode is 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 and PREPAREd statements it created in the same message as its
    ROLLBACK, which a real PgBouncer test confirms.
  • import_database_sql (#201): imports a .sql file 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 (default public) is
    prepended onto the connection's search_path instead of replacing it. Also
    sets SET CONSTRAINTS ALL DEFERRED and SET LOCAL synchronous_commit = OFF,
    runs deferred constraint checks before COMMIT, reports the failing
    statement's number, line and text, and honors cancel between statements and
    before COMMIT. Statements are streamed and split correctly around quotes,
    dollar quoting, comments and BEGIN ATOMIC bodies, and each runs as exactly
    one command. BEGIN/COMMIT lines in the file are skipped so the import
    stays atomic; ROLLBACK, COPY ... FROM STDIN/TO STDOUT, anything that
    could turn standard_conforming_strings off, and psql meta-commands are
    rejected with an explanation (use pg_dump --inserts). The database the user
    picked wins over the one named in a legacy connection string. Session
    settings from the dump are reset before COMMIT so they do not leak through
    a transaction pooler. No progress events are emitted.
  • get_foreign_keys and get_all_foreign_keys_batch now return ref_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 query billing.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: the search_path is set in one statement
    instead of a read and a SET, 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 its search_path
    first. Connections in transaction pooler mode are unchanged.
  • tokio-postgres 0.7.18 is vendored under vendor/tokio-postgres with 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/DECIMAL values and NaN no longer silently decode to null
    on the read_rows lossless path (#214, #216). A new PgNumeric FromSql
    decodes the base-10000 wire bytes directly, reproducing PG16's
    numeric_out/get_str_from_var — values over 29 significant digits and
    NaN/Infinity survive. The write side (bind_pg_numeric_string) always
    binds via TEXT+CAST($N AS numeric), not Decimal::parse (which silently
    rounds high-scale values to 28 significant digits).
  • A read_rows session-cursor response is now bounded by a 16 MB byte budget
    (MAX_RESPONSE_BYTES) so a table with large bytea values can be copied
    without exhausting memory (#215, #217). The cursor DECLAREs SCROLL and
    FETCHes in a batch; when the byte budget is hit, the over-budget rows are
    rewound with MOVE BACKWARD (via query_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 (no session_id) is unchanged: at most limit
    rows, no byte budget. limit is capped at MAX_PAGE_SIZE = 100,000 to
    prevent runaway round-trips on small-row tables.
  • Data-modifying CTE statements (WITH ... INSERT/UPDATE/DELETE ...) no
    longer get SQL pagination appended (#212). A WITH ... INSERT ... RETURNING
    with a limit param got LIMIT appended after RETURNING, causing a syntax
    error; a WITH 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 with pagination: null.
  • DATE, TIMESTAMP and TIMESTAMPTZ values beyond year 9999 no longer decode
    to null (#200). The interim jiff port (RUSTSEC-2026-0543) bounded years to
    ±9999, so valid PostgreSQL dates up to ~5.88M AD (DATE) / ~294276 AD
    (TIMESTAMP) silently became null where the old chrono path produced a
    formatted string, and BC dates with 1-3 digit years padded as -050 where
    chrono padded to -0050. The four temporal types now decode via custom
    FromSql impls that read the raw wire bytes and format with chrono-matching
    output over the full PostgreSQL range: %Y puts the sign outside the 4-digit
    field (-0050, +10000), Howard Hinnant's civil_from_days algorithm
    covers 4713 BC to ~5.88M AD, and infinity sentinels (i32::MAX/i64::MAX/
    MIN) decode to null as the old chrono path did. The jiff dependency
    is removed entirely (no calendar-library dependency remains).
    clause was appended to the end of the text, so after a trailing -- note it
    sat inside the comment, PostgreSQL ignored it, and every page returned the
    first rows with has_more still 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 (including E'..'),
    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 trailing LIMIT/OFFSET is found even when a comment
    follows it, and LIMIT +5 (a signed number) is still read. A LIMIT ALL,
    FETCH FIRST, or OFFSET written before LIMIT is still not understood
    and PostgreSQL rejects the doubled clause, as before.
  • A very large limit or page no 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 0 and silently returned no rows. They are now 64-bit, and the offset
    stops at the largest value PostgreSQL's bigint accepts.
  • 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 \r was read as
    part of the comment, which hid its leading keyword from the transaction-control
    and result-set checks.
  • A bigint or money value of -9223372036854775808 no 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.