pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephen Frost <sfrost@snowman.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Moshe Jacobson <moshe@neadwerx.com>
Cc: daniele.varrazzo@gmail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
Date: Fri, 20 Jan 2017 17:10:40 -0500
Message-ID: <20170120221039.GZ18360@tamriel.snowman.net> (raw)
In-Reply-To: <13549.1484248592@sss.pgh.pa.us>
References: <20161208191642.1407.30751@wrigleys.postgresql.org>
	<20161208192933.GG23417@tamriel.snowman.net>
	<CAJ4CxLmGST-UkYzhrS-QbXLoXeYnZPPO7m7b9U=2RRr-cTArHQ@mail.gmail.com>
	<20170112183457.GJ18360@tamriel.snowman.net>
	<CAJ4CxLk8iAsLVgmv2NAWNoKD3cA+pqJ0UmB9=135DsJzcfEXOg@mail.gmail.com>
	<12559.1484247701@sss.pgh.pa.us>
	<20170112190830.GP18360@tamriel.snowman.net>
	<13549.1484248592@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Tom, Moshe,

* Tom Lane (tgl@sss.pgh.pa.us) wrote:
> Stephen Frost <sfrost@snowman.net> writes:
> > * Tom Lane (tgl@sss.pgh.pa.us) wrote:
> >> Hmm.  There's an argument to be made that ALTER EXTENSION ADD should
> >> absorb whatever the object's current ACLs are into the pg_init_privs
> >> entries for the extension.  (I don't think it does that now, though
> >> I might be wrong.)  However ...
> 
> > I've not gone and looked yet, but I doubt that it does.  I think I can
> > agree with the argument that it really should add those ACLs to
> > pg_init_privs.  Of course, any furhter manipulation of the ACLs from
> > that point will cause those ACLs to be included in the pg_dump.
> 
> > I'll take a look at ALTER EXTENSION ADD and pg_init_privs.
> 
> By the same token, does ALTER EXTENSION DROP remove those entries?

Please find attached a WIP patch to have ALTER EXTENSION ADD/DROP update
pg_init_privs accordingly.

It's a bit big as it needs to have independent code for every different
kind of object that ALTER EXTENSION ADD/DROP supports.  Most of that
code is pretty boiler-plate, of course.

I'm planning to review it further, add more regression tests, and then
back-patch it to 9.6.

Moshe, if you're feeling adventurous and want to give it a spin and make
sure it behaves as you're expecting, that'd be great.

Tom, your thoughts and comments are always welcome, if you'd like to
peruse the patch, of course.

Otherwise, I expect to have time to wrap this all up over the weekend.

Thanks!

Stephen

Attachments:

