Re: refactor AlterDomainAddConstraint (alter domain add constraint)

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: refactor AlterDomainAddConstraint (alter domain add constraint)
Date: 2025-01-15 05:34:58
Message-ID: CACJufxFZg9FCvsBPpPt4xWVpeqhBxzTRZei=tENoL4=N25TrUw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jan 15, 2025 at 12:37 AM Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
>
> Hello,
>
> On 2024-Dec-09, jian he wrote:
>
> > ALTER DOMAIN ADD CONSTRAINT syntax more simple than CREATE DOMAIN.
>
> Your proposed patch makes the code simpler, yes, but I think it also
> makes the error messages worse. I don't think that's an improvement
> from the user point of view.
>

hi.
thanks for the comments!
we cannot error out AlterDomainAddConstraint for cases like ALTER
DOMAIN ADD CHECK NO INHERIT.
because "NO INHERIT" is actually a separate Constraint Node, and
AlterDomainAddConstraint
can only handle one Constraint node.

i believe I have addressed all the syntax problems related to the
ALTER DOMAIN command.
feel free to try the attached new patch.

examples with master:
create domain d_int as int4;
alter domain d_int add constraint cc check(value > 1) no inherit ;
---ok. success

alter domain d_int add constraint cc check(value > 1) not enforced; --error
ERROR: CHECK constraints cannot be marked NOT ENFORCED

alter domain d_int add constraint cc1 check(value > 1) not deferrable
initially immediate; --ok. success.
--------------------------------------------------------------------------
examples with patch:

alter domain d_int add constraint cc check(value > 1) no inherit;
ERROR: constraint specified as no-inherit is not supported for domains

alter domain d_int add constraint cc check(value > 1) not enforced;
ERROR: specifying constraint enforceability not supported for domains

alter domain d_int add constraint cc1 check(value > 1) not deferrable
initially immediate;
ERROR: specifying constraint deferrability not supported for domains

Attachment Content-Type Size
v4-0001-better-error-message-for-ALTER-DOMAIN-ADD-CONSTRA.patch application/x-patch 8.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-01-15 05:41:31 Re: Issue with markers in isolation tester? Or not?
Previous Message Amul Sul 2025-01-15 05:34:51 Re: Allow NOT VALID foreign key constraints on partitioned tables.