Re: Re: Re: BUG #19351: in pg18.1,when not null exists in the table , and add constraint problem.

From: Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>
To: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Cc: yanliang lei <msdnchina(at)163(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Re: Re: BUG #19351: in pg18.1,when not null exists in the table , and add constraint problem.
Date: 2026-02-01 12:19:07
Message-ID: CAFC+b6oVFELdux6b71LSs=_SJHT-O4MODV40VDy3aOYVR3YkQg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Álvaro

On Mon, Jan 26, 2026 at 8:03 PM Álvaro Herrera <alvherre(at)kurilemu(dot)de> wrote:

>
>
> > I think we can fix this by throwing an error only if this constraint
> > was added directly to the table and not through
> > inheritance/propagation from the parent, we can do this using the
> > "is_local" flag, i have checked and all tests passed.
>
> Hmm, I'm not opposed to this; does it change any other behavior? I
> think it's important to see whether there are other corner cases that
> would react to this behavior change. For example, what would happen if
> two existing parents have a not-null constraint on the same column? Is
> there a change for combined LIKE and regular inheritance? I think we
> should have reasonable reactions to each of those scenarios:
>
> create table parent (a int not null);
> create table parent2 (a int not null);
>
> create table child1 () inherits (parent, parent2);
> create table child2 () inherits (parent2, parent);
> create table child3 (not null a) inherits (parent2, parent);
>
> create table child4 (like parent) inherits (parent2);
> -- and so on as your imagination allows
>

as you have suggested i have looked whether it effects the other behaviour
,during table creation with not null constraints i observed that flow
doesn't
touch the AdjustNotNullInheritance where we added the error message,
When running CREATE TABLE, the standard NOT NULL merging logic is
handled by DefineRelation -> AddRelationNotNullConstraints. This function
explicitly handles the "Constraint Selection" logic (prioritizing the
Child's
constraint if present, otherwise defaulting to the 1st parent's constraint),
please correct me if I totally understood your concerns wrong here.

> Would you be able to send a patch based on this idea and what I sent
> earlier?
>

I've attached the updated patch.

--
Thanks,
Srinath Reddy Sadipiralla
EDB: https://www.enterprisedb.com/

Attachment Content-Type Size
v2-0001-Reject-ADD-CONSTRAINT-NOT-NULL-if-name-mismatches-ex.patch application/octet-stream 11.1 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Chris Hanks 2026-02-01 18:56:47 Function not found while creating partial index
Previous Message Álvaro Herrera 2026-01-31 16:08:10 Re: basic_archive lost archive_directory