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

Commit83fd58d

Browse files
committed
Add missing correction of sublevelsup when pulling up a subquery.
Fixes problem with cases likeSELECT * FROM foo t WHERE NOT EXISTS (SELECT remoteid FROM(SELECT f1 as remoteid FROM foo WHERE f1 = t.f1) AS t1)
1 parent44f68fc commit83fd58d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* 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 $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -337,17 +337,23 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join)
337337

338338
/*
339339
* Now make a modifiable copy of the subquery that we can run
340-
* OffsetVarNodes on.
340+
* OffsetVarNodesand IncrementVarSublevelsUpon.
341341
*/
342342
subquery=copyObject(subquery);
343343

344344
/*
345-
* Adjust varnos in subquery so that we can append its
345+
* Adjustlevel-0varnos in subquery so that we can append its
346346
* rangetable to upper query's.
347347
*/
348348
rtoffset=length(parse->rtable);
349349
OffsetVarNodes((Node*)subquery,rtoffset,0);
350350

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+
351357
/*
352358
* Replace all of the top query's references to the subquery's
353359
* outputs with copies of the adjusted subtlist items, being

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp