Sort DO_DEFAULT_ACL dump objects independent of OIDs. master github/master
authorNoah Misch <[email protected]>
Sat, 23 Aug 2025 03:50:28 +0000 (20:50 -0700)
committerNoah Misch <[email protected]>
Sat, 23 Aug 2025 03:50:28 +0000 (20:50 -0700)
Commit 0decd5e89db9f5edb9b27351082f0d74aae7a9b6 missed DO_DEFAULT_ACL,
leading to assertion failures, potential dump order instability, and
spurious schema diffs.  Back-patch to v13, like that commit.

Reported-by: Alexander Lakhin <[email protected]>
Author: Kirill Reshke <[email protected]>
Discussion: https://postgr.es/m/d32aaa8d-df7c-4f94-bcb3-4c85f02bea21@gmail.com
Backpatch-through: 13

src/bin/pg_dump/pg_dump_sort.c
src/test/regress/expected/privileges.out
src/test/regress/sql/privileges.sql

index a02da3e9652c145a7cb80072f735fe46e011e65e..2d02456664b5940357fb54055ff6900d25e0b393 100644 (file)
@@ -418,6 +418,19 @@ DOTypeNameCompare(const void *p1, const void *p2)
                return cmpval;
        }
    }
                return cmpval;
        }
    }
+   else if (obj1->objType == DO_DEFAULT_ACL)
+   {
+       DefaultACLInfo *daclobj1 = *(DefaultACLInfo *const *) p1;
+       DefaultACLInfo *daclobj2 = *(DefaultACLInfo *const *) p2;
+
+       /*
+        * Sort by defaclrole, per pg_default_acl_role_nsp_obj_index.  The
+        * (namespace, name) match (defaclnamespace, defaclobjtype).
+        */
+       cmpval = strcmp(daclobj1->defaclrole, daclobj2->defaclrole);
+       if (cmpval != 0)
+           return cmpval;
+   }
    else if (obj1->objType == DO_PUBLICATION_REL)
    {
        PublicationRelInfo *probj1 = *(PublicationRelInfo *const *) p1;
    else if (obj1->objType == DO_PUBLICATION_REL)
    {
        PublicationRelInfo *probj1 = *(PublicationRelInfo *const *) p1;
index 845e477da044dcf26134e6aed61624a4fd2645ed..8149666725b43b19b07d16c5c12c205ca4e628d9 100644 (file)
@@ -3153,6 +3153,11 @@ DROP USER regress_priv_user6;
 DROP USER regress_priv_user7;
 DROP USER regress_priv_user8; -- does not exist
 ERROR:  role "regress_priv_user8" does not exist
 DROP USER regress_priv_user7;
 DROP USER regress_priv_user8; -- does not exist
 ERROR:  role "regress_priv_user8" does not exist
+-- leave some default ACLs for pg_upgrade's dump-restore test input.
+ALTER DEFAULT PRIVILEGES FOR ROLE pg_signal_backend
+   REVOKE INSERT ON TABLES FROM pg_signal_backend;
+ALTER DEFAULT PRIVILEGES FOR ROLE pg_read_all_settings
+   REVOKE INSERT ON TABLES FROM pg_read_all_settings;
 -- permissions with LOCK TABLE
 CREATE USER regress_locktable_user;
 CREATE TABLE lock_table (a int);
 -- permissions with LOCK TABLE
 CREATE USER regress_locktable_user;
 CREATE TABLE lock_table (a int);
index 661cf186cfd5946d794481dfb2c231626623c12b..7b1e9393577ec83d6fd818a0c5dee4c5816b65bc 100644 (file)
@@ -1863,6 +1863,13 @@ DROP USER regress_priv_user7;
 DROP USER regress_priv_user8; -- does not exist
 
 
 DROP USER regress_priv_user8; -- does not exist
 
 
+-- leave some default ACLs for pg_upgrade's dump-restore test input.
+ALTER DEFAULT PRIVILEGES FOR ROLE pg_signal_backend
+   REVOKE INSERT ON TABLES FROM pg_signal_backend;
+ALTER DEFAULT PRIVILEGES FOR ROLE pg_read_all_settings
+   REVOKE INSERT ON TABLES FROM pg_read_all_settings;
+
+
 -- permissions with LOCK TABLE
 CREATE USER regress_locktable_user;
 CREATE TABLE lock_table (a int);
 -- permissions with LOCK TABLE
 CREATE USER regress_locktable_user;
 CREATE TABLE lock_table (a int);