| From: | Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> |
|---|---|
| To: | jian he <jian(dot)universality(at)gmail(dot)com>, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> |
| 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 09:25:47 |
| Message-ID: | 685ff627-fed3-44a3-8633-ce104eaaabe5@uni-muenster.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Jian
On 11/05/2026 05:13, jian he wrote:
> The attached patch should address most, if not all, of the issues you
> both raised.
Thanks for the update. All my points were addressed.
> 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(at)mail(dot)gmail(dot)com
>
> The exclusion unique constraint issue is still not resolved.... but,
> overall v2 is better than v1, IMHO.
One other thing I just noticed in BINARY mode. I believe we're missing a
check in ProcessCopyOptions() with ON_CONFLICT TABLE to show a proper
error message, e.g.
/* Check on_conflict */
if (opts_out->format == COPY_FORMAT_BINARY && opts_out->on_conflict !=
ONCONFLICT_NONE)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("cannot specify %s in BINARY mode", "ON_CONFLICT TABLE")));
postgres=# COPY t FROM STDIN (FORMAT binary, ON_CONFLICT TABLE,
CONFLICT_TABLE ctbl);
ERROR: cannot specify ON_CONFLICT TABLE in BINARY mode
Right now the error is rather vague:
ERROR: COPY file signature not recognized
What do you think?
Thanks!
Best, Jim
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Shlok Kyal | 2026-05-11 09:29:22 | Re: Proposal: Conflict log history table for Logical Replication |
| Previous Message | shveta malik | 2026-05-11 09:07:46 | Re: Proposal: Conflict log history table for Logical Replication |