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