Re: Timely reporting of COPY errors

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Postgresql <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Timely reporting of COPY errors
Date: 2008-04-17 13:28:31
Message-ID: 20080417132831.GV4999@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

* Martijn van Oosterhout (kleptog(at)svana(dot)org) wrote:
> On Wed, Apr 16, 2008 at 05:22:17PM -0400, Tom Lane wrote:
> > 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.

erm, maybe I'm missing something here, but psql could certainly stop
reading the file it was given on a \copy line when an error on the
backend happens. I agree that a user doing a copy-from-stdin wouldn't
be able to have it stop, though it'd go alot faster if it's just psql
throwing away data rather than it being sent across the network. Also,
imv, we should consider adding a 'stdin' option to \copy to let psql
know that it's ok to error-out if it starts to get errors from the
backend.

Admittedly, I do use "zcat | psql -c "copy ... from stdin" quite a bit,
but I'd be extremely happy to change that, in pretty much any way
necessary, to make it so that psql just exit's when the backend starts
reporting errors. Actually, ideally psql would just say "oh, this is a
-c command, not a script anyway, so I can error out if that command
starts to fail for whatever reason".

Thanks,

Stephen

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2008-04-17 13:30:04 Re: get rid of psql welcome message
Previous Message Simon Riggs 2008-04-17 13:27:09 Re: get rid of psql welcome message