PQgetResult() and NULL - Mailing list pgsql-novice

From bradg
Subject PQgetResult() and NULL
Date
Msg-id 1457707980874-5892227.post@n5.nabble.com
Whole thread Raw
Responses Re: PQgetResult() and NULL
List pgsql-novice
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.


pgsql-novice by date:

Previous
From: Sherrie Kubis
Date:
Subject: Re: Getting started - pgadmin3
Next
From: bradg
Date:
Subject: Re: PQgetResult() and NULL