Re: bogus error message for ALTER TABLE ALTER CONSTRAINT
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: Álvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>,
Pg Hackers <pgsql-hackers@lists.postgresql.org>, Peter Eisentraut <peter@eisentraut.org>,
Nathan Bossart <nathandbossart@gmail.com>
Date: 2025-03-11T07:00:53Z
Lists: pgsql-hackers
On Tue, Mar 11, 2025 at 1:58 AM Álvaro Herrera <alvherre@alvh.no-ip.org> wrote:
>
> Hello,
>
> I fleshed this out more fully and I think 0001 is good enough to commit.
>
> I then noticed that constraints on domains are giving bogus error
> messages as well, and the situation is easily improved -- see 0002. I'm
> not so sure about this one, mainly because test coverage appears scant.
> I need to look into this one a bit more.
>
hi.
this look a little strange?
if (cas_bits & (CAS_NOT_DEFERRABLE) && seen)
seen->seen_deferrability = true;
it should be
if ((cas_bits & CAS_NOT_DEFERRABLE) && seen)
seen->seen_deferrability = true;
?
typedef struct CAS_flags need add to typedefs.list
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;
we can add the following into processCASbits to make it error out
if ((cas_bits & CAS_INITIALLY_IMMEDIATE) && seen)
seen->seen_deferrability = true;
create domain d_int as int4;
alter domain d_int add not null no inherit not valid;
ERROR: not-null constraints on domains cannot be marked NOT VALID
LINE 1: alter domain d_int add not null no inherit not valid;
^
If we can report an error like
"ERROR: NOT NULL constraints on domains cannot be marked INHERIT / NOT INHERIT"
That would be great.
just report the first constraint property that is not ok, but seems not doable.
Commits
-
Fix bogus grammar for a CREATE CONSTRAINT TRIGGER error
- 87251e114967 19 (unreleased) landed
-
Fix ALTER TABLE error message
- bf1e2d2db510 15.13 landed
- 9ea5fe5b6c80 16.9 landed
- 931a1c023790 14.18 landed
- 7bbc46213de9 18.0 landed
- 4e026be5f159 17.5 landed
- 0f354e0805ed 13.21 landed