From 8f263374bb9d75e6226333c88f776acc09b68844 Mon Sep 17 00:00:00 2001 From: Sai Pranav Date: Sun, 22 Nov 2026 13:43:51 +0000 Subject: [PATCH v1] pg_upgrade: Ignore NO INHERIT not-null constraints in the inheritance check check_for_not_null_inheritance() reports child columns that are nullable while the parent's column is NOT NULL. But a not-null constraint marked NO INHERIT, possible since v18, doesn't apply to the children, so a valid v18 schema with one was rejected and could not be upgraded. Skip parent columns whose not-null constraint is NO INHERIT. Older versions have no not-null constraints in pg_constraint, so the check is unchanged for them. Reported-by: Alexander Lakhin Discussion: https://postgr.es/m/19928-c3f1f0dc1c0a44e9@postgresql.org --- src/bin/pg_upgrade/check.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c index 2d4aaf22a0..255e795766 100644 --- a/src/bin/pg_upgrade/check.c +++ b/src/bin/pg_upgrade/check.c @@ -1708,7 +1708,12 @@ check_for_not_null_inheritance(ClusterInfo *cluster) "WHERE cc.oid = ac.attrelid AND i.inhrelid = ac.attrelid " " AND i.inhparent = ap.attrelid AND ac.attname = ap.attname " " AND cc.relnamespace = nc.oid " - " AND ap.attnum > 0 and ap.attnotnull AND NOT ac.attnotnull"; + " AND ap.attnum > 0 and ap.attnotnull AND NOT ac.attnotnull " + /* a NO INHERIT not-null constraint doesn't apply to children */ + " AND NOT EXISTS (SELECT 1 FROM pg_catalog.pg_constraint c " + " WHERE c.conrelid = ap.attrelid " + " AND c.contype = 'n' AND c.connoinherit " + " AND ap.attnum = ANY (c.conkey))"; task = upgrade_task_create(); upgrade_task_add_step(task, query, -- 2.50.1 (Apple Git-155)