Re: ALTER TABLE ALTER CONSTRAINT misleading error message

Álvaro Herrera <alvherre@kurilemu.de>

From: Álvaro Herrera <alvherre@kurilemu.de>
To: Fujii Masao <masao.fujii@oss.nttdata.com>
Cc: jian he <jian.universality@gmail.com>, pgsql-hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-07-02T15:31:46Z
Lists: pgsql-hackers

Attachments

On 2025-Jul-02, Fujii Masao wrote:

> Regarding the 0003 patch:
> 
> +					if (($11 & CAS_NOT_ENFORCED) != 0)
> +						ereport(ERROR,
> +								errmsg("constraint triggers cannot be marked %s",
> +									   "NOT ENFORCED"),
> +								parser_errposition(@11));
> 
> Shouldn't we also raise an error when CAS_ENFORCED is given?

Great point -- ENFORCED can also throw the bogus error.  However, if you
say ENFORCED, the constraint is going to be enforced, which is the same
that happens if you don't say anything, so I think we should accept the
case.  So how about this?

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
"This is a foot just waiting to be shot"                (Andrew Dunstan)

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