Thread
-
Re: COPY ON_CONFLICT TABLE; save duplicated record to another table.
jian he <jian.universality@gmail.com> — 2026-05-11T03:13:15Z
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. -- jian https://www.enterprisedb.com/