Re: Syntax error in a large COPY

From: Dimitri Fontaine <dfontaine(at)hi-media(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Reg Me Please <regmeplease(at)gmail(dot)com>, "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
Subject: Re: Syntax error in a large COPY
Date: 2007-11-06 22:10:57
Message-ID: 200711062310.58215.dfontaine@hi-media.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

Le Tuesday 06 November 2007 22:40:50 Tom Lane, vous avez écrit :
> Reg Me Please <regmeplease(at)gmail(dot)com> writes:
> > I'm trying to understand what and where.
> > The point is that I have this 29M+ lines script telling me there's a
> > problem somewhere.

You could use pgloader, which reads CSV input (or text which is not quite CSV)
and will import valid rows and reject invalid ones, filling both a reject log
file with error messages and a rejected data file with bad input lines.
Basically, it will issue the dichotomy steps (branch and bound) for you.
http://pgfoundry.org/projects/pgloader
http://pgloader.projects.postgresql.org/

> It told you exactly where it detected the problem.
>
> Actually ... are you looking at the right error message? If this is a
> copy operation within a larger psql script, I think it's probably true
> that psql will point at the end of the copy data, because *it* doesn't
> know any better. But the error message from the backend should
> correctly finger which line of copy input it got confused at.

Or just use the server logged error message, which will be the same as
reported by pgloader (no magic here) --- pgloader will import successfully
the rest of the data and have the faulty lines separated out in the reject
file, but still uses COPY internally.

Hope this helps,
--
dim

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Erik Jones 2007-11-06 22:18:41 Re: subversion support?
Previous Message Thomas Kellerer 2007-11-06 22:05:18 Re: Syntax error in a large COPY