Re: pg_restore COPY error handling

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: pg_restore COPY error handling
Date: 2006-02-02 03:08:18
Message-ID: 7801.1138849698@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Stephen Frost <sfrost(at)snowman(dot)net> writes:
> I'd be happy to work this up, and I think it would work, but it seems
> kind of ugly since then we'd have ahwrite and ahprintf returning error
> codes which in 99% of the cases wouldn't be checked which doesn't seem
> terribly clean. :/

I agree. I wonder if it wouldn't be cleaner to pass the information in
the other direction, ie, send a boolean down to PrintTocData saying "you
are sending SQL commands" or "you are sending COPY data". Then, instead
of depending only on the libpq state to decide what to do in
ExecuteSqlCommandBuf, we could cross-check: if we're sending SQL data
and the libpq state is wrong, just discard the line.

The immediate problem you saw is fairly clear at this point:
ExecuteSqlCommandBuf and its subroutines attempt to parse the data well
enough to determine command boundaries (if SQL commands) or line
boundaries (if COPY data). If they are misinformed about what they are
processing then the parsing gets totally confused --- it's not hard to
imagine the code thinking the entire COPY dump is an incomplete SQL
command. So driving this from an upper-level indication of what we are
currently sending, rather than libpq status, ought to be more robust.

BTW, we'd not need to mess with a ton of routine APIs to make this
happen --- just add a flag in ArchiveHandle.

regards, tom lane

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2006-02-02 04:48:45 Re: [BUGS] BUG #2171: Differences compiling plpgsql in ecpg and psql
Previous Message Bruce Momjian 2006-02-02 02:54:51 Re: pg_restore COPY error handling