Re: Timely reporting of COPY errors

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Postgresql <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Timely reporting of COPY errors
Date: 2008-04-16 22:20:01
Message-ID: 20080416222001.GC26340@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Apr 16, 2008 at 05:22:17PM -0400, Tom Lane wrote:
> I dunno about "intentional", but the API exposed by libpq for COPY
> doesn't really permit any other behavior: you push all the data and
> then look to see if it worked or not.

Oh? I expected the PQputData would return -1 as stated by the
documentation, at which point I would call PQendCopy and retrieve the
resultset.

> Even if we had some way of letting the application notice that the copy
> had already failed, I don't see that psql could do very much with it,
> at least not for COPY FROM STDIN. It's got to read through the source
> data anyway or it'll be out of sync with the script file.

psql could ignore the result of PQputData if it wanted, no big deal
there.

> We could possibly fix libpq to start dropping the data on the floor
> if it sees an error reply already pending, but that's only going
> to be an incremental change.

At the very least the documentation needs to be improved. For example,
no NOTICEs will be processed either *unless* there are enough to cause
the backend to block. At which point they will all be processed at
once. But the first step would be to get libpq to even notice the
error. I'm confused as to why PQconsumeInput doesn't work.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joshua D. Drake 2008-04-16 22:22:31 Re: Patch for Prevent pg_dump/pg_restore from being affected by statement_timeout
Previous Message Greg Sabino Mullane 2008-04-16 22:17:30 Re: Patch for Prevent pg_dump/pg_restore from being affected by statement_timeout