|
7 | 7 | * Portions Copyright (c) 1994, Regents of the University of California
|
8 | 8 | *
|
9 | 9 | * 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 $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -136,13 +136,24 @@ make_subplan(SubLink *slink)
|
136 | 136 |
|
137 | 137 | PlannerQueryLevel++;/* we become child */
|
138 | 138 |
|
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. |
142 | 143 | */
|
143 | 144 | if (subquery==NULL)
|
| 145 | +elog(ERROR,"make_subplan: invalid expression structure (SubLink already processed?)"); |
| 146 | +if (subquery->base_rel_list!=NIL) |
144 | 147 | elog(ERROR,"make_subplan: invalid expression structure (subquery already processed?)");
|
145 | 148 |
|
| 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 | + |
146 | 157 | /*
|
147 | 158 | * For an EXISTS subplan, tell lower-level planner to expect that only
|
148 | 159 | * the first tuple will be retrieved. For ALL and ANY subplans, we
|
|