Re: Is PQgetResult() guaranteed to return the whole SQL commandresult? - Mailing list pgsql-docs

From Peter Eisentraut
Subject Re: Is PQgetResult() guaranteed to return the whole SQL commandresult?
Date
Msg-id f2f8adbf-d6e9-4e49-06b6-d1765a101ccf@2ndquadrant.com
Whole thread Raw
In response to Is PQgetResult() guaranteed to return the whole SQL command result?  (Arseny Sher <a.sher@postgrespro.ru>)
Responses Re: Is PQgetResult() guaranteed to return the whole SQL command result?
List pgsql-docs
On 12/13/17 08:50, Arseny Sher wrote:
> I wonder is it guaranteed that one PQgetResult() call returns result for
> the whole one statement (SQL command) in usual (not SingleRow) mode?
> For instance, if I run PQsendQuery with query consisting of two
> statements (separated by semicolons), is possible to have three or more
> PQgetResult calls returning data? I guess not, but it seems to be not
> clear from the docs.
> 
> PQgetResult description says:
> 
> Waits for the next result from a prior call...
> 
> Does one "result" here correspond to one statement?

If you PQsendQuery() a string consisting of multiple statements (e.g.,
"SELECT 1; SELECT 2;"), you will have to call PQgetResult() twice to get
two result sets.  The third call will return NULL indicating that there
are not more result sets.

Are you asking whether it is possible that the results for the two
statements might be split across more than two libpq result sets?  That
is not possible.

But there is a possible future feature that a single command could
produce more than one result set.  So it is not necessarily the case
that the number of statements equals the number of result sets.  But the
relationship should always be deterministic.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


pgsql-docs by date:

Previous
From: Arseny Sher
Date:
Subject: Is PQgetResult() guaranteed to return the whole SQL command result?
Next
From: Arseny Sher
Date:
Subject: Re: Is PQgetResult() guaranteed to return the whole SQL command result?