Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2c7b5da

Browse filesBrowse files
committed
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
1 parent 29aeda6 commit 2c7b5da
Copy full SHA for 2c7b5da

File tree

Expand file treeCollapse file tree

1 file changed

+22
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+22
-0
lines changed

‎src/backend/catalog/dependency.c

Copy file name to clipboardExpand all lines: src/backend/catalog/dependency.c
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,6 +2256,28 @@ find_expr_references_walker(Node *node,
22562256
context->addrs);
22572257
}
22582258
}
2259+
else if (IsA(node, TableFunc))
2260+
{
2261+
TableFunc *tf = (TableFunc *) node;
2262+
ListCell *ct;
2263+
2264+
/*
2265+
* Add refs for the datatypes and collations used in the TableFunc.
2266+
*/
2267+
foreach(ct, tf->coltypes)
2268+
{
2269+
add_object_address(OCLASS_TYPE, lfirst_oid(ct), 0,
2270+
context->addrs);
2271+
}
2272+
foreach(ct, tf->colcollations)
2273+
{
2274+
Oid collid = lfirst_oid(ct);
2275+
2276+
if (OidIsValid(collid) && collid != DEFAULT_COLLATION_OID)
2277+
add_object_address(OCLASS_COLLATION, collid, 0,
2278+
context->addrs);
2279+
}
2280+
}
22592281
else if (IsA(node, TableSampleClause))
22602282
{
22612283
TableSampleClause *tsc = (TableSampleClause *) node;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.