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

Commit3017000

Browse files
committed
Back-patch fix to copy sub-Query nodes before planning them. This
fixes problems with subselects appearing in contexts like COALESCE orBETWEEN, where parser will make multiple links to same subexpression.
1 parentc3aab02 commit3017000

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

‎src/backend/optimizer/plan/subselect.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.36 2000/04/1400:19:16 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.36.2.1 2000/09/23 21:00:05 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -136,13 +136,24 @@ make_subplan(SubLink *slink)
136136

137137
PlannerQueryLevel++;/* we become child */
138138

139-
/* Check to see if this node was already processed; if so we have
140-
* trouble. Someday should change tree representation so that we can
141-
* cope with multiple links to the same subquery, but for now...
139+
/*
140+
* Check to see if this node was already processed; if so we have
141+
* trouble. We check to see if the linked-to Query appears to have
142+
* been planned already, too.
142143
*/
143144
if (subquery==NULL)
145+
elog(ERROR,"make_subplan: invalid expression structure (SubLink already processed?)");
146+
if (subquery->base_rel_list!=NIL)
144147
elog(ERROR,"make_subplan: invalid expression structure (subquery already processed?)");
145148

149+
/*
150+
* Copy the source Query node. This is a quick and dirty kluge to resolve
151+
* the fact that the parser can generate trees with multiple links to the
152+
* same sub-Query node, but the planner wants to scribble on the Query.
153+
* Try to clean this up when we do querytree redesign...
154+
*/
155+
subquery= (Query*)copyObject(subquery);
156+
146157
/*
147158
* For an EXISTS subplan, tell lower-level planner to expect that only
148159
* the first tuple will be retrieved. For ALL and ANY subplans, we

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp