Re: bogus error message for ALTER TABLE ALTER CONSTRAINT

2025-03-14 Thread Álvaro Herrera
On 2025-Mar-11, Amul Sul wrote: > I was thinking of something like the attached, which includes your > test cases from 0001. Perhaps the macro name could be improved. FWIW I like this general idea. I don't like the proposed names much though, especially the abuse of ALL_CAPS; and because they op

Re: bogus error message for ALTER TABLE ALTER CONSTRAINT

2025-03-11 Thread Álvaro Herrera
On 2025-Mar-04, Tom Lane wrote: > Hmm. I agree that "ALTER CONSTRAINT statement" is off the > mark here, but I'm not convinced that "FOREIGN KEY" is entirely > on-point either. The grammar has no way of knowing what kind of > constraint is being targeted. I do see that ATExecAlterConstraint > c

Re: bogus error message for ALTER TABLE ALTER CONSTRAINT

2025-03-11 Thread Amul Sul
On Mon, Mar 10, 2025 at 11:29 PM Álvaro Herrera wrote: > > Hello, > > I fleshed this out more fully and I think 0001 is good enough to commit. > The approach looks good to me, but instead of adding a CAS_flags struct, could we use macros like SEEN_DEFERRABILITY(bits), SEEN_ENFORCEABILITY(bits), e

Re: bogus error message for ALTER TABLE ALTER CONSTRAINT

2025-03-11 Thread Álvaro Herrera
On 2025-Mar-11, jian he wrote: > 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 immedia

Re: bogus error message for ALTER TABLE ALTER CONSTRAINT

2025-03-11 Thread jian he
On Tue, Mar 11, 2025 at 6:21 PM Álvaro Herrera 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 d

Re: bogus error message for ALTER TABLE ALTER CONSTRAINT

2025-03-11 Thread Amul Sul
On Tue, Mar 11, 2025 at 1:56 PM Álvaro Herrera wrote: > > On 2025-Mar-11, Amul Sul wrote: > > > On Mon, Mar 10, 2025 at 11:29 PM Álvaro Herrera > > wrote: > > > > > I fleshed this out more fully and I think 0001 is good enough to commit. > > > > The approach looks good to me, but instead of addi

Re: bogus error message for ALTER TABLE ALTER CONSTRAINT

2025-03-11 Thread Álvaro Herrera
On 2025-Mar-11, jian he wrote: > 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; True. And since you mentioned

Re: bogus error message for ALTER TABLE ALTER CONSTRAINT

2025-03-11 Thread Álvaro Herrera
On 2025-Mar-11, Amul Sul wrote: > On Mon, Mar 10, 2025 at 11:29 PM Álvaro Herrera > wrote: > > > I fleshed this out more fully and I think 0001 is good enough to commit. > > The approach looks good to me, but instead of adding a CAS_flags struct, could > we use macros like SEEN_DEFERRABILITY(bi

Re: bogus error message for ALTER TABLE ALTER CONSTRAINT

2025-03-11 Thread jian he
On Tue, Mar 11, 2025 at 1:58 AM Álvaro Herrera 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 su

Re: bogus error message for ALTER TABLE ALTER CONSTRAINT

2025-03-10 Thread Álvaro Herrera
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

Re: bogus error message for ALTER TABLE ALTER CONSTRAINT

2025-03-04 Thread Tom Lane
=?utf-8?Q?=C3=81lvaro?= Herrera writes: > I just discovered that trying to set a foreign key as NO INHERIT in > ALTER TABLE ALTER CONSTRAINT returns an absurd error message: > create table pk (a int primary key); > create table fk (a int references pk); > alter table fk alter constraint fk_a_fkey

bogus error message for ALTER TABLE ALTER CONSTRAINT

2025-03-04 Thread Álvaro Herrera
I just discovered that trying to set a foreign key as NO INHERIT in ALTER TABLE ALTER CONSTRAINT returns an absurd error message: create table pk (a int primary key); create table fk (a int references pk); alter table fk alter constraint fk_a_fkey deferrable, alter constraint fk_a_fkey no inheri

Re: bogus error message for ALTER TABLE ALTER CONSTRAINT

2025-03-04 Thread Álvaro Herrera
On 2025-Mar-04, Nathan Bossart wrote: > On Tue, Mar 04, 2025 at 07:22:22PM +0100, Álvaro Herrera wrote: > > I just discovered that trying to set a foreign key as NO INHERIT in > > ALTER TABLE ALTER CONSTRAINT returns an absurd error message: > > Here's the fix along with some additional cleanup.

Re: bogus error message for ALTER TABLE ALTER CONSTRAINT

2025-03-04 Thread Nathan Bossart
On Tue, Mar 04, 2025 at 07:22:22PM +0100, Álvaro Herrera wrote: > I just discovered that trying to set a foreign key as NO INHERIT in > ALTER TABLE ALTER CONSTRAINT returns an absurd error message: > > create table pk (a int primary key); > create table fk (a int references pk); > > alter table f