| From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Cc: | 125atishprak(at)gmail(dot)com |
| Subject: | BUG #19846: dump/restore marks inherited NOT VALID not-null constraint as local |
| Date: | 2026-11-07 15:10:48 |
| Message-ID: | 19846-abd715e593eba809@postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 19846
Logged by: Atish Prakash
Email address: 125atishprak(at)gmail(dot)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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | PG Bug reporting form | 2026-11-07 15:12:50 | BUG #19847: pg_dump loses ENFORCED on inherited CHECK under NOT ENFORCED parent |
| Previous Message | Atisss hh | 2026-11-07 14:20:30 | Re: BUG #19845: pg_dump extended stats break when column numbers change on restore |