postgresql/src/backend
Nathan Bossart b65be6ef00 Ensure we have a snapshot when updating various system catalogs.
A few places that access system catalogs don't set up an active
snapshot before potentially accessing their TOAST tables.  To fix,
push an active snapshot just before each section of code that might
require accessing one of these TOAST tables, and pop it shortly
afterwards.  While at it, this commit adds some rather strict
assertions in an attempt to prevent such issues in the future.

Commit 16bf24e0e4 recently removed pg_replication_origin's TOAST
table in order to fix the same problem for that catalog.  On the
back-branches, those bugs are left in place.  We cannot easily
remove a catalog's TOAST table on released major versions, and only
replication origins with extremely long names are affected.  Given
the low severity of the issue, fixing older versions doesn't seem
worth the trouble of significantly modifying the patch.

Also, on v13 and v14, the aforementioned strict assertions have
been omitted because commit 2776922201, which added
HaveRegisteredOrActiveSnapshot(), was not back-patched.  While we
could probably back-patch it now, I've opted against it because it
seems unlikely that new TOAST snapshot issues will be introduced in
the oldest supported versions.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/18127-fe54b6a667f29658%40postgresql.org
Discussion: https://postgr.es/m/18309-c0bf914950c46692%40postgresql.org
Discussion: https://postgr.es/m/ZvMSUPOqUU-VNADN%40nathan
Backpatch-through: 13
2025-05-30 15:17:28 -05:00
..
access Fix GIN's shimTriConsistentFn to not corrupt its input. 2025-04-12 12:27:46 -04:00
bootstrap Rethink definition of pg_attribute.attcompression. 2021-05-27 13:24:27 -04:00
catalog Fix broken handling of domains in atthasmissing logic. 2025-03-03 12:43:29 -05:00
commands Ensure we have a snapshot when updating various system catalogs. 2025-05-30 15:17:28 -05:00
executor Fix failure for generated column with a not-null domain constraint. 2025-04-15 12:08:34 -04:00
foreign Restrict accesses to non-system views and foreign tables during pg_dump. 2024-08-05 06:05:23 -07:00
jit Fix NULLIF()'s handling of read-write expanded objects. 2024-11-25 18:09:10 -05:00
lib Accommodate very large dshash tables. 2024-12-17 15:24:45 -06:00
libpq Allow larger packets during GSSAPI authentication exchange. 2025-05-30 12:55:15 -04:00
main Fix elog(FATAL) before PostmasterMain() or just after fork(). 2024-12-10 13:52:02 -08:00
nodes Build whole-row Vars the same way during parsing and planning. 2025-03-12 11:47:19 -04:00
optimizer Fix failure for generated column with a not-null domain constraint. 2025-04-15 12:08:34 -04:00
parser Fix parse_cte.c's failure to examine sub-WITHs in DML statements. 2025-04-05 15:01:33 -04:00
partitioning Fix creation of partition descriptor during concurrent detach+drop 2024-08-12 18:17:56 -04:00
po Translation updates 2025-05-05 12:22:42 +02:00
port Check for STATUS_DELETE_PENDING on Windows. 2024-11-08 09:34:00 +10:30
postmaster Ensure we have a snapshot when updating various system catalogs. 2025-05-30 15:17:28 -05:00
regex Fix recently-exposed portability issue in regex optimization. 2024-11-17 14:14:06 -05:00
replication Don't retreat slot's confirmed_flush LSN. 2025-05-19 11:15:09 +05:30
rewrite Repair commits 317aba70e et al for -DWRITE_READ_PARSE_PLAN_TREES. 2025-03-13 12:13:07 -04:00
snowball Avoid null pointer dereference crash after OOM in Snowball stemmers. 2025-02-18 21:24:12 -05:00
statistics Fix incorrectly reported stats kind in "can't happen" ERROR 2024-03-05 16:18:42 +13:00
storage Make XactLockTableWait() and ConditionalXactLockTableWait() interruptable more. 2025-05-31 00:14:29 +09:00
tcop Repair commits 317aba70e et al for -DWRITE_READ_PARSE_PLAN_TREES. 2025-03-13 12:13:07 -04:00
tsearch Clear errno before calling strtol() in spell.c. 2025-03-08 11:24:57 -05:00
utils Fix conversion of SIMILAR TO regexes for character classes 2025-05-28 08:59:27 +09:00
.gitignore
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Use sort_template.h for qsort_tuple() and qsort_ssup(). 2021-03-03 17:02:32 +13:00
nls.mk Translation updates 2021-09-20 16:23:13 +02:00