Re: Confused comment about drop replica identity index - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Confused comment about drop replica identity index
Date
Msg-id YdKqBchHjcj1e2vH@paquier.xyz
Whole thread Raw
In response to RE: Confused comment about drop replica identity index  ("houzj.fnst@fujitsu.com" <houzj.fnst@fujitsu.com>)
List pgsql-hackers
On Thu, Dec 30, 2021 at 06:45:30AM +0000, houzj.fnst@fujitsu.com wrote:
> I think forbids DROP INDEX might not completely solve this problem. Because
> user could still use other command to delete the index, for example: ALTER
> TABLE DROP COLUMN. After dropping the column, the index on it will also be
> dropped.
>
> Besides, user can also ALTER REPLICA IDENTITY USING INDEX "primary key", and in
> this case, when they ALTER TABLE DROP CONSTR "PRIMARY KEY", the replica
> identity index will also be dropped.

Indexes related to any other object type, like constraints, are
dropped as part of index_drop() as per the handling of dependencies.
So, by putting a restriction there, any commands would take this code
path, and fail when trying to drop an index used as a replica
identity.  Why would that be logically a problem?  We may want errors
with more context for such cases, though, as complaining about an
object not directly known by the user when triggering a different
command, like a constraint index, could be confusing.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: "Andrey V. Lepikhov"
Date:
Subject: Clarify planner_hook calling convention
Next
From: Michael Paquier
Date:
Subject: Re: pg_receivewal fail to streams when the partial file to write is not fully initialized present in the wal receiver directory