|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.124 2002/09/04 20:31:21 momjian Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.125 2002/09/24 18:38:23 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -337,17 +337,23 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join)
|
337 | 337 |
|
338 | 338 | /*
|
339 | 339 | * Now make a modifiable copy of the subquery that we can run
|
340 |
| - * OffsetVarNodes on. |
| 340 | + * OffsetVarNodesand IncrementVarSublevelsUpon. |
341 | 341 | */
|
342 | 342 | subquery=copyObject(subquery);
|
343 | 343 |
|
344 | 344 | /*
|
345 |
| - * Adjust varnos in subquery so that we can append its |
| 345 | + * Adjustlevel-0varnos in subquery so that we can append its |
346 | 346 | * rangetable to upper query's.
|
347 | 347 | */
|
348 | 348 | rtoffset=length(parse->rtable);
|
349 | 349 | OffsetVarNodes((Node*)subquery,rtoffset,0);
|
350 | 350 |
|
| 351 | +/* |
| 352 | + * Upper-level vars in subquery are now one level closer to their |
| 353 | + * parent than before. |
| 354 | + */ |
| 355 | +IncrementVarSublevelsUp((Node*)subquery,-1,1); |
| 356 | + |
351 | 357 | /*
|
352 | 358 | * Replace all of the top query's references to the subquery's
|
353 | 359 | * outputs with copies of the adjusted subtlist items, being
|
|