From b4fc645787cc7c614c0c97fc9fffacf2bdc6a388 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Wed, 12 Oct 2016 18:29:57 -0700 Subject: [PATCH] Make pg_dumpall's database ACL query independent of hash table order. Previously GRANT order on databases was not well defined, due to the use of EXCEPT without an ORDER BY. Add an ORDER BY, adapt test output. I don't, at the moment, see reason to backpatch this. --- src/bin/pg_dump/pg_dumpall.c | 10 ++++++---- src/bin/pg_dump/t/002_pg_dump.pl | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index 82157e5620..45749f3e64 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -1307,11 +1307,13 @@ dumpCreateDB(PGconn *conn) "pg_encoding_to_char(d.encoding), " "datcollate, datctype, datfrozenxid, datminmxid, " "datistemplate, " - "(SELECT pg_catalog.array_agg(acl) FROM (SELECT pg_catalog.unnest(coalesce(datacl,pg_catalog.acldefault('d',datdba))) AS acl " - "EXCEPT SELECT pg_catalog.unnest(pg_catalog.acldefault('d',datdba))) as foo)" + "(SELECT pg_catalog.array_agg(acl ORDER BY acl::text) FROM ( " + " SELECT pg_catalog.unnest(coalesce(datacl,pg_catalog.acldefault('d',datdba))) AS acl " + " EXCEPT SELECT pg_catalog.unnest(pg_catalog.acldefault('d',datdba))) as datacls)" "AS datacl, " - "(SELECT pg_catalog.array_agg(acl) FROM (SELECT pg_catalog.unnest(pg_catalog.acldefault('d',datdba)) AS acl " - "EXCEPT SELECT pg_catalog.unnest(coalesce(datacl,pg_catalog.acldefault('d',datdba)))) as foo)" + "(SELECT pg_catalog.array_agg(acl ORDER BY acl::text) FROM ( " + " SELECT pg_catalog.unnest(pg_catalog.acldefault('d',datdba)) AS acl " + " EXCEPT SELECT pg_catalog.unnest(coalesce(datacl,pg_catalog.acldefault('d',datdba)))) as rdatacls)" "AS rdatacl, " "datconnlimit, " "(SELECT spcname FROM pg_tablespace t WHERE t.oid = d.dattablespace) AS dattablespace " diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index 37cbdcdaa5..1d3af87334 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -2484,6 +2484,7 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m, create_sql => 'REVOKE CONNECT ON DATABASE dump_test FROM public;', regexp => qr/^ \QREVOKE CONNECT,TEMPORARY ON DATABASE dump_test FROM PUBLIC;\E\n + \QGRANT CREATE ON DATABASE dump_test TO regress_dump_test_role;\E\n \QGRANT TEMPORARY ON DATABASE dump_test TO PUBLIC;\E /xm, like => { pg_dumpall_dbprivs => 1, }, -- 2.40.0