Re: BUG #19846: dump/restore marks inherited NOT VALID not-null constraint as local

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Kirill Reshke <reshkekirill(at)gmail(dot)com>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Cc: 125atishprak(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19846: dump/restore marks inherited NOT VALID not-null constraint as local
Date: 2026-12-03 02:53:18
Message-ID: CAGRkXqToFWu1a+45CW4BRT7FsGNsCGfT3tqT6X3Wg-Rog9-xAw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Kirill,

Thanks for checking the plain dump side too. Yes, a plain dump still
restores it as local. Fixing that means not printing the child's
constraint and running VALIDATE on the child after the parent's
constraint is added, which is an extra scan of each such child.

It is also harder than it looks. I tried it first. With two NOT VALID
parents that use different names, the child's name depends on restore
order. Then the VALIDATE can miss it and the restore fails.
Multi-level partitioning also needs care at every level, or a leaf
still comes back local.

The only visible effect is that the child keeps NOT NULL when the
parent's constraint is dropped. So I would fix pg_upgrade in 18 and up
first. If Alvaro thinks plain dumps are worth it too, I am happy to
send a patch for that.

Thanks,
Shihao

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message shihao zhong 2026-12-03 03:03:16 Re: BUG #17545: Incorrect selectivity for IS NOT DISTINCT FROM and NULLs
Previous Message shihao zhong 2026-12-03 02:44:59 Re: BUG #19872: JSON_TABLE: an UNUSED PASSING argument's COLLATE leaks into the output columns (wrong results, persi