fix: set_options must refuse with 42809, not plpgsql's default P0001 - #757
Conversation
246e38d to
f21b7aa
Compare
|
Rebased onto Flagging that this PR has zero CI runs in any state, the same symptom as #749 — and a force-push here did not create one either, which is why I have withdrawn the "transient, push again" advice I gave there. The gate evidence in the description is from my container: audit on all five majors, converge on 17/18/19, plus the removal proof. |
jdatcmd
left a comment
There was a problem hiding this comment.
Approving. Verified on the merged tree, pg17, built from it with the installed library's md5
printed beside each result.
Taking this as your own defect rather than leaving it as a note on #748 was the right call,
and landing it first is the right order: #748 adds a second guard raising the same sentence
and #749 wants a SQLSTATE assertion, so both would otherwise be built on the inconsistency.
Verified
| check | result |
|---|---|
audit.sh |
AUDIT TEST PASSED, and the new arm reads 42809 |
| the premise beside it | 22012 from SELECT 1/0, so an empty probe cannot read as a pass |
native_upgrade_converge |
PASSED -- the mirroring into the upgrade script holds |
base vs upgrade set_options body |
identical: True, 6511 bytes each, wrong_object_type present in both |
Removal proof, both .sql files reverted to main and reinstalled:
PASS premise: the SQLSTATE probe reads a known code: 22012
FAIL set_options on a non-columnar relation raises 42809, not P0001: got [P0001] want [42809]
The premise stays green while the assertion reddens, so it fails for the stated reason and not
because the probe stopped working. That pairing is what makes the arm worth having.
Using VERBOSITY=verbose rather than a DO block with an exception handler is also the right
call for audit.sh specifically, and for the reason you give: that file passes SQL through
bash -lc, and I hit exactly that nested dollar-quoting trap myself earlier today building a
probe for #748 -- mine came back as syntax error at or near "294276" and told me nothing.
One thing to fix before merge
The CHANGELOG entry is attributed (#403):
... The guard now sets `wrong_object_type` explicitly and
`audit.sh` asserts the code. (#403)
#403 is the ClickHouse-paper issue. This is #747 debt, found on #748, fixed in #757 -- none of
which is #403. Worth correcting, since the merge commit carries it and the CHANGELOG is what
someone reads a year from now to find why the code changed.
Not blocking anything else; the change itself is right and proved.
…not commandprompt#403 Raised on review. commandprompt#403 is the ClickHouse-paper issue and owns none of this: the defect came from commandprompt#747's guard, was found while reviewing commandprompt#748, and is fixed here. The CHANGELOG is what someone reads a year from now to find why the code changed, and the merge commit carries it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Corrected the attribution myself in Everything else stands as reviewed: Merging once the checks on this head come back. |
|
@jdatcmd — jd has asked me to put a merge order in front of you. All three are green as of Merge in this order
The two blocking reviews are stale rather than outstanding — both were written before the Why this order and not another#757 first because it is the one the other two build on. It makes #749 before #748 is your own call, and I agree with it: you withdrew "either order" on the What I verified, so you can weight the re-reviewsI ran both on the real 3-way merge rather than the branch, and removal-proved each:
Neither is mine to approve: all three carry — OffgridwithJD |
pgcolumnar.set_optionsrefuses a non-columnar relation with SQLSTATEP0001instead of42809. My defect, from #747, already merged. jdatcmd spotted it as a follow-up whilereviewing #748 and I am taking it rather than leaving it on his PR.
The split
plpgsql's
RAISE EXCEPTIONdefaults toP0001unless anERRCODEis given, and the guardshipped without one:
The C paths raise the same sentence with
errcode(ERRCODE_WRONG_OBJECT_TYPE)—42809—and that is also what #748's new visibility-map guard returns. Measured on merged
main:So the identical message text carries two different SQLSTATEs depending on which path refuses
the caller, in a tree whose own privilege suites deliberately assert SQLSTATE rather than
message text. It matters now rather than later because #748 adds a second guard raising the
same sentence, and #749 wants a test that asserts a SQLSTATE — both would be built against an
inconsistency.
Test first
The arm went into
audit.shbefore the fix and was demonstrated red:The premise matters: it reads
22012fromSELECT 1/0so a probe that returned nothing forany reason could not be mistaken for a pass.
The probe uses
psql -v VERBOSITY=verbose, which printsERROR: <sqlstate>: <message>,rather than a
DOblock with an exception handler.audit.shpasses SQL throughbash -lc,and a dollar-quoted block nested inside that is the quoting trap this tree already has scars
from — I verified the mechanism on a known error before building the arm on it.
Gate
auditnative_upgrade_convergeset_optionsbodydocs_style/shellcheck -S error -s bashRemoval proof — drop the
ERRCODEfrom both scripts:USING ERRCODE = 'wrong_object_type',removedgot [P0001] want [42809], premise still greenThe guard is mirrored into the
1.0-alpha→1.0-alpha2upgrade script, regenerated from thebase text so the two are byte-identical, which
native_upgrade_convergechecks by comparingmd5(pg_get_functiondef()).🤖 Generated with Claude Code