postgresql/src
Robert Haas 0d4391b265 Store information about elided nodes in the final plan.
An extension (or core code) might want to reconstruct the planner's
choice of join order from the final plan. To do so, it must be possible
to find all of the RTIs that were part of the join problem in that plan.
Commit adbad833f3, together with the
earlier work in 8c49a484e8, is enough to
let us match up RTIs we see in the final plan with RTIs that we see
during the planning cycle, but we still have a problem if the planner
decides to drop some RTIs out of the final plan altogether.

To fix that, when setrefs.c removes a SubqueryScan, single-child Append,
or single-child MergeAppend from the final Plan tree, record the type of
the removed node and the RTIs that the removed node would have scanned
in the final plan tree. It would be natural to record this information
on the child of the removed plan node, but that would require adding an
additional pointer field to type Plan, which seems undesirable.  So,
instead, store the information in a separate list that the executor need
never consult, and use the plan_node_id to identify the plan node with
which the removed node is logically associated.

Also, update pg_overexplain to display these details.

Reviewed-by: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Jakub Wartak <jakub.wartak@enterprisedb.com>
Reviewed-by: Greg Burd <greg@burd.me>
Reviewed-by: Jacob Champion <jacob.champion@enterprisedb.com>
Reviewed-by: Amit Langote <amitlangote09@gmail.com>
Reviewed-by: Haibo Yan <tristan.yim@gmail.com>
Reviewed-by: Alexandra Wang <alexandra.wang.oss@gmail.com>
Discussion: http://postgr.es/m/CA+TgmoZ-Jh1T6QyWoCODMVQdhTUPYkaZjWztzP1En4=ZHoKPzw@mail.gmail.com
2026-02-10 16:46:05 -05:00
..
backend Store information about elided nodes in the final plan. 2026-02-10 16:46:05 -05:00
bin pg_upgrade: Fix handling of pg_largeobject_metadata. 2026-02-09 14:58:02 -06:00
common Fix mb2wchar functions on short input. 2026-02-09 12:08:58 +13:00
fe_utils Force standard_conforming_strings to always be ON. 2026-01-21 15:08:38 -05:00
include Store information about elided nodes in the final plan. 2026-02-10 16:46:05 -05:00
interfaces libpq: Prepare for protocol grease during 19beta 2026-02-06 10:31:45 -08:00
makefiles tests: Add a test C++ extension module 2026-01-20 16:42:30 +01:00
pl Refactor att_align_nominal() to improve performance. 2026-02-02 14:39:50 -05:00
port Fix accidentally cast away qualifiers 2026-01-26 16:02:31 +01:00
template Remove traces of support for Sun Studio compiler 2025-09-12 07:39:05 +02:00
test Simplify some log messages in extended_stats_funcs.c 2026-02-10 16:59:19 +09:00
timezone Update time zone data files to tzdata release 2025c. 2026-01-18 14:54:33 -05:00
tools Store information about elided nodes in the final plan. 2026-02-10 16:46:05 -05:00
tutorial Force standard_conforming_strings to always be ON. 2026-01-21 15:08:38 -05:00
.gitignore
DEVELOPERS
Makefile
Makefile.global.in tests: Add a test C++ extension module 2026-01-20 16:42:30 +01:00
Makefile.shlib Use exported symbols list on macOS for loadable modules as well 2025-06-10 07:04:43 +02:00
meson.build Update copyright for 2026 2026-01-01 13:24:10 -05:00
nls-global.mk Fix update-po for the PGXS case 2025-10-16 20:21:05 +02:00