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

Commit12e116a

Browse files
committed
Put back one copyObject() in rewriteTargetView().
Commit6f8cb1e tried to centralize rewriteTargetView's copyingof a target view's Query struct. However, it ignored the fact that thejointree->quals field was used twice. This only accidentally failed tofail immediately because the same ChangeVarNodes mutation is applied inboth cases, so that we end up with logically identical expression treesfor both uses (and, as the code stands, the second ChangeVarNodes callactually does nothing). However, we end up linking *physically*identical expression trees into both an RTE's securityQuals list andthe WithCheckOption list. That's pretty dangerous, mainly becauseprepsecurity.c is utterly cavalier about further munging such structureswithout copying them first.There may be no live bug in HEAD as a consequence of the fact that we applypreprocess_expression in between here and prepsecurity.c, and that willmake a copy of the tree anyway. Or it may just be that the regressiontests happen to not trip over it. (I noticed this only because thingsfell over pretty badly when I tried to relocate the planner's call ofexpand_security_quals to before expression preprocessing.) In any caseit's very fragile because if anyone tried to make the securityQuals andWithCheckOption trees diverge before we reach preprocess_expression, itwould not work. The fact that the current code will preprocesssecurityQuals and WithCheckOptions lists at completely different times indifferent query levels does nothing to increase my trust that that can'thappen.In view of the fact that 9.5.0 is almost upon us and the aforesaid commithas seen exactly zero field testing, the prudent course is to make an extracopy of the quals so that the behavior is not different from what has beenin the field during beta.
1 parent3b3e8fc commit12e116a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

‎src/backend/rewrite/rewriteHandler.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2825,6 +2825,13 @@ rewriteTargetView(Query *parsetree, Relation view)
28252825
{
28262826
Node*viewqual= (Node*)viewquery->jointree->quals;
28272827

2828+
/*
2829+
* Even though we copied viewquery already at the top of this
2830+
* function, we must duplicate the viewqual again here, because we may
2831+
* need to use the quals again below for a WithCheckOption clause.
2832+
*/
2833+
viewqual=copyObject(viewqual);
2834+
28282835
ChangeVarNodes(viewqual,base_rt_index,new_rt_index,0);
28292836

28302837
if (RelationIsSecurityView(view))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp