Re: PQisBusy() always returns TRUE

From: ntinos(at)aueb(dot)gr
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: PQisBusy() always returns TRUE
Date: 2005-01-15 19:50:35
Message-ID: courier.41E9740B.00002F13@red.servers.aueb.gr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)aueb(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-01-15 20:08:20 Re: Pgsql taking a *lot* of CPU time (unkillable).
Previous Message Berteun Damman 2005-01-15 19:40:34 Re: Pgsql taking a *lot* of CPU time (unkillable).