Re: on_error table, saving error info to a table
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: solaimurugan vellaipandiyan <drsolaimurugan.v@gmail.com>
Cc: Nishant Sharma <nishant.sharma@enterprisedb.com>,
Kirill Reshke <reshkekirill@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-05-12T07:06:46Z
Lists: pgsql-hackers
Attachments
- v11-0001-export-ExecInsert.patch (text/x-patch)
- v11-0002-COPY-FROM-on_error-table-error_table-errtbl.patch (text/x-patch)
On Mon, May 11, 2026 at 3:32 PM solaimurugan vellaipandiyan <drsolaimurugan.v@gmail.com> wrote: > > I additionally tested ERROR_TABLE behavior with a BEFORE INSERT > trigger attached to err_tbl. > From my testing, COPY still succeeds and malformed rows continue to be > inserted into err_tbl even when triggers are present on the > ERROR_TABLE. The trigger function also appears to execute normally > during error row insertion. For example, using a trigger function with > RAISE NOTICE produced: > > NOTICE: trigger fired > for each malformed row redirected into err_tbl. > Since the patch comments mention restrictions around triggers for > ERROR_TABLE, I was not sure whether this current behavior is > intentional or whether the trigger restriction checks are still > incomplete. With v11, I changed the behavior to: Statement-level triggers on the ERROR_TABLE are fired unconditionally, regardless of whether an error occurred or not. Each row inserted into the ERROR_TABLE will fire both the BEFORE INSERT FOR EACH ROW and AFTER INSERT FOR EACH ROW triggers.