Обсуждение: PQgetResult() and NULL

Поиск
Список
Период
Сортировка

PQgetResult() and NULL

От
bradg
Дата:
I am trying to handle asynchronous queries. My question relates to
PQgetResult() returning NULL.

Everything seems fine up until the point where I would expect PQgetResult()
to return NULL, but instead I get a result with a status of
PGRES_FATAL_ERROR and no error message on the connection or any of the
result error fields. When I poke the result for things like PQcmdStatus(), I
get nothing back. And if I keep calling PQgetResult() after that, I keep
getting the same kind of result and never NULL.

The connection status is CONNECTION_OK and the polling status is
PGRES_POLLING_OK the entire time, before and after I get the empty fatal
error results.
The transaction status, however, changes from PQTRANS_ACTIVE to PQTRANS_IDLE
when I would expect PQgetResult() to return NULL.

I am running version 9.5 on OS X 10.11. My code logic is pretty simple and
boilerplate from what I've seen on the web:
1- monitor the socket for reading
2- call PQconsumeInput()
3- if PQisBusy() wait for socket again
4- loop indefinitely... calling PQisBusy(), PQgetResult(), exit if result
NULL | process if result not NULL

Any insights would be helpful. Thanks.

Brad



--
View this message in context: http://postgresql.nabble.com/PQgetResult-and-NULL-tp5892227.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.


Re: PQgetResult() and NULL

От
bradg
Дата:
Finally figured out the problem...

I declared the variable for the PGresult outside the loop that calls
PQgetResult() until NULL.

When I moved the declaration inside, everything works as expected.



--
View this message in context: http://postgresql.nabble.com/PQgetResult-and-NULL-tp5892227p5892370.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.