Re: on_error table, saving error info to a table - Mailing list pgsql-hackers

From solaimurugan vellaipandiyan
Subject Re: on_error table, saving error info to a table
Date
Msg-id CAHEL7KSwRXeQNyh1zynYi9TKERU8GxR1iG1MfsvqKN9qZCtGfw@mail.gmail.com
Whole thread
In response to Re: on_error table, saving error info to a table  (jian he <jian.universality@gmail.com>)
List 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

pgsql-hackers by date:

Previous
From: vignesh C
Date:
Subject: Re: Proposal: Conflict log history table for Logical Replication
Next
From: solaimurugan vellaipandiyan
Date:
Subject: Re: postgres_fdw: Use COPY to speed up batch inserts