PQisBusy() always returns TRUE

From: ntinos(at)aueb(dot)gr
To: pgsql-general(at)postgresql(dot)org
Subject: PQisBusy() always returns TRUE
Date: 2005-01-15 12:50:26
Message-ID: courier.41E91192.00007842@red.servers.aueb.gr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2005-01-15 15:07:43 Re: PostgreSQL v7.3.6
Previous Message Michael Fuhr 2005-01-15 12:46:11 Re: OID Usage