Re: bug: repeated ALTER COLUMN SET DATA TYPE corrupt check constraint

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: bug: repeated ALTER COLUMN SET DATA TYPE corrupt check constraint
Date: 2025-12-27 11:32:06
Message-ID: CACJufxECtm=EpiquvXhWKmP0x7-RNt5=qDuXJuuQkQ+6bOFXLA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Dec 27, 2025 at 4:32 PM Srinath Reddy Sadipiralla
<srinath2133(at)gmail(dot)com> wrote:
>>
>
> Yeah, I can easily reproduce this.
>
hi.

thinking about it more...
I tend to think it's not a bug.
because SET DATA TYPE changes the CHECK constraint definition.

>> DROP TABLE IF EXISTS main_table;
>> CREATE TABLE main_table (a int, b int, check(a = b));
>> ALTER TABLE main_table ALTER COLUMN a SET DATA TYPE numeric;
>> ALTER TABLE main_table ALTER COLUMN a SET DATA TYPE int;

At this stage, the constraint definition is no longer "a = b",
it becomes "(a::numeric = b::numeric)", which is different from "(a = b)".

sorry for the noise.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Laurenz Albe 2025-12-27 12:15:58 Re: Get rid of "Section.N.N.N" on DOCs
Previous Message cca5507 2025-12-27 09:52:59 Missing oauth_validator_libraries in variable_is_guc_list_quote()