diff options
author | Dean Rasheed <dean.a.rasheed@gmail.com> | 2024-03-30 10:00:26 +0000 |
---|---|---|
committer | Dean Rasheed <dean.a.rasheed@gmail.com> | 2024-03-30 10:00:26 +0000 |
commit | 0294df2f1f842dfb0eed79007b21016f486a3c6c (patch) | |
tree | d01da8c03b91a25a438f05dd7dccdb95d13f8f92 /src/backend/optimizer/util/pathnode.c | |
parent | 46e5441fa536b89c1123f270fdfeeb72c320b901 (diff) |
Add support for MERGE ... WHEN NOT MATCHED BY SOURCE.
This allows MERGE commands to include WHEN NOT MATCHED BY SOURCE
actions, which operate on rows that exist in the target relation, but
not in the data source. These actions can execute UPDATE, DELETE, or
DO NOTHING sub-commands.
This is in contrast to already-supported WHEN NOT MATCHED actions,
which operate on rows that exist in the data source, but not in the
target relation. To make this distinction clearer, such actions may
now be written as WHEN NOT MATCHED BY TARGET.
Writing WHEN NOT MATCHED without specifying BY SOURCE or BY TARGET is
equivalent to writing WHEN NOT MATCHED BY TARGET.
Dean Rasheed, reviewed by Alvaro Herrera, Ted Yu and Vik Fearing.
Discussion: https://postgr.es/m/CAEZATCWqnKGc57Y_JanUBHQXNKcXd7r=0R4NEZUVwP+syRkWbA@mail.gmail.com
Diffstat (limited to 'src/backend/optimizer/util/pathnode.c')
-rw-r--r-- | src/backend/optimizer/util/pathnode.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index e4a5ae83e4a..3cf1dac0873 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -3716,6 +3716,7 @@ create_lockrows_path(PlannerInfo *root, RelOptInfo *rel, * 'onconflict' is the ON CONFLICT clause, or NULL * 'epqParam' is the ID of Param for EvalPlanQual re-eval * 'mergeActionLists' is a list of lists of MERGE actions (one per rel) + * 'mergeJoinConditions' is a list of join conditions for MERGE (one per rel) */ ModifyTablePath * create_modifytable_path(PlannerInfo *root, RelOptInfo *rel, @@ -3727,7 +3728,8 @@ create_modifytable_path(PlannerInfo *root, RelOptInfo *rel, List *updateColnosLists, List *withCheckOptionLists, List *returningLists, List *rowMarks, OnConflictExpr *onconflict, - List *mergeActionLists, int epqParam) + List *mergeActionLists, List *mergeJoinConditions, + int epqParam) { ModifyTablePath *pathnode = makeNode(ModifyTablePath); @@ -3795,6 +3797,7 @@ create_modifytable_path(PlannerInfo *root, RelOptInfo *rel, pathnode->onconflict = onconflict; pathnode->epqParam = epqParam; pathnode->mergeActionLists = mergeActionLists; + pathnode->mergeJoinConditions = mergeJoinConditions; return pathnode; } |