mirror of
https://github.com/postgres/postgres.git
synced 2025-08-18 12:22:09 +03:00
19bb5e46b95fa8543a9e685788ff6c514eda07fc
In branches before commit 4be058fe9
, we have to prevent flattening
of subqueries with empty jointrees if the subqueries' output
columns might need to be wrapped in PlaceHolderVars. That's
because the empty jointree would result in empty phrels for the
PlaceHolderVars, meaning we'd be unable to figure out where to
evaluate them. However, we've failed to keep is_simple_subquery's
check for this hazard in sync with what pull_up_simple_subquery
actually does. The former is checking "lowest_outer_join != NULL",
whereas the conditions pull_up_simple_subquery actually uses are
if (lowest_nulling_outer_join != NULL)
if (containing_appendrel != NULL)
if (parse->groupingSets)
So the outer-join test is overly conservative, while we missed out
checking for appendrels and groupingSets. The appendrel omission
is harmless, because in that case we also check is_safe_append_member
which will also reject such subqueries. The groupingSets omission
is a bug though, leading to assertion failures or planner errors
such as "variable not found in subplan target lists".
is_simple_subquery has access to none of the three variables used
in the correct tests, but its callers do, so I chose to have them
pass down a bool corresponding to the OR of these conditions.
(The need for duplicative conditions would be a maintenance
hazard in actively-developed code, but I'm not too concerned
about it in branches that have only ~ 1 year to live.)
Per bug #17614 from Wei Wei. Patch v10 and v11 only, since we have a
better answer to this in v12 and later (indeed, the faulty check in
is_simple_subquery is gone entirely).
Discussion: https://postgr.es/m/17614-8ec20c85bdecaa2a@postgresql.org
PostgreSQL Database Management System ===================================== This directory contains the source code distribution of the PostgreSQL database management system. PostgreSQL is an advanced object-relational database management system that supports an extended subset of the SQL standard, including transactions, foreign keys, subqueries, triggers, user-defined types and functions. This distribution also contains C language bindings. PostgreSQL has many language interfaces, many of which are listed here: https://www.postgresql.org/download See the file INSTALL for instructions on how to build and install PostgreSQL. That file also lists supported operating systems and hardware platforms and contains information regarding any other software packages that are required to build or run the PostgreSQL system. Copyright and license information can be found in the file COPYRIGHT. A comprehensive documentation set is included in this distribution; it can be read as described in the installation instructions. The latest version of this software may be obtained at https://www.postgresql.org/download/. For more information look at our web site located at https://www.postgresql.org/.
Languages
C
85.2%
PLpgSQL
6%
Perl
4.5%
Yacc
1.2%
Meson
0.7%
Other
2.1%