pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
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:32:59 +0000
Message-ID: <E1nBLC7-0004uh-VG@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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d8fbbb925bdb8ca1c8eb8572192f4ee199f4d276

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(+)



view thread (5+ messages)  latest in thread

Message-ID: <E1nBLC7-0004uh-VG@gemulon.postgresql.org>
Permalink:  ../E1nBLC7-0004uh-VG@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1nBLC7-0004uh-VG@gemulon.postgresql.org

 · 

reply

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: <E1nBLC7-0004uh-VG@gemulon.postgresql.org>
  References: <E1nBLC7-0004uh-VG@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