postgresql/src/include/storage
Noah Misch e2eefb97e3 Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX.
Commit 5b562644fe added a comment that
SetRelationHasSubclass() callers must hold this lock.  When commit
17f206fbc8 extended use of this column to
partitioned indexes, it didn't take the lock.  As the latter commit
message mentioned, we currently never reset a partitioned index to
relhassubclass=f.  That largely avoids harm from the lock omission.  The
cause for fixing this now is to unblock introducing a rule about locks
required to heap_update() a pg_class row.  This might cause more
deadlocks.  It gives minor user-visible benefits:

- If an ALTER INDEX SET TABLESPACE runs concurrently with ALTER TABLE
  ATTACH PARTITION or CREATE PARTITION OF, one transaction blocks
  instead of failing with "tuple concurrently updated".  (Many cases of
  DDL concurrency still fail that way.)

- Match ALTER INDEX ATTACH PARTITION in choosing to lock the index.

While not user-visible today, we'll need this if we ever make something
set the flag to false for a partitioned index, like ANALYZE does today
for tables.  Back-patch to v12 (all supported versions), the plan for
the commit relying on the new rule.  In back branches, add
LockOrStrongerHeldByMe() instead of adding a LockHeldByMe() parameter.

Reviewed (in an earlier version) by Robert Haas.

Discussion: https://postgr.es/m/20240611024525.9f.nmisch@google.com
2024-06-27 19:21:13 -07:00
..
.gitignore When trace_lwlocks is used, identify individual lwlocks by name. 2015-09-11 14:01:39 -04:00
backendid.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
barrier.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
block.h Fix bogus casting in BlockIdGetBlockNumber(). 2022-03-03 19:03:46 -05:00
buf.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
buf_internals.h Ensure we use the correct spelling of "ensure" 2023-11-10 00:18:33 +13:00
buffile.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
bufmgr.h Revert "Skip WAL for new relfilenodes, under wal_level=minimal." 2020-03-22 09:24:13 -07:00
bufpage.h Extend PageIsVerified() to handle more custom options 2020-11-02 10:41:30 +09:00
checksum.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
checksum_impl.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
condition_variable.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
copydir.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
dsm.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
dsm_impl.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
fd.h Fix many typos and inconsistencies 2019-07-01 10:00:23 +09:00
freespace.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
fsm_internals.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
indexfsm.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
ipc.h Consistently test for in-use shared memory. 2019-04-12 22:36:38 -07:00
item.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
itemid.h Standardize ItemIdData terminology. 2019-05-13 15:53:39 -07:00
itemptr.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
large_object.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
latch.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
lmgr.h Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX. 2024-06-27 19:21:13 -07:00
lock.h Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX. 2024-06-27 19:21:13 -07:00
lockdefs.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
lwlock.h lwlock: Fix quadratic behavior with very long wait lists 2024-01-18 11:12:48 +09:00
md.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
off.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_sema.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_shmem.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
pmsignal.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
predicate.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
predicate_internals.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
proc.h lwlock: Fix quadratic behavior with very long wait lists 2024-01-18 11:12:48 +09:00
procarray.h Improve heuristics for compressing the KnownAssignedXids array. 2022-11-29 15:43:17 -05:00
proclist.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
proclist_types.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
procsignal.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
reinit.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
relfilenode.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
s_lock.h Allow use of __sync_lock_test_and_set for spinlocks on any machine. 2022-11-02 17:37:26 -04:00
sharedfileset.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
shm_mq.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
shm_toc.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
shmem.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
sinval.h Remove superfluous newlines in function prototypes. 2019-07-31 00:07:09 -07:00
sinvaladt.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
smgr.h Revert "Skip WAL for new relfilenodes, under wal_level=minimal." 2020-03-22 09:24:13 -07:00
spin.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
standby.h Fix MVCC bug with prepared xact with subxacts on standby 2024-06-27 21:09:15 +03:00
standbydefs.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
sync.h Fix assorted inconsistencies. 2019-06-08 08:16:38 +05:30