| From: | Tender Wang <tndrwang(at)gmail(dot)com> |
|---|---|
| To: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Fix stale source values in MERGE RETURNING after a cross-partition update |
| Date: | 2026-11-23 09:11:23 |
| Message-ID: | CAHewXNnB==6QQrL6EQhqzdPvB0DDjG8=feBXdhS6E-1we1nexQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> 于2026年11月22日周日 19:32写道:
>
> Hmm, I don't like that solution because it's somewhat delocalised,
> which I think makes it fragile if new code is added using
> context->planSlot, instead of your new returningSlot.
>
> I think a better (more localised) solution is to have
> ExecMergeMatched() swap out context->planSlot while it executes the
> NOT MATCHED BY SOURCE action. That feels more robust, because it
> removes any chance of any code called while executing the action
> seeing the old stale source values. Something like v2, attached.
>
Yeah, I agree that temporarily replacing context->planSlot in
ExecMergeMatched() is cleaner.
It gives the entire NOT MATCHED BY SOURCE action a consistent view of
the source row, including the cross-partition RETURNING path.
Restoring the original slot before returning also makes it available
to any subsequent NOT MATCHED BY TARGET action.
> Also, I don't think merge-match-recheck is the right place to test
> this, since it's not about rechecking AND conditions. I've added new
> tests to merge-not-matched, based on the ones added before for bug
> #19912, testing both left and full joins.
>
+1
--
Tender Wang
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bertrand Drouvot | 2026-11-23 09:22:39 | Fix relation statistics around transactional TRUNCATE |
| Previous Message | Aleksander Alekseev | 2026-11-23 08:56:37 | Re: Avoid unnecessary StringInfo allocation in tablesync COPY buffer |