Skip to content

Commit fbf967e

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 ec47100 commit fbf967e

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
@@ -414,6 +414,19 @@ DOTypeNameCompare(const void *p1, const void *p2)
414414
return cmpval;
415415
}
416416
}
417+
else if (obj1->objType == DO_DEFAULT_ACL)
418+
{
419+
DefaultACLInfo *daclobj1 = *(DefaultACLInfo *const *) p1;
420+
DefaultACLInfo *daclobj2 = *(DefaultACLInfo *const *) p2;
421+
422+
/*
423+
* Sort by defaclrole, per pg_default_acl_role_nsp_obj_index. The
424+
* (namespace, name) match (defaclnamespace, defaclobjtype).
425+
*/
426+
cmpval = strcmp(daclobj1->defaclrole, daclobj2->defaclrole);
427+
if (cmpval != 0)
428+
return cmpval;
429+
}
417430
else if (obj1->objType == DO_PUBLICATION_REL)
418431
{
419432
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
@@ -2634,6 +2634,11 @@ DROP USER regress_priv_user6;
26342634
DROP USER regress_priv_user7;
26352635
DROP USER regress_priv_user8; -- does not exist
26362636
ERROR: role "regress_priv_user8" does not exist
2637+
-- leave some default ACLs for pg_upgrade's dump-restore test input.
2638+
ALTER DEFAULT PRIVILEGES FOR ROLE pg_signal_backend
2639+
REVOKE INSERT ON TABLES FROM pg_signal_backend;
2640+
ALTER DEFAULT PRIVILEGES FOR ROLE pg_read_all_settings
2641+
REVOKE INSERT ON TABLES FROM pg_read_all_settings;
26372642
-- permissions with LOCK TABLE
26382643
CREATE USER regress_locktable_user;
26392644
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
@@ -1661,6 +1661,13 @@ DROP USER regress_priv_user7;
16611661
DROP USER regress_priv_user8; -- does not exist
16621662

16631663

1664+
-- leave some default ACLs for pg_upgrade's dump-restore test input.
1665+
ALTER DEFAULT PRIVILEGES FOR ROLE pg_signal_backend
1666+
REVOKE INSERT ON TABLES FROM pg_signal_backend;
1667+
ALTER DEFAULT PRIVILEGES FOR ROLE pg_read_all_settings
1668+
REVOKE INSERT ON TABLES FROM pg_read_all_settings;
1669+
1670+
16641671
-- permissions with LOCK TABLE
16651672
CREATE USER regress_locktable_user;
16661673
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