Re: on_error table, saving error info to a table

solaimurugan vellaipandiyan <drsolaimurugan.v@gmail.com>

From: solaimurugan vellaipandiyan <drsolaimurugan.v@gmail.com>
To: jian he <jian.universality@gmail.com>
Cc: Nishant Sharma <nishant.sharma@enterprisedb.com>, Kirill Reshke <reshkekirill@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-05-07T11:32:56Z
Lists: pgsql-hackers
Hi,

I tested the v9 patch series on current PostgreSQL HEAD.

The patches did not apply cleanly on the latest tree because of a small
conflict in nodeModifyTable.c, but after resolving it manually, the build
and installation completed successfully.

I initialized a fresh cluster and verified that the built-in composite type
copy_error_saving is created correctly during initdb.

I tested the feature using the following setup:

CREATE TABLE err_tbl OF copy_error_saving;

CREATE TABLE t(a int, b int, c int);

COPY t

FROM STDIN

WITH (

    FORMAT csv,

    ON_ERROR table,

    ERROR_TABLE err_tbl

);

Input used:

1,2,3

4,5,x

7,8,9

From my testing:

   -

   valid rows were inserted into the target table correctly
   -

   malformed rows were stored in ERROR_TABLE as expected
   -

   COPY continued processing the remaining rows successfully

The latest executor-based approach using ExecInsert() looks cleaner and
easier to follow compared to the earlier direct insertion approach.

I also feel the built-in composite type approach makes the ERROR_TABLE
validation simpler and more maintainable compared to manually checking all
columns and types.

Regards,
Solaimurugan