Re: on_error table, saving error info to a table

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: on_error table, saving error info to a table
Date: 2026-09-30 11:04:25
Message-ID: CACJufxFRDRkqMhuQqoTXY8-30epEGHim85CS8dMfhRR+XK2sUQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi.

V15 makes some non-fundamental changes compared to v14.
These are listed below:

1. Previously COPY FREEZE + ON_ERROR table does not working properly.
We need go through CopyFrom ``if (cstate->opts.freeze)`` loop first
then do CopyFromErrorTableInit.

2. we need following for COPY ON_ERROR table
```
if (XactReadOnly && !cstate->error_rel->rd_islocaltemp)
PreventCommandIfReadOnly("COPY FROM");
```

3. With COPY(ON_ERROR TABLE) in some case, we need set the
(CopyInsertMethod insertMethod)
to CIM_SINGLE.

4. Yes, (lineno bigint, line text) distinguishes the error rows within one COPY.
It does not distinguish rows from different COPY FROM operations that
write to the same
error table, e.g., loading the same file twice.
So I added a (starttime timestamptz) column, set to the statement start time.
Each <command>COPY FROM</command> command records its own start time,
so this column distinguishes the rows saved by different commands.

--
jian
https://www.enterprisedb.com/

Attachment Content-Type Size
v15-0002-COPY-FROM-on_error-table-error_table-errtbl.patch text/x-patch 65.2 KB
v15-0001-export-ExecInsert.patch text/x-patch 4.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message kedar anavardekar 2026-09-30 11:10:27 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Vadim Shakirov 2026-09-30 10:51:34 [PATCH v1] Fix out-of-bounds access in pg_bsd_indent's parser stack