pgsql: Remove code setting wrap_non_vars to true for UNION ALL subqueri - Mailing list pgsql-committers

From Richard Guo
Subject pgsql: Remove code setting wrap_non_vars to true for UNION ALL subqueri
Date
Msg-id E1tsd77-002EUO-36@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Remove code setting wrap_non_vars to true for UNION ALL subqueries

In pull_up_simple_subquery and pull_up_constant_function, there is
code that sets wrap_non_vars to true when dealing with an appendrel
member.  The goal is to wrap subquery outputs that are not simple Vars
in PlaceHolderVars, ensuring that what we pull up doesn't get merged
into a surrounding expression during later processing, which could
cause it to fail to match the expression actually available from the
appendrel.

However, this is unnecessary.  When pulling up an appendrel child
subquery, the only part of the upper query that could reference the
appendrel child yet is the translated_vars list of the associated
AppendRelInfo that we just made for this child.  Furthermore, we do
not want to force use of PHVs in the AppendRelInfo, as there is no
outer join between.  In fact, perform_pullup_replace_vars always sets
wrap_non_vars to false before performing pullup_replace_vars on the
AppendRelInfo.

This patch simply removes the code that sets wrap_non_vars to true for
UNION 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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4c4961171577e292220d050c338020f2c6bf4c76

Modified Files
--------------
src/backend/optimizer/prep/prepjointree.c | 33 ++++++++-----------------------
1 file changed, 8 insertions(+), 25 deletions(-)


pgsql-committers by date:

Previous
From: "Daniel Westermann (DWE)"
Date:
Subject: Re: pgsql: Modularize log_connections output
Next
From: Peter Eisentraut
Date:
Subject: Re: pgsql: pg_logicalinspect: Fix possible crash when passing a directory p