mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
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 this issue of whether querytrees are read-only and can share substructure or not.
This commit is contained in:
@ -14,7 +14,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.61 2001/03/22 03:59:38 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.62 2001/03/27 18:02:19 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -692,6 +692,29 @@ adjust_inherited_attrs_mutator(Node *node,
|
|||||||
* NOTE: we do not need to recurse into sublinks, because they should
|
* NOTE: we do not need to recurse into sublinks, because they should
|
||||||
* already have been converted to subplans before we see them.
|
* already have been converted to subplans before we see them.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BUT: although we don't need to recurse into subplans, we do need to
|
||||||
|
* make sure that they are copied, not just referenced as
|
||||||
|
* expression_tree_mutator will do by default. Otherwise we'll have the
|
||||||
|
* same subplan node referenced from each arm of the inheritance APPEND
|
||||||
|
* plan, which will cause trouble in the executor. This is a kluge
|
||||||
|
* that should go away when we redesign querytrees.
|
||||||
|
*/
|
||||||
|
if (is_subplan(node))
|
||||||
|
{
|
||||||
|
SubPlan *subplan;
|
||||||
|
|
||||||
|
/* Copy the node and process subplan args */
|
||||||
|
node = expression_tree_mutator(node, adjust_inherited_attrs_mutator,
|
||||||
|
(void *) context);
|
||||||
|
/* Make sure we have separate copies of subplan and its rtable */
|
||||||
|
subplan = (SubPlan *) ((Expr *) node)->oper;
|
||||||
|
subplan->plan = copyObject(subplan->plan);
|
||||||
|
subplan->rtable = copyObject(subplan->rtable);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
return expression_tree_mutator(node, adjust_inherited_attrs_mutator,
|
return expression_tree_mutator(node, adjust_inherited_attrs_mutator,
|
||||||
(void *) context);
|
(void *) context);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user