Re: Return results for PQexec vs PQexecP* - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Return results for PQexec vs PQexecP*
Date
Msg-id 19727.1147876074@sss.pgh.pa.us
Whole thread Raw
In response to Return results for PQexec vs PQexecP*  ("Greg Sabino Mullane" <greg@turnstep.com>)
List pgsql-hackers
"Greg Sabino Mullane" <greg@turnstep.com> writes:
> Someone posted something on the DBD::Pg mailing list recently that
> made me wonder if the user's problem is more of a "don't do that"
> or something that may be solvable with a libpq or protocol change.

> Basically, the user has a rule which switches an insert to a select.
> They then want to run the insert, and pull the resulting tuples
> from it. This works fine when using PQexec, as it returns the latest
> result, which is PGRES_TUPLES_OK. However, when using the newer
> PQexec family (PQexecParams and PQexecPrepared), the only thing returned
> is PGRES_COMMAND_OK, which prevents the drawing of any subsequent tuples.

I'd call that a "don't do that" issue.  The newer protocol is
specifically designed to be more predictable than the old, and that
includes not returning tuples from statements that clearly shouldn't
return anything.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: PL/pgSQL 'i = i + 1' Syntax
Next
From: Tom Lane
Date:
Subject: Re: pg_dump and backslash escapes