Re: expand on_error ignore error handling scope - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: expand on_error ignore error handling scope
Date
Msg-id aBF20Al3fO3-MJPT@paquier.xyz
Whole thread Raw
In response to expand on_error ignore error handling scope  (jian he <jian.universality@gmail.com>)
List pgsql-hackers
On Wed, Apr 30, 2025 at 08:00:00AM +0800, jian he wrote:
> Currently, (on_error ignore) only handles data type incompatibility errors.
> However, we can extend its functionality to also handle errors caused by extra
> data (additional columns) or missing data (fewer columns), I think.

The original argument behind type incompatibility checks was that
incorrectly shaped multi-byte utf-8 character sequences could be
problematic, particularly if these are cut with a newline.  It should
take care of most cases I've heard about (these should be arguments
about that around pg_bulkload, as well).

> on_error is only applicable to non-binary formats.
> In non-binary formats (such as text and CSV), COPY FROM cut income source row by
> row by newline.  This means that row boundaries are clearly defined.  If a
> line's contents cannot be successfully converted to the table's columns, an
> error is raised.

That depends.  If the code can be made more verbose with more details
depending on the error path reached without blowing up the whole COPY,
knowing more about the incorrect state of a row without extending
ON_ERROR with a new mode seems useful to me.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Large expressions in indexes can't be stored (non-TOASTable)
Next
From: Junwang Zhao
Date:
Subject: Typo in multixact.c and jsonfuncs.c documentation