From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
---|---|
To: | jian he <jian(dot)universality(at)gmail(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: let ALTER TABLE DROP COLUMN drop whole-row referenced object |
Date: | 2025-09-11 01:27:27 |
Message-ID: | 2B70C6CA-606B-438C-8EF2-84DCBA1C0813@gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> On Sep 9, 2025, at 11:12, jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> hi.
> I found a new way to solve this problem.
>
> CREATE TABLE ts (a int, c int, b int
> constraint cc check((ts = ROW(1,1,1))),
> constraint cc1 check((ts.a = 1)));
>
>
> ALTER TABLE ts DROP COLUMN a CASCADE;
> will drop above all indexes, constraints and policies on the table ts.
> <v2-0001-ALTER-TABLE-DROP-COLUMN-drop-wholerow-referenced-object.patch>
I agree we should delete those constraints and indices on the whole row, otherwise, with cc (ts=ROW(1,1,1)), once a column is dropped, it won’t be able to insert data anymore:
```
evantest=# insert into ts values (2, 3);
ERROR: new row for relation "ts" violates check constraint "cc"
DETAIL: Failing row contains (2, 3).
evantest=# insert into ts values (1, 1);
ERROR: cannot compare record types with different numbers of columns
```
But v2 needs a rebase, I cannot apply it to master.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2025-09-11 01:33:28 | Re: someone else to do the list of acknowledgments |
Previous Message | Michael Paquier | 2025-09-11 01:16:58 | Re: Stale comment in guc.h; publish listing of setting sources? |