Re: pg_restore COPY error handling

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: pg_restore COPY error handling
Date: 2006-01-20 20:21:20
Message-ID: 20060120202120.GJ6026@ns.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-patches

* Stephen Frost (sfrost(at)snowman(dot)net) wrote:
> * Tom Lane (tgl(at)sss(dot)pgh(dot)pa(dot)us) wrote:
> > Stephen Frost <sfrost(at)snowman(dot)net> writes:
> > > It seems like pg_restore really should be able to handle COPY errors
> > > correctly by skipping to the end of the COPY data segment when the
> > > initial COPY command comes back as an error.
> >
> > Send a patch ;-)
>
> This is what I get for knowing how to copy & paste C code, eh? ;-)
>
> Attached is a patch to pg_restore, against HEAD but I think it'd work
> against 8.1 just fine, to better handle it when a COPY command fails
> (for whatever reason) during a DB restore.
[...]
> Command was:
>
> COPY bg02_d00 (ogc_fid, wkb_geometry, area, perimeter, bg02_d00_, bg02_d00_i, state, county, tract, blkgroup, name, lsad, ...
> WARNING: errors ignored on restore: 7
> ------------------------

Of course, looking at this again, I'm afraid my COPY-attempt-detection
logic isn't quite enough. I was hoping it'd be taken care of by
_sendSQLLine, but apparently not.

The line:
if (strncasecmp(qry->data,"COPY ",5) == 0) AH->pgCopyIn = -1;

Needs to be changed to handle whitespace in front of the actual 'COPY',
unless someone else has a better idea. This should be reasonably
trivial to do though... If you'd like me to make that change and send
in a new patch, just let me know.

Thanks,

Stephen

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Andras Got 2006-01-21 00:53:37 BUG #2193: INITCAP and LOWER/UPPER string conversion error
Previous Message Stephen Frost 2006-01-20 20:13:44 [PATCH] pg_restore COPY error handling

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2006-01-20 21:32:42 Re: TODO-Item: include for guc
Previous Message Stephen Frost 2006-01-20 20:13:44 [PATCH] pg_restore COPY error handling