Re: ALTER TABLE ALTER CONSTRAINT misleading error message

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: ALTER TABLE ALTER CONSTRAINT misleading error message
Date: 2025-05-28 11:59:29
Message-ID: 202505281159.3mjhwmmf6wuz@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2025-May-28, jian he wrote:

> hi.
>
> create table t(a int, constraint cc check(a = 1));
> ALTER TABLE t ALTER CONSTRAINT cc not valid;
> ERROR: FOREIGN KEY constraints cannot be marked NOT VALID
> LINE 1: ALTER TABLE t ALTER CONSTRAINT cc not valid;
> ^
>
> the error message seems misleading,

We discussed this already, didn't we? There's a thread with IIRC three
proposed patches for this. I think I liked this one the most:

https://postgr.es/m/CAAJ_b97hd-jMTS7AjgU6TDBCzDx_KyuKxG+K-DtYmOieg+giyQ@mail.gmail.com

--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"Computing is too important to be left to men." (Karen Spärck Jones)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tender Wang 2025-05-28 12:12:16 Re: Foreign key validation failure in 18beta1
Previous Message Fujii Masao 2025-05-28 11:36:32 Re: Add CHECK_FOR_INTERRUPTS in polling loop code path in XactLockTableWait