Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-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

pgsql-bugs by date

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

pgsql-patches by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group