Skip to content

Commit b61a5c4

Browse files
committed
Sort DO_DEFAULT_ACL dump objects independent of OIDs.
Commit 0decd5e 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 <exclusion@gmail.com> Author: Kirill Reshke <reshkekirill@gmail.com> Discussion: https://postgr.es/m/d32aaa8d-df7c-4f94-bcb3-4c85f02bea21@gmail.com Backpatch-through: 13
1 parent c13070a commit b61a5c4

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

src/bin/pg_dump/pg_dump_sort.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,19 @@ DOTypeNameCompare(const void *p1, const void *p2)
418418
return cmpval;
419419
}
420420
}
421+
else if (obj1->objType == DO_DEFAULT_ACL)
422+
{
423+
DefaultACLInfo *daclobj1 = *(DefaultACLInfo *const *) p1;
424+
DefaultACLInfo *daclobj2 = *(DefaultACLInfo *const *) p2;
425+
426+
/*
427+
* Sort by defaclrole, per pg_default_acl_role_nsp_obj_index. The
428+
* (namespace, name) match (defaclnamespace, defaclobjtype).
429+
*/
430+
cmpval = strcmp(daclobj1->defaclrole, daclobj2->defaclrole);
431+
if (cmpval != 0)
432+
return cmpval;
433+
}
421434
else if (obj1->objType == DO_PUBLICATION_REL)
422435
{
423436
PublicationRelInfo *probj1 = *(PublicationRelInfo *const *) p1;

src/test/regress/expected/privileges.out

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3153,6 +3153,11 @@ DROP USER regress_priv_user6;
31533153
DROP USER regress_priv_user7;
31543154
DROP USER regress_priv_user8; -- does not exist
31553155
ERROR: role "regress_priv_user8" does not exist
3156+
-- leave some default ACLs for pg_upgrade's dump-restore test input.
3157+
ALTER DEFAULT PRIVILEGES FOR ROLE pg_signal_backend
3158+
REVOKE INSERT ON TABLES FROM pg_signal_backend;
3159+
ALTER DEFAULT PRIVILEGES FOR ROLE pg_read_all_settings
3160+
REVOKE INSERT ON TABLES FROM pg_read_all_settings;
31563161
-- permissions with LOCK TABLE
31573162
CREATE USER regress_locktable_user;
31583163
CREATE TABLE lock_table (a int);

src/test/regress/sql/privileges.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,6 +1863,13 @@ DROP USER regress_priv_user7;
18631863
DROP USER regress_priv_user8; -- does not exist
18641864

18651865

1866+
-- leave some default ACLs for pg_upgrade's dump-restore test input.
1867+
ALTER DEFAULT PRIVILEGES FOR ROLE pg_signal_backend
1868+
REVOKE INSERT ON TABLES FROM pg_signal_backend;
1869+
ALTER DEFAULT PRIVILEGES FOR ROLE pg_read_all_settings
1870+
REVOKE INSERT ON TABLES FROM pg_read_all_settings;
1871+
1872+
18661873
-- permissions with LOCK TABLE
18671874
CREATE USER regress_locktable_user;
18681875
CREATE TABLE lock_table (a int);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy