Re: psql COPY vs. ON_ERROR_ROLLBACK, multi-command strings - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: psql COPY vs. ON_ERROR_ROLLBACK, multi-command strings
Date
Msg-id 1331564960-sup-8481@alvh.no-ip.org
Whole thread Raw
In response to Re: psql COPY vs. ON_ERROR_ROLLBACK, multi-command strings  (Noah Misch <noah@leadboat.com>)
List pgsql-hackers
Excerpts from Noah Misch's message of jue mar 08 12:11:37 -0300 2012:
>
> On Wed, Mar 07, 2012 at 04:57:12PM -0500, Robert Haas wrote:

> > As a side note, the documentation for PQexec() is misleading about
> > what will happen if COPY is present in a multi-command string.  It
> > says: "Note however that the returned PGresult structure describes
> > only the result of the last command executed from the string. Should
> > one of the commands fail, processing of the string stops with it and
> > the returned PGresult describes the error condition.  It does not
> > explain that it also stops if it hits a COPY.  I had to read the
> > source code for libpq to understand why this psql logic was coded the
> > way it is.
>
> Agreed; I went through a similar process.  Awhile after reading the code, I
> found the behavior documented in section "Functions Associated with the COPY
> Command":
>
>   If a COPY command is issued via PQexec in a string that could contain
>   additional commands, the application must continue fetching results via
>   PQgetResult after completing the COPY sequence. Only when PQgetResult
>   returns NULL is it certain that the PQexec command string is done and it is
>   safe to issue more commands.
>
> I'm not quite sure what revision would help most here -- a cross reference,
> moving that content, duplicating that content.  Offhand, I'm inclined to move
> it to the PQexec() documentation with some kind of reference back from its
> original location.  Thoughts?

I would vote for moving it and adding a reference in the COPY functions
section.  That way, the PQexec doc is complete by itself without having
to duplicate anything.

--
Álvaro Herrera <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [v9.2] Add GUC sepgsql.client_label
Next
From: Kohei KaiGai
Date:
Subject: Re: [v9.2] Add GUC sepgsql.client_label