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