| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> |
| Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: COPY ON_CONFLICT TABLE; save duplicated record to another table. |
| Date: | 2026-05-11 03:13:15 |
| Message-ID: | CACJufxHjjhshvXC8jOMyry73AYMESTVLfQwto0=NK_A951exAA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi.
The attached patch should address most, if not all, of the issues you
both raised.
As explained in [1], we can export ExecInsert to let it perform the
main insertion work.
To allow ExecInsert to handle the remaining tasks, we need to carefuly manage
the lifecycle of constructed CopyFromStateData->ModifyTableContext (including
ModifyTableContext->EState): populate it, use it, and then release it.
Since ExecInsert already contains the necessary infrastructure for INSERT ON
CONFLICT DO NOTHING/SELECT, exporting it avoids duplicating that logic in
src/backend/commands/copyfrom.c (which is what v1 of the patch did).
[1]: https://postgr.es/m/CACJufxH_NbPuA+O5YR7xP4xDZ+iHkO2VFkddhrhBz+4-EUTp7w@mail.gmail.com
The exclusion unique constraint issue is still not resolved.... but,
overall v2 is better than v1, IMHO.
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0002-COPY-ON_CONFLICT-TABLE.patch | text/x-patch | 58.5 KB |
| v2-0001-export-ExecInsert.patch | text/x-patch | 4.7 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | JoongHyuk Shin | 2026-05-11 03:17:36 | Re: [PATCH] Don't call ereport(ERROR) from recovery target GUC assign hooks |
| Previous Message | Fujii Masao | 2026-05-11 03:01:33 | Re: [PATCH] Release replication slot on error in SQL-callable slot functions |