Re: ALTER TABLE ALTER CONSTRAINT misleading error message

Álvaro Herrera <alvherre@kurilemu.de>

From: Álvaro Herrera <alvherre@kurilemu.de>
To: jian he <jian.universality@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-05-28T11:59:29Z
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)



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix bogus grammar for a CREATE CONSTRAINT TRIGGER error

  2. Fix error message for ALTER CONSTRAINT ... NOT VALID