Fix crash in REINDEX CONCURRENTLY due to DDLs run in index functions

ReindexRelationConcurrently() keeps track of the OIDs of the relations
it processes across all its phases, relying on session locks to protect
them.  A function called from an index predicate or expression could
drop one of the indexes being processed by a REINDEX CONCURRENTLY,
causing a crash during the swap phase due to a relation gone missing.

The relations being reindexed, on which are taken the session locks, are
now pinned during the build and validation phases so as no manipulation
of their definition can happen in the session running a REINDEX
CONCURRENTLY.

Reported-by: Florent Saudel <[email protected]>
Author: Michael Paquier <[email protected]>
Backpatch-through: 14
Security: CVE-2026-116336

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/122d1f8be0b16a8c0c7959be37b94c75c1d924ee
Author: Michael Paquier <[email protected]>

Modified Files
--------------
src/backend/commands/indexcmds.c           | 62 ++++++++++++++++++++++++++++++
src/test/regress/expected/create_index.out | 27 +++++++++++++
src/test/regress/sql/create_index.sql      | 21 ++++++++++
3 files changed, 110 insertions(+)

Reply via email to