alter_ext_adddrop_init_privs_v1_master.patch (text/x-diff, 22.7K) download diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c new file mode 100644 index 7803d0d..73471c6 *** a/src/backend/catalog/aclchk.c --- b/src/backend/catalog/aclchk.c *************** *** 27,33 **** --- 27,36 ---- #include "catalog/dependency.h" #include "catalog/indexing.h" #include "catalog/objectaccess.h" + #include "catalog/pg_aggregate.h" + #include "catalog/pg_am.h" #include "catalog/pg_authid.h" + #include "catalog/pg_cast.h" #include "catalog/pg_collation.h" #include "catalog/pg_conversion.h" #include "catalog/pg_database.h" *************** *** 49,54 **** --- 52,60 ---- #include "catalog/pg_type.h" #include "catalog/pg_ts_config.h" #include "catalog/pg_ts_dict.h" + #include "catalog/pg_ts_parser.h" + #include "catalog/pg_ts_template.h" + #include "catalog/pg_transform.h" #include "commands/dbcommands.h" #include "commands/event_trigger.h" #include "commands/extension.h" *************** static AclMode pg_aclmask(AclObjectKind *** 130,135 **** --- 136,143 ---- Oid roleid, AclMode mask, AclMaskHow how); static void recordExtensionInitPriv(Oid objoid, Oid classoid, int objsubid, Acl *new_acl); + static void recordExtensionInitPrivWorker(Oid objoid, Oid classoid, int objsubid, + Acl *new_acl); #ifdef ACLDEBUG *************** get_user_default_acl(GrantObjectType obj *** 5226,5235 **** } /* ! * Record initial ACL for an extension object * ! * This will perform a wholesale replacement of the entire ACL for the object ! * passed in, therefore be sure to pass in the complete new ACL to use. * * Can be called at any time, we check if 'creating_extension' is set and, if * not, exit immediately. --- 5234,5604 ---- } /* ! * Record initial privileges for the top-level object passed in. * ! * For the object passed in, this will record its ACL (if any) and the ACLs of ! * any sub-objects (eg: columns) into pg_init_privs. ! * ! * Any new kinds of objects which have ACLs associated with them and can be ! * added to an extension should be added to the if-else tree below. ! */ ! void ! recordExtObjInitPriv(Oid objoid, Oid classoid) ! { ! /* ! * pg_class / pg_attribute ! * ! * If this is a relation then we need to see if there are any sub-objects ! * (eg: columns) for it and, if so, be sure to call ! * recordExtensionInitPrivWorker() for each one. ! */ ! if (classoid == RelationRelationId) ! { ! Form_pg_class pg_class_tuple; ! Datum aclDatum; ! bool isNull; ! HeapTuple tuple; ! ! tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(objoid)); ! if (!HeapTupleIsValid(tuple)) ! elog(ERROR, "cache lookup failed for relation %u", objoid); ! pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple); ! ! /* Indexes don't have permissions */ ! if (pg_class_tuple->relkind == RELKIND_INDEX) ! return; ! ! /* Composite types don't have permissions either */ ! if (pg_class_tuple->relkind == RELKIND_COMPOSITE_TYPE) ! return; ! ! /* ! * If this isn't a sequence, index, or composite type then it's ! * possibly going to have columns associated with it that might have ! * ACLs. ! */ ! if (pg_class_tuple->relkind != RELKIND_SEQUENCE) ! { ! AttrNumber curr_att; ! AttrNumber nattrs = pg_class_tuple->relnatts; ! ! for (curr_att = 1; curr_att <= nattrs; curr_att++) ! { ! HeapTuple attTuple; ! Datum attaclDatum; ! ! attTuple = SearchSysCache2(ATTNUM, ! ObjectIdGetDatum(objoid), ! Int16GetDatum(curr_att)); ! ! if (!HeapTupleIsValid(attTuple)) ! continue; ! ! /* ignore dropped columns */ ! if (((Form_pg_attribute) GETSTRUCT(attTuple))->attisdropped) ! { ! ReleaseSysCache(attTuple); ! continue; ! } ! ! attaclDatum = SysCacheGetAttr(ATTNUM, attTuple, ! Anum_pg_attribute_attacl, ! &isNull); ! ! /* no need to do anything for a NULL ACL */ ! if (isNull) ! { ! ReleaseSysCache(attTuple); ! continue; ! } ! ! recordExtensionInitPrivWorker(objoid, classoid, curr_att, ! DatumGetAclP(attaclDatum)); ! ! ReleaseSysCache(attTuple); ! } ! } ! ! aclDatum = SysCacheGetAttr(RELOID, tuple, Anum_pg_class_relacl, ! &isNull); ! ! /* Add the record, if any, for the top-level object */ ! if (!isNull) ! recordExtensionInitPrivWorker(objoid, classoid, 0, ! DatumGetAclP(aclDatum)); ! ! ReleaseSysCache(tuple); ! } ! /* pg_foreign_data_wrapper */ ! else if (classoid == ForeignDataWrapperRelationId) ! { ! Datum aclDatum; ! bool isNull; ! HeapTuple tuple; ! ! tuple = SearchSysCache1(FOREIGNDATAWRAPPEROID, ! ObjectIdGetDatum(objoid)); ! if (!HeapTupleIsValid(tuple)) ! elog(ERROR, "cache lookup failed for foreign data wrapper %u", ! objoid); ! ! aclDatum = SysCacheGetAttr(FOREIGNDATAWRAPPEROID, tuple, ! Anum_pg_foreign_data_wrapper_fdwacl, ! &isNull); ! ! /* Add the record, if any, for the top-level object */ ! if (!isNull) ! recordExtensionInitPrivWorker(objoid, classoid, 0, ! DatumGetAclP(aclDatum)); ! ! ReleaseSysCache(tuple); ! } ! /* pg_foreign_server */ ! else if (classoid == ForeignServerRelationId) ! { ! Datum aclDatum; ! bool isNull; ! HeapTuple tuple; ! ! tuple = SearchSysCache1(FOREIGNSERVEROID, ObjectIdGetDatum(objoid)); ! if (!HeapTupleIsValid(tuple)) ! elog(ERROR, "cache lookup failed for foreign data wrapper %u", ! objoid); ! ! aclDatum = SysCacheGetAttr(FOREIGNSERVEROID, tuple, ! Anum_pg_foreign_server_srvacl, ! &isNull); ! ! /* Add the record, if any, for the top-level object */ ! if (!isNull) ! recordExtensionInitPrivWorker(objoid, classoid, 0, ! DatumGetAclP(aclDatum)); ! ! ReleaseSysCache(tuple); ! } ! /* pg_language */ ! else if (classoid == LanguageRelationId) ! { ! Datum aclDatum; ! bool isNull; ! HeapTuple tuple; ! ! tuple = SearchSysCache1(LANGOID, ObjectIdGetDatum(objoid)); ! if (!HeapTupleIsValid(tuple)) ! elog(ERROR, "cache lookup failed for language %u", objoid); ! ! aclDatum = SysCacheGetAttr(LANGOID, tuple, Anum_pg_language_lanacl, ! &isNull); ! ! /* Add the record, if any, for the top-level object */ ! if (!isNull) ! recordExtensionInitPrivWorker(objoid, classoid, 0, ! DatumGetAclP(aclDatum)); ! ! ReleaseSysCache(tuple); ! } ! /* pg_largeobject_metadata */ ! else if (classoid == LargeObjectMetadataRelationId) ! { ! Datum aclDatum; ! bool isNull; ! HeapTuple tuple; ! ScanKeyData entry[1]; ! SysScanDesc scan; ! Relation relation; ! ! relation = heap_open(LargeObjectMetadataRelationId, RowExclusiveLock); ! ! /* There's no syscache for pg_largeobject_metadata */ ! ScanKeyInit(&entry[0], ! ObjectIdAttributeNumber, ! BTEqualStrategyNumber, F_OIDEQ, ! ObjectIdGetDatum(objoid)); ! ! scan = systable_beginscan(relation, ! LargeObjectMetadataOidIndexId, true, ! NULL, 1, entry); ! ! tuple = systable_getnext(scan); ! if (!HeapTupleIsValid(tuple)) ! elog(ERROR, "cache lookup failed for large object %u", objoid); ! ! aclDatum = heap_getattr(tuple, ! Anum_pg_largeobject_metadata_lomacl, ! RelationGetDescr(relation), &isNull); ! ! /* Add the record, if any, for the top-level object */ ! if (!isNull) ! recordExtensionInitPrivWorker(objoid, classoid, 0, ! DatumGetAclP(aclDatum)); ! ! systable_endscan(scan); ! } ! /* pg_namespace */ ! else if (classoid == NamespaceRelationId) ! { ! Datum aclDatum; ! bool isNull; ! HeapTuple tuple; ! ! tuple = SearchSysCache1(NAMESPACEOID, ObjectIdGetDatum(objoid)); ! if (!HeapTupleIsValid(tuple)) ! elog(ERROR, "cache lookup failed for function %u", objoid); ! ! aclDatum = SysCacheGetAttr(NAMESPACEOID, tuple, ! Anum_pg_namespace_nspacl, &isNull); ! ! /* Add the record, if any, for the top-level object */ ! if (!isNull) ! recordExtensionInitPrivWorker(objoid, classoid, 0, ! DatumGetAclP(aclDatum)); ! ! ReleaseSysCache(tuple); ! } ! /* pg_proc */ ! else if (classoid == ProcedureRelationId) ! { ! Datum aclDatum; ! bool isNull; ! HeapTuple tuple; ! ! tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(objoid)); ! if (!HeapTupleIsValid(tuple)) ! elog(ERROR, "cache lookup failed for function %u", objoid); ! ! aclDatum = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_proacl, ! &isNull); ! ! /* Add the record, if any, for the top-level object */ ! if (!isNull) ! recordExtensionInitPrivWorker(objoid, classoid, 0, ! DatumGetAclP(aclDatum)); ! ! ReleaseSysCache(tuple); ! } ! /* pg_type */ ! else if (classoid == TypeRelationId) ! { ! Datum aclDatum; ! bool isNull; ! HeapTuple tuple; ! ! tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(objoid)); ! if (!HeapTupleIsValid(tuple)) ! elog(ERROR, "cache lookup failed for function %u", objoid); ! ! aclDatum = SysCacheGetAttr(TYPEOID, tuple, Anum_pg_type_typacl, ! &isNull); ! ! /* Add the record, if any, for the top-level object */ ! if (!isNull) ! recordExtensionInitPrivWorker(objoid, classoid, 0, ! DatumGetAclP(aclDatum)); ! ! ReleaseSysCache(tuple); ! } ! else if (classoid == AccessMethodRelationId || ! classoid == AggregateRelationId || ! classoid == CastRelationId || ! classoid == CollationRelationId || ! classoid == ConversionRelationId || ! classoid == EventTriggerRelationId || ! classoid == OperatorRelationId || ! classoid == OperatorClassRelationId || ! classoid == OperatorFamilyRelationId || ! classoid == NamespaceRelationId || ! classoid == TSConfigRelationId || ! classoid == TSDictionaryRelationId || ! classoid == TSParserRelationId || ! classoid == TSTemplateRelationId || ! classoid == TransformRelationId ! ) ! { ! /* no ACL for these object types, so do nothing. */ ! } ! /* ! * complain if we are given a class OID for a class that extensions don't ! * support or that we don't recognize. ! */ ! else ! { ! elog(ERROR, "unrecognized or unsupported class OID: %u", classoid); ! } ! } ! ! /* ! * For the object passed in, remove its ACL and the ACLs of any object subIds ! * from pg_init_privs (via recordExtensionInitPrivWorker()). ! */ ! void ! removeExtObjInitPriv(Oid objoid, Oid classoid) ! { ! /* ! * If this is a relation then we need to see if there are any sub-objects ! * (eg: columns) for it and, if so, be sure to call ! * recordExtensionInitPrivWorker() for each one. ! */ ! if (classoid == RelationRelationId) ! { ! Form_pg_class pg_class_tuple; ! HeapTuple tuple; ! ! tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(objoid)); ! if (!HeapTupleIsValid(tuple)) ! elog(ERROR, "cache lookup failed for relation %u", objoid); ! pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple); ! ! /* Indexes don't have permissions */ ! if (pg_class_tuple->relkind == RELKIND_INDEX) ! return; ! ! /* Composite types don't have permissions either */ ! if (pg_class_tuple->relkind == RELKIND_COMPOSITE_TYPE) ! return; ! ! /* ! * If this isn't a sequence, index, or composite type then it's ! * possibly going to have columns associated with it that might have ! * ACLs. ! */ ! if (pg_class_tuple->relkind != RELKIND_SEQUENCE) ! { ! AttrNumber curr_att; ! AttrNumber nattrs = pg_class_tuple->relnatts; ! ! for (curr_att = 1; curr_att <= nattrs; curr_att++) ! { ! HeapTuple attTuple; ! ! attTuple = SearchSysCache2(ATTNUM, ! ObjectIdGetDatum(objoid), ! Int16GetDatum(curr_att)); ! ! if (!HeapTupleIsValid(attTuple)) ! continue; ! ! /* ignore dropped columns */ ! if (((Form_pg_attribute) GETSTRUCT(attTuple))->attisdropped) ! { ! ReleaseSysCache(attTuple); ! continue; ! } ! ! recordExtensionInitPrivWorker(objoid, classoid, curr_att, NULL); ! ! ReleaseSysCache(attTuple); ! } ! } ! ! ReleaseSysCache(tuple); ! } ! ! /* Remove the record, if any, for the top-level object */ ! recordExtensionInitPrivWorker(objoid, classoid, 0, NULL); ! } ! ! /* ! * Record initial ACL for an extension object * * Can be called at any time, we check if 'creating_extension' is set and, if * not, exit immediately. *************** get_user_default_acl(GrantObjectType obj *** 5248,5259 **** static void recordExtensionInitPriv(Oid objoid, Oid classoid, int objsubid, Acl *new_acl) { - Relation relation; - ScanKeyData key[3]; - SysScanDesc scan; - HeapTuple tuple; - HeapTuple oldtuple; - /* * Generally, we only record the initial privileges when an extension is * being created, but because we don't actually use CREATE EXTENSION --- 5617,5622 ---- *************** recordExtensionInitPriv(Oid objoid, Oid *** 5265,5270 **** --- 5628,5657 ---- if (!creating_extension && !binary_upgrade_record_init_privs) return; + recordExtensionInitPrivWorker(objoid, classoid, objsubid, new_acl); + } + + /* + * Record initial ACL for an extension object, worker. + * + * This will perform a wholesale replacement of the entire ACL for the object + * passed in, therefore be sure to pass in the complete new ACL to use. + * + * Generally speaking, do *not* use this function directly but instead use + * recordExtensionInitPriv(), which checks if 'creating_extension' is set. + * This function does *not* check if 'creating_extension' is set as it is also + * used when an object is added to or removed from an extension via ALTER + * EXTENSION ... ADD/DROP. + */ + static void + recordExtensionInitPrivWorker(Oid objoid, Oid classoid, int objsubid, Acl *new_acl) + { + Relation relation; + ScanKeyData key[3]; + SysScanDesc scan; + HeapTuple tuple; + HeapTuple oldtuple; + relation = heap_open(InitPrivsRelationId, RowExclusiveLock); ScanKeyInit(&key[0], *************** recordExtensionInitPriv(Oid objoid, Oid *** 5317,5344 **** } else { - /* No entry found, so add it. */ Datum values[Natts_pg_init_privs]; bool nulls[Natts_pg_init_privs]; ! MemSet(nulls, false, sizeof(nulls)); ! values[Anum_pg_init_privs_objoid - 1] = ObjectIdGetDatum(objoid); ! values[Anum_pg_init_privs_classoid - 1] = ObjectIdGetDatum(classoid); ! values[Anum_pg_init_privs_objsubid - 1] = Int32GetDatum(objsubid); ! /* This function only handles initial privileges of extensions */ ! values[Anum_pg_init_privs_privtype - 1] = ! CharGetDatum(INITPRIVS_EXTENSION); ! values[Anum_pg_init_privs_privs - 1] = PointerGetDatum(new_acl); ! tuple = heap_form_tuple(RelationGetDescr(relation), values, nulls); ! simple_heap_insert(relation, tuple); ! /* keep the catalog indexes up to date */ ! CatalogUpdateIndexes(relation, tuple); } systable_endscan(scan); --- 5704,5740 ---- } else { Datum values[Natts_pg_init_privs]; bool nulls[Natts_pg_init_privs]; ! /* ! * Only add a new entry if the new ACL is non-NULL. ! * ! * If we are passed in a NULL ACL and no entry exists, we can just fall ! * through and do nothing. ! */ ! if (new_acl) ! { ! /* No entry found, so add it. */ ! MemSet(nulls, false, sizeof(nulls)); ! values[Anum_pg_init_privs_objoid - 1] = ObjectIdGetDatum(objoid); ! values[Anum_pg_init_privs_classoid - 1] = ObjectIdGetDatum(classoid); ! values[Anum_pg_init_privs_objsubid - 1] = Int32GetDatum(objsubid); ! /* This function only handles initial privileges of extensions */ ! values[Anum_pg_init_privs_privtype - 1] = ! CharGetDatum(INITPRIVS_EXTENSION); ! values[Anum_pg_init_privs_privs - 1] = PointerGetDatum(new_acl); ! tuple = heap_form_tuple(RelationGetDescr(relation), values, nulls); ! simple_heap_insert(relation, tuple); ! /* keep the catalog indexes up to date */ ! CatalogUpdateIndexes(relation, tuple); ! } } systable_endscan(scan); diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c new file mode 100644 index be52148..e6108ff *** a/src/backend/commands/extension.c --- b/src/backend/commands/extension.c *************** *** 52,57 **** --- 52,58 ---- #include "nodes/makefuncs.h" #include "storage/fd.h" #include "tcop/utility.h" + #include "utils/acl.h" #include "utils/builtins.h" #include "utils/fmgroids.h" #include "utils/lsyscache.h" *************** ExecAlterExtensionContentsStmt(AlterExte *** 3239,3244 **** --- 3240,3255 ---- * OK, add the dependency. */ recordDependencyOn(&object, &extension, DEPENDENCY_EXTENSION); + + /* + * Also record the initial ACL on the object, if any. + * + * Note that this will handle the object's ACLs, as well as any ACLs + * on object subIds. (In other words, when the object is a table, + * this will record the table's ACL and the ACLs for the columns on + * the table, if any). + */ + recordExtObjInitPriv(object.objectId, object.classId); } else { *************** ExecAlterExtensionContentsStmt(AlterExte *** 3266,3271 **** --- 3277,3292 ---- */ if (object.classId == RelationRelationId) extension_config_remove(extension.objectId, object.objectId); + + /* + * Remove all the initial ACLs, if any. + * + * Note that this will remove the object's ACLs, as well as any ACLs + * on object subIds. (In other words, when the object is a table, + * this will remove the table's ACL and the ACLs for the columns on + * the table, if any). + */ + removeExtObjInitPriv(object.objectId, object.classId); } InvokeObjectPostAlterHook(ExtensionRelationId, extension.objectId, 0); diff --git a/src/include/utils/acl.h b/src/include/utils/acl.h new file mode 100644 index 433ba2d..6508cc1 *** a/src/include/utils/acl.h --- b/src/include/utils/acl.h *************** extern void aclcheck_error_col(AclResult *** 312,317 **** --- 312,321 ---- extern void aclcheck_error_type(AclResult aclerr, Oid typeOid); + extern void recordExtObjInitPriv(Oid objoid, Oid classoid); + extern void removeExtObjInitPriv(Oid objoid, Oid classoid); + + /* ownercheck routines just return true (owner) or false (not) */ extern bool pg_class_ownercheck(Oid class_oid, Oid roleid); extern bool pg_type_ownercheck(Oid type_oid, Oid roleid); diff --git a/src/test/modules/test_pg_dump/expected/test_pg_dump.out b/src/test/modules/test_pg_dump/expected/test_pg_dump.out new file mode 100644 index 360caa2..d37aea0 *** a/src/test/modules/test_pg_dump/expected/test_pg_dump.out --- b/src/test/modules/test_pg_dump/expected/test_pg_dump.out *************** *** 1,6 **** ! SELECT 1; ! ?column? ! ---------- ! 1 ! (1 row) ! --- 1,2 ---- ! CREATE ROLE regress_dump_test_role; ! CREATE EXTENSION test_pg_dump; diff --git a/src/test/modules/test_pg_dump/sql/test_pg_dump.sql b/src/test/modules/test_pg_dump/sql/test_pg_dump.sql new file mode 100644 index e0ac49d..d37aea0 *** a/src/test/modules/test_pg_dump/sql/test_pg_dump.sql --- b/src/test/modules/test_pg_dump/sql/test_pg_dump.sql *************** *** 1 **** ! SELECT 1; --- 1,2 ---- ! CREATE ROLE regress_dump_test_role; ! CREATE EXTENSION test_pg_dump; diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl new file mode 100644 index dc90a4a..643fc8d *** a/src/test/modules/test_pg_dump/t/001_base.pl --- b/src/test/modules/test_pg_dump/t/001_base.pl *************** my %pgdump_runs = ( *** 188,193 **** --- 188,213 ---- # as the regexps are used for each run the test applies to. my %tests = ( + 'ALTER EXTENSION test_pg_dump' => { + create_order => 9, + create_sql => 'ALTER EXTENSION test_pg_dump ADD TABLE regress_pg_dump_table_added;', + regexp => qr/^ + \QCREATE TABLE regress_pg_dump_table_added (\E + \n\s+\Qcol1 integer NOT NULL,\E + \n\s+\Qcol2 integer\E + \n\);\n/xm, + like => { binary_upgrade => 1, }, + unlike => { + clean => 1, + clean_if_exists => 1, + createdb => 1, + defaults => 1, + no_privs => 1, + no_owner => 1, + pg_dumpall_globals => 1, + schema_only => 1, + section_pre_data => 1, + section_post_data => 1, }, }, 'CREATE EXTENSION test_pg_dump' => { create_order => 2, create_sql => 'CREATE EXTENSION test_pg_dump;', *************** my %tests = ( *** 283,288 **** --- 303,328 ---- schema_only => 1, section_pre_data => 1, section_post_data => 1, }, }, + 'CREATE TABLE regress_pg_dump_table_added' => { + create_order => 7, + create_sql => 'CREATE TABLE regress_pg_dump_table_added (col1 int not null, col2 int);', + regexp => qr/^ + \QCREATE TABLE regress_pg_dump_table_added (\E + \n\s+\Qcol1 integer NOT NULL,\E + \n\s+\Qcol2 integer\E + \n\);\n/xm, + like => { binary_upgrade => 1, }, + unlike => { + clean => 1, + clean_if_exists => 1, + createdb => 1, + defaults => 1, + no_privs => 1, + no_owner => 1, + pg_dumpall_globals => 1, + schema_only => 1, + section_pre_data => 1, + section_post_data => 1, }, }, 'CREATE ACCESS METHOD regress_test_am' => { regexp => qr/^ \QCREATE ACCESS METHOD regress_test_am TYPE INDEX HANDLER bthandler;\E *************** my %tests = ( *** 373,378 **** --- 413,457 ---- no_privs => 1, pg_dumpall_globals => 1, section_post_data => 1, }, }, + 'GRANT SELECT regress_pg_dump_table_added pre-ALTER EXTENSION' => { + create_order => 8, + create_sql => 'GRANT SELECT ON regress_pg_dump_table_added TO regress_dump_test_role;', + regexp => qr/^ + \QGRANT SELECT ON TABLE regress_pg_dump_table_added TO regress_dump_test_role;\E + \n/xm, + like => { binary_upgrade => 1, }, + unlike => { + clean => 1, + clean_if_exists => 1, + createdb => 1, + defaults => 1, + no_privs => 1, + no_owner => 1, + pg_dumpall_globals => 1, + schema_only => 1, + section_pre_data => 1, + section_post_data => 1, }, }, + 'REVOKE SELECT regress_pg_dump_table_added post-ALTER EXTENSION' => { + create_order => 10, + create_sql => 'REVOKE SELECT ON regress_pg_dump_table_added FROM regress_dump_test_role;', + regexp => qr/^ + \QREVOKE SELECT ON TABLE regress_pg_dump_table_added FROM regress_dump_test_role;\E + \n/xm, + like => { + binary_upgrade => 1, + clean => 1, + clean_if_exists => 1, + createdb => 1, + defaults => 1, + no_owner => 1, + schema_only => 1, + section_pre_data => 1, + }, + unlike => { + no_privs => 1, + pg_dumpall_globals => 1, + section_post_data => 1, + }, }, 'GRANT USAGE ON regress_pg_dump_table_col1_seq TO regress_dump_test_role' => { create_order => 5,
signature.asc (application/pgp-signature, 818B) download

view thread (18+ messages)  latest in thread

Message-ID: <20170120221039.GZ18360@tamriel.snowman.net>
Permalink:  ../20170120221039.GZ18360@tamriel.snowman.net/
Also on:    postgresql.org/message-id/20170120221039.GZ18360@tamriel.snowman.net

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: sfrost@snowman.net, tgl@sss.pgh.pa.us, moshe@neadwerx.com, daniele.varrazzo@gmail.com
  Subject: Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
  In-Reply-To: <20170120221039.GZ18360@tamriel.snowman.net>
  References: <20161208191642.1407.30751@wrigleys.postgresql.org> <20161208192933.GG23417@tamriel.snowman.net> <CAJ4CxLmGST-UkYzhrS-QbXLoXeYnZPPO7m7b9U=2RRr-cTArHQ@mail.gmail.com> <20170112183457.GJ18360@tamriel.snowman.net> <CAJ4CxLk8iAsLVgmv2NAWNoKD3cA+pqJ0UmB9=135DsJzcfEXOg@mail.gmail.com> <12559.1484247701@sss.pgh.pa.us> <20170112190830.GP18360@tamriel.snowman.net> <13549.1484248592@sss.pgh.pa.us> <20170120221039.GZ18360@tamriel.snowman.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox