| From: | Alexander Lakhin <exclusion(at)gmail(dot)com> |
|---|---|
| To: | Raja Sai pranav <rajasaipranav0(at)gmail(dot)com>, alvherre(at)kurilemu(dot)de |
| Cc: | 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-27 09:00:00 |
| Message-ID: | d93d3d87-99ac-490a-acac-7721a2b34914@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Hello Sai,
26.11.2026 23:22, Raja Sai pranav wrote:
> On 2026-Nov-26, Álvaro Herrera wrote:
> > > I'll look into a fix, unless Álvaro would rather handle it.
> >
> > Please go ahead.
>
> Here is a patch. pg_dump now makes each ancestor's NOT VALID not-null
> constraints depend on the child's own, so the child's command runs first
> and the parent's then merges into it, the same way the original schema
> was built. The restored catalog then matches the source: the child keeps
> its own constraint name, with conislocal = true and coninhcount = 1.
>
> I checked plain and parallel (pg_restore -j4) restores of these cases
> with and without the patch:
>
> - the schema from Alexander's report;
> - three levels, each with its own NOT VALID constraint;
> - a middle table with only the inherited constraint, between a parent
> and a grandchild that both have their own;
> - a child with two parents, each with a NOT VALID constraint;
> - a partitioned table with a NOT VALID constraint.
I've found another case, which probably should be fixed as well:
echo "CREATE DATABASE regression;
\connect regression
create table inh_nn1 (f1 int primary key references inh_nn1);
alter table inh_nn1 alter constraint inh_nn1_f1_not_null no inherit;
-- 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/db.sql
olddump=/tmp/db.sql oldinstall=`pwd`/tmp_install/usr/local/pgsql PROVE_TESTS="t/002*" make -s check -C src/bin/pg_upgrade/
...
# 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/20261127T100429.284/log/pg_upgrade_dump_16384.log"
for
# the probable cause of the failure.
# Failure, exiting
tail .../pg_upgrade_dump_16384.log
...
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 3382; 2606 16390 CONSTRAINT inh_nn1 inh_nn1_pkey law
pg_restore: error: could not execute query: ERROR: cannot create primary key on column "f1"
DETAIL: The constraint "inh_nn1_f1_not_null" on column "f1" of table "inh_nn1", marked NO INHERIT, is incompatible with
a primary key.
HINT: You might need to make the existing constraint inheritable using ALTER TABLE ... ALTER CONSTRAINT ... INHERIT.
Command was:
-- For binary upgrade, must preserve pg_class oids, toast chunk type oids and relfilenodes
SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('16389'::pg_catalog.oid);
SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('16389'::pg_catalog.oid);
ALTER TABLE ONLY "public"."inh_nn1"
ADD CONSTRAINT "inh_nn1_pkey" PRIMARY KEY ("f1");
Best regards,
Alexander
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Kirill Reshke | 2026-11-27 09:40:27 | Re: PostgreSQL 17.11: SIGSEGV in dsa_free after "could not resize shared memory segment ... No space left on device" |
| Previous Message | Hayato Kuroda (Fujitsu) | 2026-11-27 08:59:03 | RE: BUG #19892: Logical replication skips UPDATE/DELETE of rows with NULL in a hash-indexed subscriber column |