From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Flush table's relcache during ALTER TABLE ADD PRIMARY KEY USING
Date: Sat, 22 Jan 2022 18:33:00 +0000
Message-ID: <E1nBLC8-0004un-0E@gemulon.postgresql.org> (raw)
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
Branch
------
REL_12_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/e2d53c8767da9f98c7c4c8d0b129171848472c93
Modified Files
--------------
src/backend/catalog/index.c | 11 +++++++++++
src/test/regress/expected/publication.out | 14 ++++++++++++++
src/test/regress/sql/publication.sql | 13 +++++++++++++
3 files changed, 38 insertions(+)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Flush table's relcache during ALTER TABLE ADD PRIMARY KEY USING
In-Reply-To: <E1nBLC8-0004un-0E@gemulon.postgresql.org>
References: <E1nBLC8-0004un-0E@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox