Re: persevere NO INHERIT when Dump not-null constraints on inherited columns

Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>

From: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
To: Álvaro Herrera <alvherre@kurilemu.de>
Cc: jian he <jian.universality@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2026-02-26T12:19:11Z
Lists: pgsql-hackers
On Thu, Feb 26, 2026 at 4:22 PM Álvaro Herrera <alvherre@kurilemu.de> wrote:
>
> On 2026-Feb-25, Álvaro Herrera wrote:
>
> > On 2026-Feb-25, Álvaro Herrera wrote:
> >
> > > Ugh, you're right, this is broken and your patch fixes it.
> > >
> > > I'm gonna write a quick test case for this and push as soon as I'm able.
> >
> > Here it is.
>
> Pushed.  I also added a test for the standard case of NO INHERIT in a
> not-null constraint.
>
> Thanks for reporting this.

This could have been caught by 002_pg_upgrade's regression
dump/restore test, if we had a NO INHERIT on child being tested in
regression test and not dropped. I browsed through regression tests
testing NO INHERIT. I found some adding NO INHERIT check constraint on
child table but no NOT NULL constraint on child table. But I didn't
look very closely. If that's true, we may not have enough coverage to
check whether NO INHERIT on a child table is honoured or not when a
grandchild is added. I did find a test which tests that NO INHERIT NOT
NULL on the child table is not merged with normal NOT NULL constraint.

-- 
Best Wishes,
Ashutosh Bapat



Commits

  1. pg_dump: Preserve NO INHERIT on NOT NULL on inheritance children

  2. Dump not-null constraints on inherited columns correctly