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

Commit4c49611

Browse files
author
Richard Guo
committed
Remove code setting wrap_non_vars to true for UNION ALL subqueries
In pull_up_simple_subquery and pull_up_constant_function, there iscode that sets wrap_non_vars to true when dealing with an appendrelmember. The goal is to wrap subquery outputs that are not simple Varsin PlaceHolderVars, ensuring that what we pull up doesn't get mergedinto a surrounding expression during later processing, which couldcause it to fail to match the expression actually available from theappendrel.However, this is unnecessary. When pulling up an appendrel childsubquery, the only part of the upper query that could reference theappendrel child yet is the translated_vars list of the associatedAppendRelInfo that we just made for this child. Furthermore, we donot want to force use of PHVs in the AppendRelInfo, as there is noouter join between. In fact, perform_pullup_replace_vars always setswrap_non_vars to false before performing pullup_replace_vars on theAppendRelInfo.This patch simply removes the code that sets wrap_non_vars to true forUNION ALL subqueries.Author: Richard Guo <guofenglinux@gmail.com>Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>Discussion:https://postgr.es/m/CAMbWs4-VXDEi1v+hZYLxpOv0riJxHsCkCH1f46tLnhonEAyGCQ@mail.gmail.com
1 parentd3b2e5e commit4c49611

File tree

1 file changed

+8
-25
lines changed

1 file changed

+8
-25
lines changed

‎src/backend/optimizer/prep/prepjointree.c

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,24 +1440,14 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte,
14401440
rvcontext.rv_cache=palloc0((list_length(subquery->targetList)+1)*
14411441
sizeof(Node*));
14421442

1443-
/*
1444-
* If we are dealing with an appendrel member then anything that's not a
1445-
* simple Var has to be turned into a PlaceHolderVar. We force this to
1446-
* ensure that what we pull up doesn't get merged into a surrounding
1447-
* expression during later processing and then fail to match the
1448-
* expression actually available from the appendrel.
1449-
*/
1450-
if (containing_appendrel!=NULL)
1451-
rvcontext.wrap_non_vars= true;
1452-
14531443
/*
14541444
* If the parent query uses grouping sets, we need a PlaceHolderVar for
1455-
* anything that's not a simple Var.Again, thisensures that expressions
1456-
*retaintheir separate identity so that they will match grouping set
1457-
*columnswhen appropriate. (It'd be sufficient to wrap values used in
1458-
*groupingset columns, and do so only in non-aggregated portions of the
1459-
*tlist andhavingQual, but that would require a lot of infrastructure
1460-
*thatpullup_replace_vars hasn't currently got.)
1445+
* anything that's not a simple Var.Thisensures that expressions retain
1446+
* their separate identity so that they will match grouping set columns
1447+
* when appropriate. (It'd be sufficient to wrap values used in grouping
1448+
* set columns, and do so only in non-aggregated portions of the tlist and
1449+
* havingQual, but that would require a lot of infrastructure that
1450+
* pullup_replace_vars hasn't currently got.)
14611451
*/
14621452
if (parse->groupingSets)
14631453
rvcontext.wrap_non_vars= true;
@@ -2159,17 +2149,10 @@ pull_up_constant_function(PlannerInfo *root, Node *jtnode,
21592149
rvcontext.rv_cache=palloc0((list_length(rvcontext.targetlist)+1)*
21602150
sizeof(Node*));
21612151

2162-
/*
2163-
* If we are dealing with an appendrel member then anything that's not a
2164-
* simple Var has to be turned into a PlaceHolderVar. (See comments in
2165-
* pull_up_simple_subquery().)
2166-
*/
2167-
if (containing_appendrel!=NULL)
2168-
rvcontext.wrap_non_vars= true;
2169-
21702152
/*
21712153
* If the parent query uses grouping sets, we need a PlaceHolderVar for
2172-
* anything that's not a simple Var.
2154+
* anything that's not a simple Var. (See comments in
2155+
* pull_up_simple_subquery().)
21732156
*/
21742157
if (parse->groupingSets)
21752158
rvcontext.wrap_non_vars= true;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp