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

Commitf155cc8

Browse files
committed
Quick hack to fix Oliver Elphick's problem with subselects in an
inheritance query: make duplicate copies of subplans in adjust_inherited_attrs.When we redesign querytrees we really gotta do something about thisissue of whether querytrees are read-only and can share substructureor not.
1 parentfa0f2c6 commitf155cc8

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

‎src/backend/optimizer/prep/prepunion.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
*
1616
* IDENTIFICATION
17-
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.61 2001/03/22 03:59:38 momjian Exp $
17+
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.62 2001/03/27 18:02:19 tgl Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
@@ -679,7 +679,7 @@ adjust_inherited_attrs_mutator(Node *node,
679679
adjust_inherited_attrs_mutator((Node*)oldinfo->clause,context);
680680

681681
newinfo->subclauseindices=NIL;
682-
newinfo->eval_cost=-1;/* reset this too */
682+
newinfo->eval_cost=-1;/* reset this too */
683683
newinfo->left_pathkey=NIL;/* and these */
684684
newinfo->right_pathkey=NIL;
685685
newinfo->left_dispersion=-1;
@@ -692,6 +692,29 @@ adjust_inherited_attrs_mutator(Node *node,
692692
* NOTE: we do not need to recurse into sublinks, because they should
693693
* already have been converted to subplans before we see them.
694694
*/
695+
696+
/*
697+
* BUT: although we don't need to recurse into subplans, we do need to
698+
* make sure that they are copied, not just referenced as
699+
* expression_tree_mutator will do by default. Otherwise we'll have the
700+
* same subplan node referenced from each arm of the inheritance APPEND
701+
* plan, which will cause trouble in the executor. This is a kluge
702+
* that should go away when we redesign querytrees.
703+
*/
704+
if (is_subplan(node))
705+
{
706+
SubPlan*subplan;
707+
708+
/* Copy the node and process subplan args */
709+
node=expression_tree_mutator(node,adjust_inherited_attrs_mutator,
710+
(void*)context);
711+
/* Make sure we have separate copies of subplan and its rtable */
712+
subplan= (SubPlan*) ((Expr*)node)->oper;
713+
subplan->plan=copyObject(subplan->plan);
714+
subplan->rtable=copyObject(subplan->rtable);
715+
returnnode;
716+
}
717+
695718
returnexpression_tree_mutator(node,adjust_inherited_attrs_mutator,
696719
(void*)context);
697720
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp