| From: | Alexander Lakhin <exclusion(at)gmail(dot)com> |
|---|---|
| To: | Raja Sai pranav <rajasaipranav0(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Cc: | Álvaro Herrera <alvherre(at)kurilemu(dot)de> |
| Subject: | Re: BUG #19928: pg_upgrade fails on v18 schema with NOT NULL ... NO INHERIT and inheritance |
| Date: | 2026-11-26 07:00:01 |
| Message-ID: | 95b9e618-55ce-4d02-bb98-9f1c8244c7eb@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Hello Sai,
22.11.2026 15:45, Raja Sai pranav wrote:
> 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.
Thank you for paying attention to that defect!
Would you like to look also at a close one?:
echo "CREATE DATABASE regression;
\connect regression
CREATE TABLE notnull_tbl1 (a int, b int);
ALTER TABLE notnull_tbl1 ADD CONSTRAINT nn NOT NULL a NOT VALID; -- ok
CREATE TABLE notnull_tbl1_child2 (c int, b int, a int);
ALTER TABLE notnull_tbl1_child2 ADD NOT NULL a NOT VALID;
ALTER TABLE notnull_tbl1_child2 INHERIT notnull_tbl1;
-- Tables needed for the version-adaptation step
CREATE TABLE brintest (lsncol pg_lsn);
CREATE TABLE tab_core_types (pg_lsn pg_lsn);
CREATE TABLE brintest_multi (lsncol pg_lsn);
CREATE TABLE brintest_bloom (lsncol pg_lsn);
" > /tmp/db18.sql
makes
olddump=/tmp/db18.sql oldinstall=/tmp/pg18 PROVE_TESTS="t/002*" make -s check -C src/bin/pg_upgrade/
fail as below:
# Restoring database schemas in the new cluster
# *failure*
#
# Consult the last few lines of
".../src/bin/pg_upgrade/tmp_check/t_002_pg_upgrade_new_node_data/pgdata/pg_upgrade_output.d/20261126T063528.875/log/pg_upgrade_dump_16384.log"
for
# the probable cause of the failure.
cat .../pg_upgrade_dump_16384.log
...
pg_restore: from TOC entry 3359; 2606 16392 CONSTRAINT notnull_tbl1_child2 notnull_tbl1_child2_a_not_null law
pg_restore: error: could not execute query: ERROR: cannot create not-null constraint "notnull_tbl1_child2_a_not_null"
on column "a" of table "notnull_tbl1_child2"
DETAIL: A not-null constraint named "nn" already exists for this column.
Command was: ALTER TABLE "public"."notnull_tbl1_child2"
ADD CONSTRAINT "notnull_tbl1_child2_a_not_null" NOT NULL "a" NOT VALID;
This can also be reproduced with:
sed -i '0,/^ALTER TABLE notnull_tbl1_child2 INHERIT notnull_tbl1;$/!d' src/test/regress/sql/constraints.sql
src/test/regress/expected/constraints.out
PROVE_TESTS="t/002*" make -s check -C src/bin/pg_upgrade/
Reproduced starting from 96e2af605 (at the previous commit, pg_upgrade
succeeds, but a follow-up dump compare fails).
Best regards,
Alexander
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Raja Sai pranav | 2026-11-26 07:15:11 | Re: BUG #19890: pg_receivewal advances past a truncated LZ4 WAL segment |
| Previous Message | John Naylor | 2026-11-26 05:13:32 | Re: SP-GiST quad_point_ops KNN scan can omit a closer point |