You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 99e085e
Browse filesBrowse the repository at this point in the historyBrowse files
fix(driver-sql): read the key type on the caller's transaction, under a savepoint (ADR-0155 D-0, O2)
A door running in the caller's transaction now reads the PostgreSQL catalog
on that transaction's own connection, inside a knex nested transaction
(a savepoint), instead of on a second pooled connection. A pool the
transaction holds can no longer time the read out, a table the transaction
created is read, and a failed read rolls back the savepoint alone, leaving
the caller's transaction usable. That reading is kept for that transaction
only. Outside a transaction the read stays on the pool. A failed or empty
read still records nothing, and no reading is still refused (500, logged
once).
Live PG pins: a held single-connection pool answers the list's rows, cast,
on find, count and updateMany; a character(4) table created in the
uncommitted transaction answers [k1], cast; a catalog read failing inside
the transaction is refused while the transaction stays usable.
Claude-Session: https://claude.ai/code/session_01L9qibyXo4gSy8DJPNz4ANz
Co-authored-by: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: .changeset/35906-pg-share-grant-key-type.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,5 +12,6 @@ No visible change on its own: nothing writes a `SharedRecordIds` leaf yet. The s
12
12
-**PostgreSQL, a key that is not text.** The compiled subquery `id IN (SELECT record_id FROM sys_record_share WHERE …)` now projects `record_id` cast to the base type of the column it is compared with: `CAST(NULLIF(record_id, '') AS <type>)`. A federated table keyed by `integer`, `bigint`, `smallint`, `numeric`, `uuid`, `character(n)` or a domain over one of them answers the same rows as the id list of the same grants: `07` names 7, an upper-case or braced uuid names its lower-case twin, and a padded grant names a `character(n)` key. Before, an integer or uuid key failed the statement with `DATABASE_ERROR` (42883), and a `character(n)` key silently missed a padded grant.
13
13
-**A malformed grant id** (`abc` against an integer key) fails the statement with `DATABASE_ERROR` / 500, the same answer the id list gives for it.
14
14
-**How the type is known.** The driver reads the column types of the compared table from `pg_catalog` once, the first time a statement holding the leaf reaches that table, and keeps the answer for the life of the driver. A statement with no leaf reads nothing. A failed or empty catalog read records nothing and is asked again by the next statement.
15
-
-**No reading, no statement.** On PostgreSQL a statement whose leaf is compared with a table the driver holds no catalog reading of is refused with `INTERNAL_ERROR` / 500 (logged once), and never runs uncast, which on a `character(n)` key would miss a padded grant silently. A table has no reading when the catalog read fails (it runs on a pooled connection, so a pool the caller's own transaction holds times it out) or when the table was created in the caller's transaction that has not committed yet; the next statement reads the catalog again.
16
-
-**Unchanged.** A `text` or `varchar` key, which is every table the platform creates, compiles exactly as before. SQLite, MySQL, SQL Server and Oracle compile exactly as before; SQLite answers the list's rows by column affinity. MySQL and SQL Server keys are not measured against a live server yet. An Oracle `RAW(16)` uuid key is expected to fail the statement (ORA-01465, by reading: the subquery converts a dashed uuid grant to `RAW` implicitly, where the id list binds its undashed hex); it is not measured, and is tracked on #35952.
15
+
-**No reading, no statement.** On PostgreSQL a statement whose leaf is compared with a table the driver holds no catalog reading of is refused with `INTERNAL_ERROR` / 500 (logged once), and never runs uncast, which on a `character(n)` key would miss a padded grant silently. A table has no reading when the catalog read fails or finds no such relation; nothing is recorded, and the next statement reads the catalog again.
16
+
-**Read where the statement runs.** A statement in the caller's transaction reads the catalog on that transaction's own connection, inside a savepoint: it needs no second pooled connection, it sees a table the transaction created, and a failed read rolls back the savepoint alone, so the caller's transaction stays usable. That reading is kept for that transaction only. A statement outside a transaction reads on the pool and the reading is kept for the life of the driver.
17
+
-**Unchanged, and what text keys get.** A `text` or `varchar` key, which is every table the platform creates, compiles to exactly step 3's statement, with no cast. What is new for it: the first leaf statement on that table (once per driver, or once per transaction inside one) is preceded by the catalog read, and if that read fails, or finds no such relation, the statement is refused with `INTERNAL_ERROR` / 500 instead of being run. SQLite, MySQL, SQL Server and Oracle compile exactly as before and read no catalog; SQLite answers the list's rows by column affinity. MySQL and SQL Server keys are not measured against a live server yet. An Oracle `RAW(16)` uuid key is expected to fail the statement (ORA-01465, by reading: the subquery converts a dashed uuid grant to `RAW` implicitly, where the id list binds its undashed hex); it is not measured, and is tracked on #35952.
0 commit comments