From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: 125atishprak@gmail.com
Subject: BUG #19846: dump/restore marks inherited NOT VALID not-null constraint as local
Date: Sat, 07 Nov 2026 15:10:48 +0000
Message-ID: <19846-abd715e593eba809@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 19846
Logged by: Atish Prakash
Email address: 125atishprak@gmail.com
PostgreSQL version: 18.6
Operating system: Linux x86_64
Description:
A child's not-null constraint inherited from a NOT VALID parent constraint
comes
back with conislocal = true after a dump and restore. The child then behaves
differently when the parent's constraint is dropped.
CREATE TABLE np(a int, b int);
ALTER TABLE np ADD CONSTRAINT nb NOT NULL b NOT VALID;
CREATE TABLE nc() INHERITS (np);
SELECT conislocal FROM pg_constraint
WHERE conrelid = 'nc'::regclass AND conname = 'nb';
-- original: f restored: t
ALTER TABLE np DROP CONSTRAINT nb;
SELECT attnotnull FROM pg_attribute
WHERE attrelid = 'nc'::regclass AND attname = 'b';
-- original: f restored: t
Expected: the same result before and after the restore. A child of a valid
not-null constraint does not show the difference in conislocal. Partitions
are
also affected: a partition of a table with a NOT VALID not-null constraint
comes
back with conislocal = true in the same way.
pg_upgrade from 19rc1 to master changes conislocal in the same way.
I have not written a patch or traced the exact statements responsible.
Found with dump and restore differential tests. I reproduced and checked the
result myself.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, 125atishprak@gmail.com
Subject: Re: BUG #19846: dump/restore marks inherited NOT VALID not-null constraint as local
In-Reply-To: <19846-abd715e593eba809@postgresql.org>
References: <19846-abd715e593eba809@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox