]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Ensure we have a snapshot while dropping ON COMMIT DROP temp tables.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 16 Oct 2023 18:06:11 +0000 (14:06 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 16 Oct 2023 18:06:11 +0000 (14:06 -0400)
commitf6e1ee3cfa3eb6fbda0e798e103dbad7760f17f5
treec9ab3d281498918914b17697410d85617e847ee1
parent81b3df0f1b89531bce57b8e8168e790e6c1cf6ec
Ensure we have a snapshot while dropping ON COMMIT DROP temp tables.

Dropping a temp table could entail TOAST table access to clean out
toasted catalog entries, such as large pg_constraint.conbin strings
for complex CHECK constraints.  If we did that via ON COMMIT DROP,
we triggered the assertion in init_toast_snapshot(), because
there was no provision for setting up a snapshot for the drop
actions.  Fix that.

(I assume here that the adjacent truncation actions for ON COMMIT
DELETE ROWS don't have a similar problem: it doesn't seem like
nontransactional truncations would need to touch any toasted fields.
If that proves wrong, we could refactor a bit to have the same
snapshot acquisition cover that too.)

The test case added here does not fail before v15, because that
assertion was added in 277692220 which was not back-patched.
However, the race condition the assertion warns of surely
exists further back, so back-patch to all supported branches.

Per report from Richard Guo.

Discussion: https://postgr.es/m/CAMbWs4-x26=_QxxgdJyNbiCDzvtr2WV5ZDso_v-CukKEe6cBZw@mail.gmail.com
src/backend/commands/tablecmds.c
src/test/regress/expected/temp.out
src/test/regress/sql/temp.sql