]> git.ipfire.org Git - thirdparty/postgresql.git/commit
pg_upgrade: check for inconsistencies in not-null constraints w/inheritance REL_17_STABLE github/REL_17_STABLE
authorÁlvaro Herrera <alvherre@kurilemu.de>
Fri, 4 Jul 2025 16:05:43 +0000 (18:05 +0200)
committerÁlvaro Herrera <alvherre@kurilemu.de>
Fri, 4 Jul 2025 16:05:43 +0000 (18:05 +0200)
commitb8b2e60527c67599bb74895fc99d7feb7f97d706
treeca916cc64a47ef2a7c8ec6539262367c4d1efb4e
parentae20c105f0b20c80a6f57d43cf0ae118d0f53d7f
pg_upgrade: check for inconsistencies in not-null constraints w/inheritance

With tables defined like this,
  CREATE TABLE ip (id int PRIMARY KEY);
  CREATE TABLE ic (id int) INHERITS (ip);
  ALTER TABLE ic ALTER id DROP NOT NULL;

pg_upgrade fails during the schema restore phase due to this error:
  ERROR: column "id" in child table must be marked NOT NULL

This can only be fixed by marking the child column as NOT NULL before
the upgrade, which could take an arbitrary amount of time (because ic's
data must be scanned).  Have pg_upgrade's check mode warn if that
condition is found, so that users know what to adjust before running the
upgrade for real.

Author: Ali Akbar <the.apaan@gmail.com>
Reviewed-by: Justin Pryzby <pryzby@telsasoft.com>
Backpatch-through: 13
Discussion: https://postgr.es/m/CACQjQLoMsE+1pyLe98pi0KvPG2jQQ94LWJ+PTiLgVRK4B=i_jg@mail.gmail.com
src/bin/pg_upgrade/check.c