bug: repeated ALTER COLUMN SET DATA TYPE corrupt check constraint

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: bug: repeated ALTER COLUMN SET DATA TYPE corrupt check constraint
Date: 2025-12-27 07:58:06
Message-ID: CACJufxFqejR+cPqxvB6RQW-t9Ji9VJQSoU514EQKRNbqRRyGQw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hi.

while working on let ALTER COLUMN SET DATA TYPE cope with trigger dependency.
I found this bug, it involves several ALTER COLUMN SET DATA TYPE calls.

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;
ALTER TABLE main_table ALTER COLUMN a SET DATA TYPE text;
ALTER TABLE main_table ALTER COLUMN b SET DATA TYPE text;
INSERT INTO main_table VALUES ('a', 'a');

This also applies to statistics, indexes. for statistics: the error is only
observable after running ANALYZE manually.

--
jian
https://www.enterprisedb.com/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Srinath Reddy Sadipiralla 2025-12-27 08:32:26 Re: bug: repeated ALTER COLUMN SET DATA TYPE corrupt check constraint
Previous Message Pavel Stehule 2025-12-27 07:52:28 Re: proposal: schema variables