Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit900a9fd

Browse files
committed
Fix some oversights in expression dependency recording.
find_expr_references() neglected to record a dependency on the result typeof a FieldSelect node, allowing a DROP TYPE to break a view or rule thatcontains such an expression. I think we'd omitted this case intentionally,reasoning that there would always be a related dependency ensuring that theDROP would cascade to the view. But at least with nested field selectionexpressions, that's not true, as shown in bug #14867 from Mansur Galiev.Add the dependency, and for good measure a dependency on the node's exposedcollation.Likewise add a dependency on the result type of a FieldStore. I think herethe reasoning was that it'd only appear within an assignment to a field,and the dependency on the field's column would be enough ... but havingseen this example, I think that's wrong for nested-composites cases.Looking at nearby code, I notice we're not recording a dependency on theexposed collation of CoerceViaIO, which seems inconsistent with our choicesfor related node types. Maybe that's OK but I'm feeling suspicious of thiscode today, so let's add that; it certainly can't hurt.This patch does not do anything to protect already-existing views, onlyviews created after it's installed. But seeing that the issue has beenthere a very long time and nobody noticed till now, that's probably goodenough.Back-patch to all supported branches.Discussion:https://postgr.es/m/20171023150118.1477.19174@wrigleys.postgresql.org
1 parent0270ad1 commit900a9fd

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

‎src/backend/catalog/dependency.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,6 +1639,27 @@ find_expr_references_walker(Node *node,
16391639
/* Extra work needed here if we ever need this case */
16401640
elog(ERROR,"already-planned subqueries not supported");
16411641
}
1642+
elseif (IsA(node,FieldSelect))
1643+
{
1644+
FieldSelect*fselect= (FieldSelect*)node;
1645+
1646+
/* result type might not appear anywhere else in expression */
1647+
add_object_address(OCLASS_TYPE,fselect->resulttype,0,
1648+
context->addrs);
1649+
/* the collation might not be referenced anywhere else, either */
1650+
if (OidIsValid(fselect->resultcollid)&&
1651+
fselect->resultcollid!=DEFAULT_COLLATION_OID)
1652+
add_object_address(OCLASS_COLLATION,fselect->resultcollid,0,
1653+
context->addrs);
1654+
}
1655+
elseif (IsA(node,FieldStore))
1656+
{
1657+
FieldStore*fstore= (FieldStore*)node;
1658+
1659+
/* result type might not appear anywhere else in expression */
1660+
add_object_address(OCLASS_TYPE,fstore->resulttype,0,
1661+
context->addrs);
1662+
}
16421663
elseif (IsA(node,RelabelType))
16431664
{
16441665
RelabelType*relab= (RelabelType*)node;
@@ -1659,6 +1680,11 @@ find_expr_references_walker(Node *node,
16591680
/* since there is no exposed function, need to depend on type */
16601681
add_object_address(OCLASS_TYPE,iocoerce->resulttype,0,
16611682
context->addrs);
1683+
/* the collation might not be referenced anywhere else, either */
1684+
if (OidIsValid(iocoerce->resultcollid)&&
1685+
iocoerce->resultcollid!=DEFAULT_COLLATION_OID)
1686+
add_object_address(OCLASS_COLLATION,iocoerce->resultcollid,0,
1687+
context->addrs);
16621688
}
16631689
elseif (IsA(node,ArrayCoerceExpr))
16641690
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp