pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix corner-case planner failure for MERGE. 2+ messages / 1 participants [nested] [flat]
* pgsql: Fix corner-case planner failure for MERGE. @ 2023-03-28 15:39 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2023-03-28 15:39 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/326a33a289c7ba2dbf45f17e610b7be98dc11f67 Modified Files -------------- src/backend/optimizer/util/appendinfo.c | 10 +++++++--- src/test/regress/expected/merge.out | 26 ++++++++++++++++++++++++++ src/test/regress/sql/merge.sql | 12 ++++++++++++ 3 files changed, 45 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Fix corner-case planner failure for MERGE. @ 2023-03-28 15:39 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2023-03-28 15:39 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/bf5c4b3d9da67ab0dd8a5a560804f88370c42866 Modified Files -------------- src/backend/optimizer/util/appendinfo.c | 10 +++++++--- src/test/regress/expected/merge.out | 25 +++++++++++++++++++++++++ src/test/regress/sql/merge.sql | 12 ++++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2023-03-28 15:39 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-03-28 15:39 pgsql: Fix corner-case planner failure for MERGE. Tom Lane <tgl@sss.pgh.pa.us> 2023-03-28 15:39 pgsql: Fix corner-case planner failure for MERGE. Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox