Hi,
I'm writing some code for asychronous command processing and I experience
the following problem. Everything seems to be OK (by following the
documentation) until I call PQisBusy(). While PQconsumeInput() returns 1,
PQisBusy() always returns 1! This is the code:
-------------------------------------------------------------------------
....
// conn is the connection already established in a nonblocking way
//(this is OK, I checked it with sychronous command processing)
PQsetnonblocking(conn,1);
//A simple query for now...
sql = "select * from t1";
if (PQsendQuery(conn,sql)!=1)
elog(ERROR,"Something went wrong with PQsendQuery....");
PQflush(conn);
sock = PQsocket(conn);
if (sock < 0)
break;
FD_ZERO(&input_mask);
FD_SET(sock, &input_mask);
if (select(sock + 1, &input_mask, NULL, NULL,NULL) < 0)
elog(ERROR,"Nothing comes to my socket!");
if (PQconsumeInput(conn)!=1) elog(ERROR,"Error in consume...");
else
{
elog(INFO,"OK with PQconsumeInput");
//Will use a cursor and 'while' later when this
//will have been fixed...
if (!PQisBusy(conn))
{
res=PQgetResult(conn);
}
else elog(INFO,"It is too busy to give me the results!");
}
...
-------------------------------------------------------------------------
If I discard PQisBusy the results are retreived without problems.
This code is used inside a SRF that is intended to return tuples from remote
dbs (as in dblink). For the time being I query local tables.
I use v7.4.2.
Is this something too obvious to see it :-) ? Is it something with
nonblocking connection establishment? Any suggestions?
Thanks in advance,
Ntinos Katsaros