summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorTom Lane2023-11-13 22:04:10 +0000
committerTom Lane2023-11-13 22:04:10 +0000
commit9e08789d4832b5d1f16d7f54e8d9b9b4ad7bd32b (patch)
tree1d6d33c5cb5723a05310c761f5c74702abeaa4ed /src/bin
parent66d9a4a207cf36ab0f53d2bfb6f5131716244134 (diff)
Don't try to dump RLS policies or security labels for extension objects.
checkExtensionMembership() set the DUMP_COMPONENT_SECLABEL and DUMP_COMPONENT_POLICY flags for extension member objects, even though we lack any infrastructure for tracking extensions' initial settings of these properties. This is not OK. The result was that a dump would always include commands to set these properties for extension objects that have them, with at least three negative consequences: 1. The restoring user might not have privilege to set these properties on these objects. 2. The properties might be incorrect/irrelevant for the version of the extension that's installed in the destination database. 3. The dump itself might fail, in the case of RLS properties attached to extension tables that the dumping user lacks privilege to LOCK. (That's because we must get at least AccessShareLock to ensure that we don't fail while trying to decompile the RLS expressions.) When and if somebody cares to invent initial-state infrastructure for extensions' RLS policies and security labels, we could think about finding another way around problem #3. But in the absence of such infrastructure, this whole thing is just wrong and we shouldn't do it. (Note: this applies only to ordinary dumps; binary-upgrade dumps still dump and restore extension member objects separately, with all properties.) Tom Lane and Jacob Champion. Back-patch to all supported branches. Discussion: https://postgr.es/m/00d46a48-3324-d9a0-49bf-e7f0f11d1038@timescale.com
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/pg_dump/pg_dump.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 7ac6a75b780..c73a6df78cc 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -1486,13 +1486,10 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
addObjectDependency(dobj, ext->dobj.dumpId);
/*
- * In 9.6 and above, mark the member object to have any non-initial ACL,
- * policies, and security labels dumped.
- *
- * Note that any initial ACLs (see pg_init_privs) will be removed when we
- * extract the information about the object. We don't provide support for
- * initial policies and security labels and it seems unlikely for those to
- * ever exist, but we may have to revisit this later.
+ * In 9.6 and above, mark the member object to have any non-initial ACLs
+ * dumped. (Any initial ACLs will be removed later, using data from
+ * pg_init_privs, so that we'll dump only the delta from the extension's
+ * initial setup.)
*
* Prior to 9.6, we do not include any extension member components.
*
@@ -1500,6 +1497,13 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
* individually, since the idea is to exactly reproduce the database
* contents rather than replace the extension contents with something
* different.
+ *
+ * Note: it might be interesting someday to implement storage and delta
+ * dumping of extension members' RLS policies and/or security labels.
+ * However there is a pitfall for RLS policies: trying to dump them
+ * requires getting a lock on their tables, and the calling user might not
+ * have privileges for that. We need no lock to examine a table's ACLs,
+ * so the current feature doesn't have a problem of that sort.
*/
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
@@ -1508,9 +1512,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->remoteVersion < 90600)
dobj->dump = DUMP_COMPONENT_NONE;
else
- dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL |
- DUMP_COMPONENT_SECLABEL |
- DUMP_COMPONENT_POLICY);
+ dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
}
return true;