pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Noah Misch <noah@leadboat.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Sort dump objects independent of OIDs, for the 7 holdout object
Date: Thu, 31 Jul 2025 13:43:10 +0000
Message-ID: <E1uhTYr-0001al-2O@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0decd5e89db9f5edb9b27351082f0d74aae7a9b6

Modified Files
--------------
src/bin/pg_dump/common.c                  |  19 +++
src/bin/pg_dump/pg_dump.c                 |  59 ++++++--
src/bin/pg_dump/pg_dump.h                 |   6 +
src/bin/pg_dump/pg_dump_sort.c            | 238 +++++++++++++++++++++++++++---
src/test/regress/expected/publication.out |  21 +++
src/test/regress/sql/publication.sql      |  22 +++
6 files changed, 335 insertions(+), 30 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1uhTYr-0001al-2O@gemulon.postgresql.org>
Permalink:  ../E1uhTYr-0001al-2O@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1uhTYr-0001al-2O@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: noah@leadboat.com, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Sort dump objects independent of OIDs, for the 7 holdout object
  In-Reply-To: <E1uhTYr-0001al-2O@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox