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

Commit465a3b0

Browse files
committed
Copy sub-Query nodes to avoid trouble when same sub-Query is linked to
multiple times in the parsetree (can happen in COALESCE or BETWEENcontexts, for example). This is a pretty grotty solution --- it willdo for now, but perhaps we can do better when we redesign querytrees.What we need is a consistent policy about whether querytrees should beconsidered read-only structures or not ...
1 parent75b6104 commit465a3b0

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.39 2000/07/12 02:37:09 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.40 2000/08/06 04:13:22 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -134,13 +134,24 @@ make_subplan(SubLink *slink)
134134

135135
PlannerQueryLevel++;/* we become child */
136136

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

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp