Re: BUG #19074: pg_dump from v18 loses the NOT NULL flag in the inherited table field when dumping v17-databases
Álvaro Herrera <alvherre@kurilemu.de>
From: Álvaro Herrera <alvherre@kurilemu.de>
To: Andrew Bille <andrewbille@gmail.com>
Cc: Dilip Kumar <dilipbalaut@gmail.com>, David Rowley <dgrowleyml@gmail.com>, pgsql-bugs@lists.postgresql.org
Date: 2025-10-18T12:06:56Z
Lists: pgsql-bugs
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix determination of not-null constraint "locality" for inherited columns
- c945b06d5f03 17.7 landed
- 615ff828e1cb 19 (unreleased) landed
- 0fe07fa115f5 18.1 landed
-
Fix pg_dump sorting of foreign key constraints
- d20df9590aef 13.23 landed
- 7419c99a25fb 17.7 landed
- 6062c3db3093 14.20 landed
- 4cc3b4445913 15.15 landed
- 4921a5972a34 19 (unreleased) landed
- 162e70ea06eb 18.1 landed
- 06c1ee6b75dc 16.11 landed
-
Sort dump objects independent of OIDs, for the 7 holdout object types.
- 0decd5e89db9 19 (unreleased) cited
-
Add pg_constraint rows for not-null constraints
- 14e87ffa5c54 18.0 cited
By the way, while testing this, I ran into a pg_dump bug. In the object
sorting algorithm (DOTypeNameCompare), we fail to process objects of
type DO_FK_CONSTRAINT correctly (which is to say: identically to
DO_CONSTRAINT ones), so we fall back to compare by OID, and in debug
builds, the assertion at the bottom of the routine fires. The fix is
trivial:
diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c
index a51064f21e3..0aec83bedb2 100644
--- a/src/bin/pg_dump/pg_dump_sort.c
+++ b/src/bin/pg_dump/pg_dump_sort.c
@@ -328,7 +328,8 @@ DOTypeNameCompare(const void *p1, const void *p2)
if (cmpval != 0)
return cmpval;
}
- else if (obj1->objType == DO_CONSTRAINT)
+ else if (obj1->objType == DO_CONSTRAINT ||
+ obj1->objType == DO_FK_CONSTRAINT)
{
ConstraintInfo *robj1 = *(ConstraintInfo *const *) p1;
ConstraintInfo *robj2 = *(ConstraintInfo *const *) p2;
I'll apply this separately, because it goes back to 13 (commit
0decd5e89db9).
--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"Computing is too important to be left to men." (Karen Spärck Jones)