Re: Asynchronous Queries/libpq

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Keary Suska <hierophant(at)pcisys(dot)net>
Cc: Postgres-Interfaces <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: Asynchronous Queries/libpq
Date: 2006-03-31 23:56:08
Message-ID: 5576.1143849368@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Keary Suska <hierophant(at)pcisys(dot)net> writes:
> Is it that PQgetResult will return a full query result from a single
> command, and will only return NULL if there are no more commands that have
> not completed, therefore only needing to be called once per command in the
> dispatched query; or is it that PQgetResult must be repeatedly called for
> even a single command query, and that it will only return NULL after each
> command in the dispatched query has completed fully?

You need to loop until PQgetResult returns null, if you want to handle
multi-command strings (you'll get one PGresult per command). If you
know there's only going to be one result you might be able to get away
without a second PQgetResult call, but I wouldn't recommend it.

> Further, can we *always* assume that query results will be returned in the
> order they appear in the query dispatch?

Yes. The backend isn't going to execute commands in a query string
out-of-order.

regards, tom lane

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Danny Braniss 2006-04-04 15:09:24 PQconnectdb et.all.
Previous Message Keary Suska 2006-03-31 19:56:13 Asynchronous Queries/libpq