diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 6ec524f8e6..1280b2f4db 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -9861,10 +9861,22 @@ getDefaultACLs(Archive *fout, int *numDefaultACLs) PQExpBuffer initacl_subquery = createPQExpBuffer(); PQExpBuffer initracl_subquery = createPQExpBuffer(); + /* + * Since the default for a global entry is the hard-wired default + * ACL for the particular object type, we pass defaclobjtype except + * for the case of 'S' (DEFACLOBJ_SEQUENCE) where we need to + * transform it to 's' since acldefault() SQL-callable function + * handles 's' as a sequence. On the other hand, since the default + * for non-global entries is an empty ACL we pass NULL. This works + * because acldefault() is STRICT. + */ buildACLQueries(acl_subquery, racl_subquery, initacl_subquery, initracl_subquery, "defaclacl", "defaclrole", "pip.initprivs", - "CASE WHEN defaclobjtype = 'S' THEN 's' ELSE defaclobjtype END::\"char\"", + "CASE WHEN defaclnamespace = 0 THEN " + " CASE WHEN defaclobjtype = 'S' THEN 's' " + " ELSE defaclobjtype END::\"char\" " + "ELSE NULL END", dopt->binary_upgrade); appendPQExpBuffer(query, "SELECT d.oid, d.tableoid, " diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index c61d95e817..31cf14a592 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -443,6 +443,24 @@ my %tests = ( }, }, + 'ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role GRANT EXECUTE ON FUNCTIONS' => { + create_order => 15, + create_sql => 'ALTER DEFAULT PRIVILEGES + FOR ROLE regress_dump_test_role IN SCHEMA dump_test + GRANT EXECUTE ON FUNCTIONS TO regress_dump_test_role;', + regexp => qr/^ + \QALTER DEFAULT PRIVILEGES \E + \QFOR ROLE regress_dump_test_role IN SCHEMA dump_test \E + \QGRANT ALL ON FUNCTIONS TO regress_dump_test_role;\E + /xm, + like => + { %full_runs, %dump_test_schema_runs, section_post_data => 1, }, + unlike => { + exclude_dump_test_schema => 1, + no_privs => 1, + }, + }, + 'ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role REVOKE' => { create_order => 55, create_sql => 'ALTER DEFAULT PRIVILEGES