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

From: Raja Sai pranav <rajasaipranav0(at)gmail(dot)com>
To: 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-22 13:45:07
Message-ID: CAPHduZCB1YxKdtZ6H-htDKK03vmoqMUVS0OZaXbZuvH_9e8VRQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

I reproduced this with pg_upgrade from master and an 18.7 old cluster,
using just the two tables from your script.

check_for_not_null_inheritance() reports a child column that is nullable
while the parent's column is NOT NULL, but it doesn't look at whether the
parent's not-null constraint is NO INHERIT. Such a constraint doesn't apply
to the children, so this is a valid v18 schema.

The attached patch skips parent columns whose not-null constraint (contype
'n') is NO INHERIT. Versions before 18 have no not-null constraints in
pg_constraint, so the check is unchanged for them.

With the patch, pg_upgrade --check passes and the full upgrade works: the
NULL row is kept, the child column stays nullable, and the parent's
constraint is still NO INHERIT. A real inconsistency is still reported: I
made one on 18 by clearing attnotnull on a child column in pg_attribute,
and the check still lists it.

I didn't add a test, because the check only runs when the old cluster is 18
or older, so the same-version pg_upgrade tests never reach it. The patch is
for master and applies to REL_19_STABLE; REL_18_STABLE doesn't have this
check.

Regards,
Sai Pranav

Attachment Content-Type Size
v1-0001-pg_upgrade-Ignore-NO-INHERIT-not-null-constraints.patch application/octet-stream 1.8 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Kacper Kuras 2026-11-22 16:33:48 Re: BUG #18754: Logical replication cannot restart if client sent a copyDone
Previous Message Raja Sai pranav 2026-11-22 12:29:53 Re: BUG #19881: CLUSTER uses a disabled sort path when enable_sort is off