| From: | Raja Sai pranav <rajasaipranav0(at)gmail(dot)com> |
|---|---|
| To: | alvherre(at)kurilemu(dot)de |
| Cc: | exclusion(at)gmail(dot)com, 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-26 21:22:00 |
| Message-ID: | CAPHduZCxvaNk7X1_JCzsXzFBzJhLkwgX7cVSyDq4OrX51g1zVw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
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.
Without the patch, all but the partitioned case fail to restore. With
it, all of them restore and the catalog matches the source.
I added a table pair to constraints.sql and left it in place, so that
002_pg_upgrade covers this. Without the pg_dump change, that test fails
with the reported error. With it, the pg_upgrade, pg_dump and regress
suites pass on master.
REL_18_STABLE now has the same failure: the name check is there too,
after 18.7. An 18.7 dump still restores, but the child silently gets
the parent's constraint name with conislocal = false. That is the dump
mismatch Alexander mentioned for the commit before the check. The
second attachment is the same fix for REL_18_STABLE. The pg_upgrade,
pg_dump and regress suites pass there, and 002_pg_upgrade fails
without it. The master patch applies to REL_19_STABLE as is.
Regards,
Sai Pranav
On Thu, Nov 26, 2026 06:26 PM, Alvaro Herrera <alvherre(at)kurilemu(dot)de> wrote:
> On 2026-Nov-26, Raja Sai pranav wrote:
>
> > Yes, thanks. I reproduced it: a master pg_dump of this schema from 18.7
> > fails to restore into master with the same error. It doesn't need
> > pg_upgrade or an older server, though: creating the schema on master
> > and doing a plain pg_dump / psql restore into another master database
> > fails the same way.
> >
> > pg_dump emits both NOT VALID constraints as separate ALTER TABLE ... ADD
> > CONSTRAINT commands after the data, parent first. Adding "nn" to the
> > parent recurses and gives the child an inherited constraint named "nn",
> > so the child's own command then fails the name check added by 96e2af605.
>
> Interesting.
>
> > I'll look into a fix, unless Álvaro would rather handle it.
>
> Please go ahead.
>
> --
> Álvaro Herrera PostgreSQL Developer —
> https://www.EnterpriseDB.com/
>
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-pg_dump-Restore-a-child-s-NOT-VALID-not-null-cons.patch | text/x-patch | 5.6 KB |
| v1-0001-pg_dump-Restore-a-child-s-NOT-VALID-not-null-cons-REL_18.patch | text/x-patch | 5.6 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Raja Sai pranav | 2026-11-26 21:23:22 | Re: BUG #19890: pg_receivewal advances past a truncated LZ4 WAL segment |
| Previous Message | Tom Lane | 2026-11-26 21:18:48 | Re: btree_gist: <-> fails on same-sign infinite intervals |