Re: ALTER TABLE ALTER CONSTRAINT misleading error message

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Cc: jian he <jian(dot)universality(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: ALTER TABLE ALTER CONSTRAINT misleading error message
Date: 2025-07-02 16:58:52
Message-ID: c29c0a07-b70c-4e5b-8f63-99412be8598a@oss.nttdata.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2025-07-02 17:02:00 Re: Inconsistent LSN format in pg_waldump output
Previous Message Nathan Bossart 2025-07-02 16:53:51 Re: add function for creating/attaching hash table in DSM registry