public inbox for [email protected]  
help / color / mirror / Atom feed
From: Michael Paquier <[email protected]>
To: Chao Li <[email protected]>
Cc: Postgres hackers <[email protected]>
Subject: Re: tablecmds: fix bug where index rebuild loses replica identity on partitions
Date: Tue, 27 Jan 2026 16:39:36 +0900
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

On Tue, Jan 27, 2026 at 01:13:32PM +0800, Chao Li wrote:
> I found this bug while working on a related patch [1].
> 
> When ALTER TABLE ... ALTER COLUMN TYPE causes an index rebuild, and
> that index is used as REPLICA IDENTITY on a partitioned table, the
> replica identity marking on partitions can be silently lost after the
> rebuild. 

I am slightly confused by the tests included in the proposed patch.
On HEAD, if I undo the proposed changes of tablecmds.c, the tests
pass.  If I run the tests of the patch with the changes of
tablecmds.c, the tests also pass.  These tests don't check what you
want them to.

-    if (tab->replicaIdentityIndex)
+    if (tab->replicaIdentityIndexOids != NIL)
         elog(ERROR, "relation %u has multiple indexes marked as replica identity", tab->relid);

This looks wrong to me.  This new list tracks the OIDs of indexes
where you'd want to make sure that relreplident is updated, and it
could be possible, based on your proposal, that multiple indexes are
stored in this list.  The error message is at least not in line
anymore.  Actually, do we really need this extra list at all?  The
list of indexes to rebuild are tracked already in changedIndexOids,
and the partitioned indexes seem to be in it, no?
--
Michael


Attachments:

  [application/pgp-signature] signature.asc (833B, 2-signature.asc)
  download

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: tablecmds: fix bug where index rebuild loses replica identity on partitions
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox