Re: ALTER TABLE ALTER CONSTRAINT misleading error message
Fujii Masao <masao.fujii@oss.nttdata.com>
From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: Álvaro Herrera <alvherre@kurilemu.de>
Cc: jian he <jian.universality@gmail.com>,
pgsql-hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-07-02T16:58:52Z
Lists: pgsql-hackers
On 2025/07/03 0:31, Álvaro Herrera wrote:
> 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?
Yeah, this approach works for me. TBH I'm fine with either way.
If we go with it, I’m slightly inclined to add [ ENFORCED ] to
the CREATE TRIGGER syntax in the docs. Without that, users might be confused
or raise concerns that CREATE CONSTRAINT TRIGGER accepts an option
(i.e., ENFORCED) that isn't actually documented in the syntax.
But if you think this is overkill, I'm ok not to update the syntax in the docs.
Regards,
--
Fujii Masao
NTT DATA Japan Corporation
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix bogus grammar for a CREATE CONSTRAINT TRIGGER error
- 87251e114967 19 (unreleased) landed
-
Fix error message for ALTER CONSTRAINT ... NOT VALID
- e16c9cd33131 18.0 landed
- c989affb527d 19 (unreleased) landed