Re: refactor AlterDomainAddConstraint (alter domain add constraint)
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-01-15T05:34:58Z
Lists: pgsql-hackers
Attachments
- v4-0001-better-error-message-for-ALTER-DOMAIN-ADD-CONSTRA.patch (application/x-patch) patch v4-0001
On Wed, Jan 15, 2025 at 12:37 AM Alvaro Herrera <alvherre@alvh.no-ip.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
Commits
-
Fix bogus grammar for a CREATE CONSTRAINT TRIGGER error
- 87251e114967 19 (unreleased) cited
-
Remove dead code
- 7407b2d48cf3 18.0 landed