Re: Practical error logging for very large COPY - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Practical error logging for very large COPY
Date
Msg-id 11335.1132671524@sss.pgh.pa.us
Whole thread Raw
In response to Re: Practical error logging for very large COPY  (Simon Riggs <simon@2ndquadrant.com>)
Responses Re: Practical error logging for very large COPY
List pgsql-hackers
Simon Riggs <simon@2ndquadrant.com> writes:
> I have committed the sin of omission again.

> Duplicate row violation is the big challenge, but not the only function
> planned. Formatting errors occur much more frequently, so yes we'd want
> to log all of that too. And yes, it would be done in the way you
> suggest.

> Here's a fuller, but still brief sketch:

> COPY ... FROM ....
>     [ERRORTABLES format1 [uniqueness1]
>      [ERRORLIMIT percent]]


This is getting worse, not better :-(

The general problem that needs to be solved is "trap any error that
occurs during attempted insertion of a COPY row, and instead of aborting
the copy, record the data and the error message someplace else".  Seen
in that light, implementing a special path for uniqueness violations is
pretty pointless.

You could almost do this today in about five minutes with a PG_TRY
construct.  The hard part is to distinguish errors that COPY can safely
trap from errors that must be allowed to abort the transaction anyway
(usually because the backend won't be in a consistent state if it's not
allowed to do post-abort cleanup).  I think the latter class would
mostly be "internal" errors, and so not trapping them shouldn't be a big
problem for usefulness; but we can't simply ignore the possibility that
they would occur during COPY.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: order by, for custom types
Next
From: Grzegorz Jaskiewicz
Date:
Subject: Re: order by, for custom types