pgsql: Apply band-aid fix for an oversight in reparameterize_path_by_ch

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Apply band-aid fix for an oversight in reparameterize_path_by_ch
Дата
Msg-id E1rVaxa-004Bpu-Cn@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Apply band-aid fix for an oversight in reparameterize_path_by_child.

The path we wish to reparameterize is not a standalone object:
in particular, it implicitly references baserestrictinfo clauses
in the associated RelOptInfo, and if it's a SampleScan path then
there is also the TableSampleClause in the RTE to worry about.
Both of those could contain lateral references to the join partner
relation, which would need to be modified to refer to its child.
Since we aren't doing that, affected queries can give wrong answers,
or odd failures such as "variable not found in subplan target list",
or executor crashes.  But we can't just summarily modify those
expressions, because they are shared with other paths for the rel.
We'd break things if we modify them and then end up using some
non-partitioned-join path.

In HEAD, we plan to fix this by postponing reparameterization
until create_plan(), when we know that those other paths are
no longer of interest, and then adjusting those expressions along
with the ones in the path itself.  That seems like too big a change
for stable branches however.  In the back branches, let's just detect
whether any troublesome lateral references actually exist in those
expressions, and fail reparameterization if so.  This will result in
not performing a partitioned join in such cases.  Given the lack of
field complaints, nobody's likely to miss the optimization.

Report and patch by Richard Guo.  Apply to 12-16 only, since
the intended fix for HEAD looks quite different.  We're not quite
ready to push the HEAD fix, but with back-branch releases coming
up soon, it seems wise to get this stopgap fix in place there.

Discussion: https://postgr.es/m/CAMbWs496+N=UAjOc=rcD3P7B6oJe4rZw08e_TZRUsWbPxZW3Tw@mail.gmail.com

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/12ec16d11c8bd75624a77ae7a456ceec8332c9d9

Modified Files
--------------
src/backend/optimizer/util/pathnode.c        | 175 +++++++++++++++++++++++++++
src/test/regress/expected/partition_join.out | 167 +++++++++++++++++++++++++
src/test/regress/sql/partition_join.sql      |  48 ++++++++
3 files changed, 390 insertions(+)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: pgsql: Continue my quest to make 002_blocks.pl pass reliably.
Следующее
От: Andrew Dunstan
Дата:
Сообщение: pgsql: Avoid package qualification of $windows_os