Re: BUG #19928: pg_upgrade fails on v18 schema with NOT NULL ... NO INHERIT and inheritance

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Raja Sai pranav <rajasaipranav0(at)gmail(dot)com>
Cc: exclusion(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19928: pg_upgrade fails on v18 schema with NOT NULL ... NO INHERIT and inheritance
Date: 2026-11-26 11:50:36
Message-ID: 519007dd-c7ad-476a-af7a-2d4e83419828@iki.fi
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 26/11/2026 11:53, Raja Sai pranav wrote:
> On 26/11/2026 09:32, Heikki Linnakangas wrote:
> > REL_18_STABLE does have this check too, it runs on a same-version
> > upgrade. But _why_ do we run that check on a 18->18 upgrade? The
> > scenario it's checking for should not be possible on a v18 cluster.
>
> You're right, and I was wrong about REL_18_STABLE: the check is there,
> with the same <= 1800 guard.
>
> I tested the scenario on 18.7: dropping the not-null constraint of a
> child column whose parent has an inheritable one fails with "cannot drop
> inherited constraint", and a NOT VALID constraint added on the parent
> gives the child a matching one. So I found no way to reach that state on
> v18.
>
> > So I think this needs to be backpatched to REL_18_STABLE too, and the
> > version guard should be fixed to:
> > [...]
> > And once you do that, you don't need to change the query in
> > check_for_not_null_inheritance() anymore, the query is correct for
> > pre-18 clusters. So all we need to do is fix that version guard.
>
> With only that change, pg_upgrade --check from 18.7 to master passes on
> the NO INHERIT schema from the report, and the full upgrade works. A PG
> 14 cluster with a real inconsistency (a child column whose NOT NULL was
> dropped) is still reported, and a clean PG 14 cluster passes.
>
> v2 attached: just your version guard change, with a commit message. It
> applies to master and to REL_18_STABLE. There is still no test, since
> the same-version pg_upgrade tests no longer reach the check.

Pushed, thanks.

- Heikki

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Álvaro Herrera 2026-11-26 12:35:51 Re: reltuples kept decreasing with each autovacuum run Re: BUG #18773
Previous Message Srinath Reddy Sadipiralla 2026-11-26 11:33:03 Re: BUG #19952: psql \d+ omits nondefault replica identity for partitioned tables