When a query has aggregates or GROUP BY, parseCheckAggregates() flattens join alias Vars in the grouping expressions, target list and HAVING clause so that aliased and unaliased references compare equal. The parser has no PlannerInfo, so this relies on every join alias expression being able to carry varnullingrels without a PHV. That doesn't hold for a whole-row Var of a join on the nullable side of an outer join: it expands to a RowExpr, and pushing the nulling bits down into its fields would turn a NULL row into ROW(NULL, ...). Such queries therefore failed with "unsupported join alias expression". To fix, leave a nulled whole-row join Var unexpanded when no root is available. The planner expands it later and wraps it in a PlaceHolderVar as before. Nothing is lost for GROUP BY matching: a nulled whole-row Var can only be equal to the same Var, never to an expression over the join's columns. This has been broken since the introduction of varnullingrels in v16. Author: Richard Guo <guofenglinux@gmail.com> Discussion: https://postgr.es/m/CAMbWs49q_gvoeOoF0+KZ-DpQaDb=nGFfSgrz2V_n1_64L4ZNVQ@mail.gmail.com Backpatch-through: 16
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.
Copyright and license information can be found in the file COPYRIGHT.
General documentation about this version of PostgreSQL can be found at https://www.postgresql.org/docs/18/. In particular, information about building PostgreSQL from the source code can be found at https://www.postgresql.org/docs/18/installation.html.
The latest version of this software, and related software, may be obtained at https://www.postgresql.org/download/. For more information look at our web site located at https://www.postgresql.org/.