Re: Is PQgetResult() guaranteed to return the whole SQL commandresult?
От | Peter Eisentraut |
---|---|
Тема | Re: Is PQgetResult() guaranteed to return the whole SQL commandresult? |
Дата | |
Msg-id | f2f8adbf-d6e9-4e49-06b6-d1765a101ccf@2ndquadrant.com обсуждение исходный текст |
Ответ на | Is PQgetResult() guaranteed to return the whole SQL command result? (Arseny Sher <a.sher@postgrespro.ru>) |
Ответы |
Re: Is PQgetResult() guaranteed to return the whole SQL command result?
|
Список | 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 по дате отправления: