Re: ALTER TABLE ALTER CONSTRAINT misleading error message - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: ALTER TABLE ALTER CONSTRAINT misleading error message
Date
Msg-id c29c0a07-b70c-4e5b-8f63-99412be8598a@oss.nttdata.com
Whole thread Raw
In response to ALTER TABLE ALTER CONSTRAINT misleading error message  (jian he <jian.universality@gmail.com>)
List 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




pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: add function for creating/attaching hash table in DSM registry
Next
From: Masahiko Sawada
Date:
Subject: Re: Inconsistent LSN format in pg_waldump output