Skip to content

Commit 471a7af

Browse files
committed
Ensure consistent sort order of large objects in pg_dump.
The primary purpose of this commit is to ensure pg_upgrade tests yield comparable dumps pre/post upgrade, which got broken by 12a53c7 / 578b229, as the order in pg_largeobject_metadata is likely to differ pre/post upgrade. It also seems like a generally good idea to make sure such dumps are comparable, outside of pg_upgrade tests. LO metadata already was already dumped in an ordered manner as the metadata is dumped in a well defined order via sortDumpableObjectsByTypeName() and sortDumpableObjects(). But large object data is currently not tracked via that mechanism. As Tom points out it seems possible that at some point dumpBlobs() was assumed to dump out objects in a well defined order, due to the use of DISTINCT, which at that time only was done using sorting. Per complaint from Andrew Dunstan and discussion with him and Tom Lane. Author: Andres Freund Discussion: https://postgr.es/m/2735.1543333649@sss.pgh.pa.us
1 parent b238527 commit 471a7af

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3328,9 +3328,13 @@ dumpBlobs(Archive *fout, void *arg)
33283328
* the already-in-memory dumpable objects instead...
33293329
*/
33303330
if (fout->remoteVersion >= 90000)
3331-
blobQry = "DECLARE bloboid CURSOR FOR SELECT oid FROM pg_largeobject_metadata";
3331+
blobQry =
3332+
"DECLARE bloboid CURSOR FOR "
3333+
"SELECT oid FROM pg_largeobject_metadata ORDER BY 1";
33323334
else
3333-
blobQry = "DECLARE bloboid CURSOR FOR SELECT DISTINCT loid FROM pg_largeobject";
3335+
blobQry =
3336+
"DECLARE bloboid CURSOR FOR "
3337+
"SELECT DISTINCT loid FROM pg_largeobject ORDER BY 1";
33343338

33353339
ExecuteSqlStatement(fout, blobQry);
33363340

0 commit comments

Comments
 (0)