Re: PQisBusy() always returns TRUE - Mailing list pgsql-general

From ntinos@aueb.gr
Subject Re: PQisBusy() always returns TRUE
Date
Msg-id courier.41E9740B.00002F13@red.servers.aueb.gr
Whole thread Raw
In response to Re: PQisBusy() always returns TRUE  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: PQisBusy() always returns TRUE
List pgsql-general
If understand correctly what you are saying, the right code for this thing
is:

PQconsumeInput(conn);        //Try to collect the results
while (PQisBusy(conn))       // while not ready ...
    PQconsumeInput(conn); //...retry

res=PQgetResult(conn);       // Now get the results

I tried this and it worked. However, the problem now is that it is slow
(surely slower than using blocking commands).
If the code above is right (?), why is that?

Thanks for your response,
Ntinos Katsaros

Tom Lane writes:

> ntinos@aueb.gr writes:
>>        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!");
>>        }
>
> PQconsumeInput has to be part of the loop.  PQisBusy doesn't change any
> state, it just tells you whether PQconsumeInput has collected a complete
> query result yet.
>
>             regards, tom lane



pgsql-general by date:

Previous
From: Berteun Damman
Date:
Subject: Re: Pgsql taking a *lot* of CPU time (unkillable).
Next
From: MargaretGillon@chromalloy.com
Date:
Subject: pg_dump shell script with ~/.pgpass