Fix incorrect Result node flattening logic

This fixes some incorrect flattening of nested Result nodes during
create_plan that was introduced by f2bae51df.  That commit failed to
maintain the logic that checks for subplans and gating quals from the
nested Result node before flattening, and that could result in the nested
gating qual and subplan being lost, which could produce incorrect results.

Bug: #19579
Reported-by: Viktor Leis <[email protected]>
Author: Ayush Tiwari <[email protected]>
Reviewed-by: David Rowley <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 19

Branch
------
REL_19_STABLE

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

Modified Files
--------------
src/backend/optimizer/plan/createplan.c | 21 +++++++++++----------
src/test/regress/expected/join.out      | 11 +++++++++++
src/test/regress/sql/join.sql           |  8 ++++++++
3 files changed, 30 insertions(+), 10 deletions(-)

Reply via email to