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

Commitf3ea3e3

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 parent471d558 commitf3ea3e3

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
@@ -1713,6 +1713,27 @@ find_expr_references_walker(Node *node,
17131713
/* Extra work needed here if we ever need this case */
17141714
elog(ERROR,"already-planned subqueries not supported");
17151715
}
1716+
elseif (IsA(node,FieldSelect))
1717+
{
1718+
FieldSelect*fselect= (FieldSelect*)node;
1719+
1720+
/* result type might not appear anywhere else in expression */
1721+
add_object_address(OCLASS_TYPE,fselect->resulttype,0,
1722+
context->addrs);
1723+
/* the collation might not be referenced anywhere else, either */
1724+
if (OidIsValid(fselect->resultcollid)&&
1725+
fselect->resultcollid!=DEFAULT_COLLATION_OID)
1726+
add_object_address(OCLASS_COLLATION,fselect->resultcollid,0,
1727+
context->addrs);
1728+
}
1729+
elseif (IsA(node,FieldStore))
1730+
{
1731+
FieldStore*fstore= (FieldStore*)node;
1732+
1733+
/* result type might not appear anywhere else in expression */
1734+
add_object_address(OCLASS_TYPE,fstore->resulttype,0,
1735+
context->addrs);
1736+
}
17161737
elseif (IsA(node,RelabelType))
17171738
{
17181739
RelabelType*relab= (RelabelType*)node;
@@ -1733,6 +1754,11 @@ find_expr_references_walker(Node *node,
17331754
/* since there is no exposed function, need to depend on type */
17341755
add_object_address(OCLASS_TYPE,iocoerce->resulttype,0,
17351756
context->addrs);
1757+
/* the collation might not be referenced anywhere else, either */
1758+
if (OidIsValid(iocoerce->resultcollid)&&
1759+
iocoerce->resultcollid!=DEFAULT_COLLATION_OID)
1760+
add_object_address(OCLASS_COLLATION,iocoerce->resultcollid,0,
1761+
context->addrs);
17361762
}
17371763
elseif (IsA(node,ArrayCoerceExpr))
17381764
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp