Re: Return results for PQexec vs PQexecP*

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Greg Sabino Mullane <greg(at)turnstep(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Return results for PQexec vs PQexecP*
Date: 2006-05-17 12:53:05
Message-ID: 20060517125305.GE15180@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, May 17, 2006 at 12:45:17PM -0000, Greg Sabino Mullane wrote:
> 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.

The main problem with PQexec and co is that they don't really do very
well if a single query produces multiple result sets. I'm not sure if
it's defined whether you get the first or the last. In any case, if you
want all the result sets, you need to be looking at PQsendquery and co.

Have a ncie day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2006-05-17 13:35:31 Re: pg_dump and backslash escapes
Previous Message Greg Sabino Mullane 2006-05-17 12:45:17 Return results for PQexec vs PQexecP*