]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Sort dump objects independent of OIDs, for the 7 holdout object types. REL_17_STABLE github/REL_17_STABLE
authorNoah Misch <noah@leadboat.com>
Thu, 31 Jul 2025 13:37:56 +0000 (06:37 -0700)
committerNoah Misch <noah@leadboat.com>
Thu, 31 Jul 2025 13:38:00 +0000 (06:38 -0700)
commit1ca1889ea6a31e4b4f128e849c614959090f2c1c
tree1a27da14989ad27cf965e63c3a10f575dd722828
parent5dd4957b28df92d25508e4d0c950099c52347a75
Sort dump objects independent of OIDs, for the 7 holdout object types.

pg_dump sorts objects by their logical names, e.g. (nspname, relname,
tgname), before dependency-driven reordering.  That removes one source
of logically-identical databases differing in their schema-only dumps.
In other words, it helps with schema diffing.  The logical name sort
ignored essential sort keys for constraints, operators, PUBLICATION
... FOR TABLE, PUBLICATION ... FOR TABLES IN SCHEMA, operator classes,
and operator families.  pg_dump's sort then depended on object OID,
yielding spurious schema diffs.  After this change, OIDs affect dump
order only in the event of catalog corruption.  While pg_dump also
wrongly ignored pg_collation.collencoding, CREATE COLLATION restrictions
have been keeping that imperceptible in practical use.

Use techniques like we use for object types already having full sort key
coverage.  Where the pertinent queries weren't fetching the ignored sort
keys, this adds columns to those queries and stores those keys in memory
for the long term.

The ignorance of sort keys became more problematic when commit
172259afb563d35001410dc6daad78b250924038 added a schema diff test
sensitive to it.  Buildfarm member hippopotamus witnessed that.
However, dump order stability isn't a new goal, and this might avoid
other dump comparison failures.  Hence, back-patch to v13 (all supported
versions).

Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Discussion: https://postgr.es/m/20250707192654.9e.nmisch@google.com
Backpatch-through: 13
src/bin/pg_dump/common.c
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.h
src/bin/pg_dump/pg_dump_sort.c
src/test/regress/expected/publication.out
src/test/regress/sql/publication.sql