Files
pad/internal
xarmian 6d4c3b4b75 fix(store): an operational SQLSTATE is not a verdict about the value (BUG-2810)
Codex round 6, and it is the round-5 fail-open one level deeper. That round
split "the server answered" from "the server did not", and I implemented the
first half as "does the error carry a SQLSTATE at all" — which is wrong,
because 57014 (query cancelled), 57P01 (terminated by administrator), the 08
class (connection exception) and the 53 class (out of resources) all carry
SQLSTATEs while saying nothing whatever about the value. Classified as
verdicts, they let the preflight proceed with an UNVERIFIED suspect, which is
the exact thing the three-way split was added to stop.

The test is now INVERTED: only SQLSTATE class 22 — data exception, PostgreSQL's
class for "this value is wrong" — counts as a verdict about the value.
`SELECT $1::jsonb` produces 22P02 for malformed JSON and 22P05 / 22021 for the
NUL cases. Everything else, code or no code, means the question was not
answered, and the caller refuses rather than guessing. Erring toward
"unavailable" is the safe direction: its cost is a refused migration an
operator re-runs, against a half-finished one they have to unpick.

The coverage is split deliberately, and both halves are needed. The operational
codes are from PostgreSQL's error-code table, formatted the way pgx renders
them, because provoking an administrator shutdown inside a unit test is not
worth it. What is NOT assumed is the rendering, or the premise that class 22 is
what a bad value yields: the real-server test now extracts the SQLSTATE from a
genuine malformed-value rejection and asserts it is class 22 and a completed
verdict, and the closed-pool test covers the no-code path. Neither half stands
on its own.

sqlStateOf's own edges are pinned too — a truncated "SQLSTATE 22" must not
yield a partial code that then matches a class prefix, and the marker search
being case-insensitive means the extraction has to be as well.
2026-09-02 17:20:31 +00:00
..
2026-03-26 01:52:36 +00:00