Re: MERGE ... WHEN NOT MATCHED BY SOURCE
Dean Rasheed <dean.a.rasheed@gmail.com>
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: Ted Yu <yuzhihong@gmail.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2023-02-07T10:28:42Z
Lists: pgsql-hackers
Attachments
- support-merge-when-not-matched-by-source-v6.patch (text/x-patch) patch v6
On Sat, 21 Jan 2023 at 14:18, Ted Yu <yuzhihong@gmail.com> wrote: > > On Sat, Jan 21, 2023 at 3:05 AM Dean Rasheed <dean.a.rasheed@gmail.com> wrote: >> >> Rebased version, following 8eba3e3f02 and 5d29d525ff. >> Another rebased version attached. > In transform_MERGE_to_join : > > + if (action->matchKind == MERGE_WHEN_NOT_MATCHED_BY_SOURCE) > + tgt_only_tuples = true; > + if (action->matchKind == MERGE_WHEN_NOT_MATCHED_BY_TARGET) > > There should be an `else` in front of the second `if`. > When tgt_only_tuples and src_only_tuples are both true, we can come out of the loop. > I decided not to do that. Adding an "else" doesn't change the code that the compiler generates, and IMO it's slightly more readable without it, since it keeps the line length shorter, and the test conditions aligned, but that's a matter of opinion / personal preference. I think adding extra logic to exit the loop early if both tgt_only_tuples and src_only_tuples are true would be a premature optimisation, increasing the code size for no real benefit. In practice, there are unlikely to be more than a few merge actions in the list. Regards, Dean
Commits
-
Add support for MERGE ... WHEN NOT MATCHED BY SOURCE.
- 0294df2f1f84 17.0 landed
-
Reindex toast before its main relation in reindex_relation()
- f2bf8fb04886 17.0 cited