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

Re: psql copy errors

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: David Bear <David(dot)Bear(at)asu(dot)edu>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: psql copy errors
Date: 2005-06-23 20:17:16
Message-ID: 20050623201715.GA38419@winnie.fuhr.org (view raw or flat)
Thread:
Lists: pgsql-admin
On Thu, Jun 23, 2005 at 12:27:44PM -0700, David Bear wrote:
>
> I'm finding the \copy is very brittle. It seems to stop for everyone
> little reason. Is there a way to tell it to be more forgiving -- for
> example, to ignore extra data fields that might exists on a line?
> 
> Or, to have it just skip that offending record but continue on to the
> next.

Calling this behavior "brittle" is debatable; some people would
call it "reliable": either the whole input validates -- matches
what's expected -- or the command rejects it.  This might sound
unreasonable if a partial load is acceptable, but it's desirable
behavior if a partial load is unacceptable.  Some would argue that
the correct solution is to fix the data, not to make the command
that loads the data more forgiving.

The developers' TODO list has a few outstanding items to enhance
COPY, but I don't know if anybody's working on them:

http://www.postgresql.org/docs/faqs.TODO.html

* Allow COPY to report error lines and continue
  This requires the use of a savepoint before each COPY line is processed,
  with ROLLBACK on COPY failure.

* Have COPY return the number of rows loaded/unloaded (?)

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

pgsql-admin by date

Next:From: Simon RiggsDate: 2005-06-23 21:40:44
Subject: Re: restoring wal archive and pg_xlog dir
Previous:From: David BearDate: 2005-06-23 19:27:44
Subject: psql copy errors

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