=== Applying patches on top of PostgreSQL commit ID 302cf15759233e654512979286ce1a5c3b36625f === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Wed Feb 19 07:44:27 UTC 2025 On branch cf/3478 nothing to commit, working tree clean === applying patch ./0001-Fix-an-oversight-in-cbc127917-for-MERGE-handling.patch Applied patch to 'src/backend/executor/nodeModifyTable.c' with conflicts. Applied patch to 'src/include/nodes/execnodes.h' with conflicts. Applied patch to 'src/test/regress/expected/partition_prune.out' with conflicts. Applied patch to 'src/test/regress/sql/partition_prune.sql' with conflicts. U src/backend/executor/nodeModifyTable.c U src/include/nodes/execnodes.h U src/test/regress/expected/partition_prune.out U src/test/regress/sql/partition_prune.sql diff --cc src/backend/executor/nodeModifyTable.c index b0fe50075a,e0f859ba96..0000000000 --- a/src/backend/executor/nodeModifyTable.c +++ b/src/backend/executor/nodeModifyTable.c @@@ -3668,14 -3667,14 +3668,22 @@@ ExecInitMerge(ModifyTableState *mtstate * anything here, do so there too. */ i = 0; ++<<<<<<< ours + foreach(lc, mergeActionLists) ++======= + foreach(lc, mtstate->mt_mergeActionLists) ++>>>>>>> theirs { List *mergeActionList = lfirst(lc); Node *joinCondition; TupleDesc relationDesc; ListCell *l; ++<<<<<<< ours + joinCondition = (Node *) list_nth(mergeJoinConditions, i); ++======= + joinCondition = (Node *) list_nth(mtstate->mt_mergeJoinConditions, i); ++>>>>>>> theirs resultRelInfo = mtstate->resultRelInfo + i; i++; relationDesc = RelationGetDescr(resultRelInfo->ri_RelationDesc); diff --cc src/include/nodes/execnodes.h index 2625d7e822,66fa613334..0000000000 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@@ -1448,9 -1448,9 +1448,15 @@@ typedef struct ModifyTableStat double mt_merge_deleted; /* ++<<<<<<< ours + * Lists of valid updateColnosLists, mergeActionLists, and + * mergeJoinConditions. These contain only entries for unpruned + * relations, filtered from the corresponding lists in ModifyTable. ++======= + * Lists of valid updateColnosListsm, mergeActionLists, and + * mergeJoinConditions. These contain only those belonging to unpruned + * relations from the respective Lists in the ModifyTable. ++>>>>>>> theirs */ List *mt_updateColnosLists; List *mt_mergeActionLists; diff --cc src/test/regress/expected/partition_prune.out index 6f80b62a3b,3261da2821..0000000000 --- a/src/test/regress/expected/partition_prune.out +++ b/src/test/regress/expected/partition_prune.out @@@ -4561,34 -4547,5 +4561,37 @@@ table part_abc_view 2 | c | t (1 row) ++<<<<<<< ours +-- All pruned. +explain (costs off) +merge into part_abc_view pt +using (select stable_one() + 2 as pid) as q join part_abc_1 pt1 on (q.pid = pt1.a) on pt.a = pt1.a +when matched then delete returning pt.a; + QUERY PLAN +------------------------------------------------------ + Merge on part_abc + -> Nested Loop + -> Append + Subplans Removed: 2 + -> Materialize + -> Seq Scan on part_abc_1 pt1 + Filter: (a = (stable_one() + 2)) +(7 rows) + +merge into part_abc_view pt +using (select stable_one() + 2 as pid) as q join part_abc_1 pt1 on (q.pid = pt1.a) on pt.a = pt1.a +when matched then delete returning pt.a; + a +--- +(0 rows) + +table part_abc_view; + a | b | c +---+---+--- + 2 | c | t +(1 row) + ++======= ++>>>>>>> theirs drop view part_abc_view; drop table part_abc; diff --cc src/test/regress/sql/partition_prune.sql index 86621dcec0,b27f3ace73..0000000000 --- a/src/test/regress/sql/partition_prune.sql +++ b/src/test/regress/sql/partition_prune.sql @@@ -1382,18 -1379,9 +1382,24 @@@ explain (costs off merge into part_abc_view pt using (select stable_one() as pid) as q join part_abc_1 pt1 on (q.pid = pt1.a) on pt.a = pt1.a when matched then delete returning pt.a; ++<<<<<<< ours +merge into part_abc_view pt +using (select stable_one() as pid) as q join part_abc_1 pt1 on (q.pid = pt1.a) on pt.a = pt1.a +when matched then delete returning pt.a; +table part_abc_view; + +-- All pruned. +explain (costs off) +merge into part_abc_view pt +using (select stable_one() + 2 as pid) as q join part_abc_1 pt1 on (q.pid = pt1.a) on pt.a = pt1.a +when matched then delete returning pt.a; +merge into part_abc_view pt +using (select stable_one() + 2 as pid) as q join part_abc_1 pt1 on (q.pid = pt1.a) on pt.a = pt1.a ++======= + + merge into part_abc_view pt + using (select stable_one() as pid) as q join part_abc_1 pt1 on (q.pid = pt1.a) on pt.a = pt1.a ++>>>>>>> theirs when matched then delete returning pt.a; table part_abc_view;