]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Flush table's relcache during ALTER TABLE ADD PRIMARY KEY USING INDEX.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 22 Jan 2022 18:32:40 +0000 (13:32 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 22 Jan 2022 18:32:40 +0000 (13:32 -0500)
commit31b7b4d26e10086d4a79d49a28fd161da52da49a
tree55172e6e86e29a137a0ebdc6b33527742ca84cba
parent64ebb43df068e3a9c01beeaacf7842080c43e712
Flush table's relcache during ALTER TABLE ADD PRIMARY KEY USING INDEX.

Previously, unless we had to add a NOT NULL constraint to the column,
this command resulted in updating only the index's relcache entry.
That's problematic when replication behavior is being driven off the
existence of a primary key: other sessions (and ours too for that
matter) failed to recalculate their opinion of whether the table can
be replicated.  Add a relcache invalidation to fix it.

This has been broken since pg_class.relhaspkey was removed in v11.
Before that, updating the table's relhaspkey value sufficed to cause
a cache flush.  Hence, backpatch to v11.

Report and patch by Hou Zhijie

Discussion: https://postgr.es/m/OS0PR01MB5716EBE01F112C62F8F9B786947B9@OS0PR01MB5716.jpnprd01.prod.outlook.com
src/backend/catalog/index.c
src/test/regress/expected/publication.out
src/test/regress/sql/publication.sql