git.postgresql.org Git - postgresql.git/commit

git projects / postgresql.git / commit
? search:
summary | shortlog | log | commit | commitdiff | tree
(parent: c1f1c1f) | patch
Fix corner-case planner failure for MERGE.
2023年3月28日 15:36:50 +0000 (11:36 -0400)
2023年3月28日 15:39:24 +0000 (11:39 -0400)
commit 326a33a289c7ba2dbf45f17e610b7be98dc11f67
Fix corner-case planner failure for MERGE.

MERGE planning could fail with "variable not found in subplan target
list" if the target table is partitioned and all its partitions are
excluded at plan time, or in the case where it has no partitions but
used to have some. This happened because distribute_row_identity_vars
thought it didn't need to make the target table's reltarget list
fully valid; but if we generate a join plan then that is required
because the dummy Result node's tlist will be made from the reltarget.

The same logic appears in distribute_row_identity_vars in v14,
but AFAICS the problem is unreachable in that branch for lack of
MERGE. In other updating statements, the target table is always
inner-joined to any other tables, so if the target is known dummy
then the whole plan reduces to dummy, so no join nodes are created.
So I'll refrain from back-patching this code change to v14 for now.

Per report from Alvaro Herrera.

Discussion: https://postgr.es/m/20230328112248.6as34mlx5sr4kltg@alvherre.pgsql
src/backend/optimizer/util/appendinfo.c diff | blob | blame | history
src/test/regress/expected/merge.out diff | blob | blame | history
src/test/regress/sql/merge.sql diff | blob | blame | history
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /