From: | jian he <jian(dot)universality(at)gmail(dot)com> |
---|---|
To: | Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Nathan Bossart <nathandbossart(at)gmail(dot)com> |
Subject: | Re: bogus error message for ALTER TABLE ALTER CONSTRAINT |
Date: | 2025-03-11 13:06:05 |
Message-ID: | CACJufxGaAdNfF+-x6ZNpvEv7mhmjfcdr9PN-ZsPYe=z-b4seUg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Mar 11, 2025 at 6:21 PM Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
>
>
> > seems didn't cover "initially immediate" case for domain.
> > for example:
> > create domain d_int as int4;
> > --- the following two cases should fail.
> > alter domain d_int add constraint nn1 not null initially immediate;
> > alter domain d_int add constraint cc check(value > 1) initially immediate;
>
> Yeah, I thought at first you were right, but on further thought, do we
> really want to do this? I mean, INITIALLY IMMEDIATE is the default
> timing for a constraint, so why should we complain if a user wants to
> get a constraint that's declared that way? I'm not sure that we should
> do it. Same with NOT DEFERRABLE.
> [... looks at the standard doc ...]
> And that's indeed what the SQL standard says:
>
> <domain definition> ::=
> CREATE DOMAIN <domain name> [ AS ] <predefined type>
> [ <default clause> ]
> [ <domain constraint>... ]
> [ <collate clause> ]
>
> <domain constraint> ::=
> [ <constraint name definition> ] <check constraint definition> [ <constraint characteristics> ]
>
> 8) For every <domain constraint> specified:
> [...]
> b) If <constraint characteristics> is not specified, then INITIALLY IMMEDIATE
> NOT DEFERRABLE is implicit.
>
>
> So I think the fix here needs to distinguish those cases and avoid
> throwing errors for them.
>
> (Note also it does not say that INITIALLY DEFERRED or DEFERRABLE are
> disallowed, which means that we're failing to fully implement the
> standard-mandated behavior by prohibiting those.)
>
I don't have a huge opinion though.
but it's better to align CREATE DOMAIN with ALTER DOMAIN.
For example, the following two logic should behave the same.
create domain d_int as int4 constraint nn1 not null initially immediate;
alter domain d_int add constraint nn1 not null initially immediate;
Also if we do not error out, then in the create_domain.sgml, alter_domain.sgml
<synopsis> section we should include these "useless" keywords.
From | Date | Subject | |
---|---|---|---|
Next Message | Dagfinn Ilmari Mannsåker | 2025-03-11 13:07:35 | Re: Changing the state of data checksums in a running cluster |
Previous Message | Anthonin Bonnefoy | 2025-03-11 13:04:27 | Re: Memory context can be its own parent and child in replication command |