public inbox for [email protected]  
help / color / mirror / Atom feed
From: Chao Li <[email protected]>
To: jian he <[email protected]>
Cc: PostgreSQL-development <[email protected]>
Subject: Re: let ALTER TABLE DROP COLUMN drop whole-row referenced object
Date: Thu, 11 Sep 2025 09:27:27 +0800
Message-ID: <[email protected]> (raw)
In-Reply-To: <CACJufxFMqpraCreGKTWWB7cyPAYP+yehwTMFm-CSx+rzWdHf+A@mail.gmail.com>
References: <CACJufxGA6KVQy7DbHGLVw9s9KKmpGyZt5ME6C7kEfjDpr2wZCw@mail.gmail.com>
	<CACJufxFMqpraCreGKTWWB7cyPAYP+yehwTMFm-CSx+rzWdHf+A@mail.gmail.com>



> On Sep 9, 2025, at 11:12, jian he <[email protected]> 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/






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]
  Subject: Re: let ALTER TABLE DROP COLUMN drop whole-row referenced object
  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