aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-11-13 12:11:49 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2019-11-13 12:11:49 -0500
commit94a9cb43ff5a84b25a3e7d5226c8e02d55fe69c3 (patch)
treef3f8d24f3aa432b60b260af996bff2b31ef15748 /src
parent8e4ef328738f7c865736ef36346461e687c9e45c (diff)
downloadpostgresql-94a9cb43ff5a84b25a3e7d5226c8e02d55fe69c3.tar.gz
postgresql-94a9cb43ff5a84b25a3e7d5226c8e02d55fe69c3.zip
Include TableFunc references when computing expression dependencies.
The TableFunc node (i.e., XMLTABLE) includes type and collation OIDs that might not be referenced anywhere else in the expression tree, so they need to be accounted for when extracting dependencies. Fortunately, the practical effects of this are limited, since (a) it's somewhat unlikely that people would be extracting columns of non-builtin types from an XML document, and (b) in many scenarios, the query would contain other references to such types, or functions depending on them. However, it's not hard to construct examples wherein the existing code lets one drop a type used in XMLTABLE and thereby break a view. This is evidently an original oversight in the XMLTABLE patch, so back-patch to v10 where that came in. Discussion: https://postgr.es/m/18427.1573508501@sss.pgh.pa.us
Diffstat (limited to 'src')
-rw-r--r--src/backend/catalog/dependency.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index 6a03e9c4d3d..7b00d7c7bab 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -2055,6 +2055,28 @@ find_expr_references_walker(Node *node,
context->addrs);
}
}
+ else if (IsA(node, TableFunc))
+ {
+ TableFunc *tf = (TableFunc *) node;
+ ListCell *ct;
+
+ /*
+ * Add refs for the datatypes and collations used in the TableFunc.
+ */
+ foreach(ct, tf->coltypes)
+ {
+ add_object_address(OCLASS_TYPE, lfirst_oid(ct), 0,
+ context->addrs);
+ }
+ foreach(ct, tf->colcollations)
+ {
+ Oid collid = lfirst_oid(ct);
+
+ if (OidIsValid(collid) && collid != DEFAULT_COLLATION_OID)
+ add_object_address(OCLASS_COLLATION, collid, 0,
+ context->addrs);
+ }
+ }
else if (IsA(node, TableSampleClause))
{
TableSampleClause *tsc = (TableSampleClause *) node;