postgresql/src/include
Noah Misch bcb784e7d2 Assert lack of hazardous buffer locks before possible catalog read.
Commit 0bada39c83 fixed a bug of this kind,
which existed in all branches for six days before detection.  While the
probability of reaching the trouble was low, the disruption was extreme.  No
new backends could start, and service restoration needed an immediate
shutdown.  Hence, add this to catch the next bug like it.

The new check in RelationIdGetRelation() suffices to make autovacuum detect
the bug in commit 243e9b40f1 that led to commit
0bada39.  This also checks in a number of similar places.  It replaces each
Assert(IsTransactionState()) that pertained to a conditional catalog read.

Back-patch to v14 - v17.  This a back-patch of commit
f4ece891fc (from before v18 branched) to
all supported branches, to accompany the back-patch of commits 243e9b4
and 0bada39.  For catalog indexes, the bttextcmp() behavior that
motivated IsCatalogTextUniqueIndexOid() was v18-specific.  Hence, this
back-patch doesn't need that or its correction from commit
4a4ee0c2c1.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/20250410191830.0e.nmisch@google.com
Discussion: https://postgr.es/m/10ec0bc3-5933-1189-6bb8-5dec4114558e@gmail.com
Backpatch-through: 14-17
2025-12-16 16:13:54 -08:00
..
access Introduce XLogRecPtrIsValid() 2025-11-06 19:08:29 +01:00
archive Add macro for customizing an archiving WARNING message. 2024-03-04 15:41:42 -06:00
backup Align blocks in incremental backups to BLCKSZ 2024-04-05 16:30:01 +02:00
bootstrap Update copyright for 2024 2024-01-03 20:49:05 -05:00
catalog Fix a deadlock during ALTER SUBSCRIPTION ... DROP PUBLICATION. 2025-08-01 06:53:16 +00:00
commands Fix bug where we truncated CLOG that was still needed by LISTEN/NOTIFY 2025-11-12 21:01:13 +02:00
common Silence warning in older versions of Valgrind 2025-02-24 18:03:48 +07:00
datatype Avoid using timezone Asia/Manila in regression tests. 2025-01-20 15:47:53 -05:00
executor Fix replica identity check for INSERT ON CONFLICT DO UPDATE. 2025-09-04 11:33:00 +01:00
fe_utils Specify the encoding of input to fmtId() 2025-02-10 10:03:38 -05:00
foreign Clean up more indent breakage from 6377e12a5. 2024-04-16 13:00:40 -04:00
jit Monkey-patch LLVM code to fix ARM relocation bug. 2024-11-06 23:07:34 +13:00
lib radixtree: Fix crash when non-creator begins iteration over shared tree. 2025-02-06 11:35:51 -08:00
libpq Make the memory layout of Port struct independent of USE_OPENSSL 2024-11-22 17:43:34 +02:00
mb With GB18030, prevent SIGSEGV from reading past end of allocation. 2025-05-05 04:52:07 -07:00
nodes Fix incorrect IndexOptInfo header comment 2025-11-24 17:01:13 +13:00
optimizer Disallow collecting transition tuples from child foreign tables. 2025-08-08 10:50:02 +09:00
parser Handle default NULL insertion a little better. 2025-01-29 15:31:55 -05:00
partitioning Revert support for ALTER TABLE ... MERGE/SPLIT PARTITION(S) commands 2024-08-24 19:18:24 +03:00
pch Update copyright for 2024 2024-01-03 20:49:05 -05:00
port Fix O_CLOEXEC flag handling in Windows port. 2025-12-10 09:10:31 +13:00
portability Update copyright for 2024 2024-01-03 20:49:05 -05:00
postmaster Wait for WAL summarization to catch up before creating .partial file. 2024-07-26 14:51:10 -04:00
regex Avoid assertion due to disconnected NFA sub-graphs in regex parsing. 2024-11-15 18:23:38 -05:00
replication Make invalid primary_slot_name follow standard GUC error reporting. 2025-10-22 20:11:47 +09:00
rewrite Support MERGE into updatable views. 2024-02-29 15:56:59 +00:00
snowball Update copyright for 2024 2024-01-03 20:49:05 -05:00
statistics Update copyright for 2024 2024-01-03 20:49:05 -05:00
storage Assert lack of hazardous buffer locks before possible catalog read. 2025-12-16 16:13:54 -08:00
tcop Restrict accesses to non-system views and foreign tables during pg_dump. 2024-08-05 06:05:30 -07:00
tsearch Update copyright for 2024 2024-01-03 20:49:05 -05:00
utils Assert lack of hazardous buffer locks before possible catalog read. 2025-12-16 16:13:54 -08:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
c.h Assume that <stdbool.h> conforms to the C standard. 2024-11-25 20:54:15 +13:00
fmgr.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
funcapi.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
getopt_long.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
Makefile Put genbki.pl output into src/include/catalog/ directly 2024-03-14 07:11:21 +01:00
meson.build meson: Restore implicit warning/debug/optimize flags for extensions 2024-06-07 09:36:26 +02:00
miscadmin.h Avoid mixing void and integer in a conditional expression. 2025-11-02 12:31:07 -05:00
pg_config.h.in Make our usage of memset_s() conform strictly to the C11 standard. 2025-05-18 12:45:55 -04:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_ext.h.meson meson: Add initial version of meson based build system 2022-09-21 22:37:17 -07:00
pg_config_manual.h Introduce a non-recursive JSON parser 2024-04-04 06:46:40 -04:00
pg_getopt.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_trace.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pgstat.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pgtar.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pgtime.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
port.h Fix O_CLOEXEC flag handling in Windows port. 2025-12-10 09:10:31 +13:00
postgres.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
postgres_ext.h Move RelFileNumber declarations to common/relpath.h. 2022-09-27 12:01:57 -04:00
postgres_fe.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
varatt.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
windowapi.h Update copyright for 2024 2024-01-03 20:49:05 -05:00