diff options
author | Stephen Frost | 2016-04-07 01:45:32 +0000 |
---|---|---|
committer | Stephen Frost | 2016-04-07 01:45:32 +0000 |
commit | 23f34fa4ba358671adab16773e79c17c92cbc870 (patch) | |
tree | f1f1cef2eb727f70ba5a48bc0d89b54b5d7c3019 /src/backend | |
parent | d217b2c360cb9a746b4ef122c568bdfedb6d726e (diff) |
In pg_dump, include pg_catalog and extension ACLs, if changed
Now that all of the infrastructure exists, add in the ability to
dump out the ACLs of the objects inside of pg_catalog or the ACLs
for objects which are members of extensions, but only if they have
been changed from their original values.
The original values are tracked in pg_init_privs. When pg_dump'ing
9.6-and-above databases, we will dump out the ACLs for all objects
in pg_catalog and the ACLs for all extension members, where the ACL
has been changed from the original value which was set during either
initdb or CREATE EXTENSION.
This should not change dumps against pre-9.6 databases.
Reviews by Alexander Korotkov, Jose Luis Tallon
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/catalog/aclchk.c | 17 | ||||
-rw-r--r-- | src/backend/utils/adt/pg_upgrade_support.c | 12 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c index ffb6678c6a4..975fe13fcf9 100644 --- a/src/backend/catalog/aclchk.c +++ b/src/backend/catalog/aclchk.c @@ -22,6 +22,7 @@ #include "access/htup_details.h" #include "access/sysattr.h" #include "access/xact.h" +#include "catalog/binary_upgrade.h" #include "catalog/catalog.h" #include "catalog/dependency.h" #include "catalog/indexing.h" @@ -85,6 +86,12 @@ typedef struct DropBehavior behavior; } InternalDefaultACL; +/* + * When performing a binary-upgrade, pg_dump will call a function to set + * this variable to let us know that we need to populate the pg_init_privs + * table for the GRANT/REVOKE commands while this variable is set to true. + */ +bool binary_upgrade_record_init_privs = false; static void ExecGrantStmt_oids(InternalGrant *istmt); static void ExecGrant_Relation(InternalGrant *grantStmt); @@ -5237,7 +5244,15 @@ recordExtensionInitPriv(Oid objoid, Oid classoid, int objsubid, Acl *new_acl) HeapTuple tuple; HeapTuple oldtuple; - if (!creating_extension) + /* + * Generally, we only record the initial privileges when an extension is + * being created, but because we don't actually use CREATE EXTENSION + * during binary upgrades with pg_upgrade, there is a variable to let us + * know that the GRANT and REVOKE statements being issued, while this + * variable is true, are for the initial privileges of the extension + * object and therefore we need to record them. + */ + if (!creating_extension && !binary_upgrade_record_init_privs) return; relation = heap_open(InitPrivsRelationId, RowExclusiveLock); diff --git a/src/backend/utils/adt/pg_upgrade_support.c b/src/backend/utils/adt/pg_upgrade_support.c index 912eadaf369..6ff035ace30 100644 --- a/src/backend/utils/adt/pg_upgrade_support.c +++ b/src/backend/utils/adt/pg_upgrade_support.c @@ -29,6 +29,7 @@ Datum binary_upgrade_set_next_toast_pg_class_oid(PG_FUNCTION_ARGS); Datum binary_upgrade_set_next_pg_enum_oid(PG_FUNCTION_ARGS); Datum binary_upgrade_set_next_pg_authid_oid(PG_FUNCTION_ARGS); Datum binary_upgrade_create_empty_extension(PG_FUNCTION_ARGS); +Datum binary_upgrade_set_record_init_privs(PG_FUNCTION_ARGS); #define CHECK_IS_BINARY_UPGRADE \ @@ -193,3 +194,14 @@ binary_upgrade_create_empty_extension(PG_FUNCTION_ARGS) PG_RETURN_VOID(); } + +Datum +binary_upgrade_set_record_init_privs(PG_FUNCTION_ARGS) +{ + bool record_init_privs = PG_GETARG_BOOL(0); + + CHECK_IS_BINARY_UPGRADE; + binary_upgrade_record_init_privs = record_init_privs; + + PG_RETURN_VOID(); +} |