let ALTER TABLE DROP COLUMN drop whole-row referenced object - Mailing list pgsql-hackers

From jian he
Subject let ALTER TABLE DROP COLUMN drop whole-row referenced object
Date
Msg-id CACJufxGA6KVQy7DbHGLVw9s9KKmpGyZt5ME6C7kEfjDpr2wZCw@mail.gmail.com
Whole thread Raw
Responses Re: let ALTER TABLE DROP COLUMN drop whole-row referenced object
List pgsql-hackers
hi.

CREATE TABLE ts (a int, c int, b int
    constraint cc check((ts = ROW(1,1,1))),
    constraint cc1 check((ts.a = 1)));
CREATE INDEX tsi on ts (a) where a = 1;
CREATE INDEX tsi2 on ts ((a is null));
CREATE INDEX tsi3 on ts ((ts is null));
CREATE INDEX tsi4 on ts (b) where ts is not null;

in the master, ``ALTER TABLE ts DROP COLUMN a;``
will not drop constraint cc, index tsi3, tsi4;

with the attached patch,
``ALTER TABLE ts DROP COLUMN a;``
will drop above all indexes on the table "ts" and also remove the
constraints "cc" and "cc1".

as per the documentation[1], quote:
"""
DROP COLUMN [ IF EXISTS ]
This form drops a column from a table. Indexes and table constraints involving
the column will be automatically dropped as well.
"""

so I think it's expected behavior to drop the entire
whole-row referenced indexes and constraints.

[1] https://www.postgresql.org/docs/devel/sql-altertable.html#SQL-ALTERTABLE-DESC-DROP-COLUMN

Attachment

pgsql-hackers by date:

Previous
From: Chao Li
Date:
Subject: Re: Allow logical replication in the same cluster
Next
From: BharatDB
Date:
Subject: Re: Adding skip scan (including MDAM style range skip scan) to nbtree