Re: PQisBusy() always returns TRUE

Поиск
Список
Период
Сортировка
От ntinos@aueb.gr
Тема Re: PQisBusy() always returns TRUE
Дата
Msg-id courier.41E9740B.00002F13@red.servers.aueb.gr
обсуждение исходный текст
Ответ на Re: PQisBusy() always returns TRUE  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: PQisBusy() always returns TRUE  (Martijn van Oosterhout <kleptog@svana.org>)
Список 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 по дате отправления:

Предыдущее
От: Berteun Damman
Дата:
Сообщение: Re: Pgsql taking a *lot* of CPU time (unkillable).
Следующее
От: MargaretGillon@chromalloy.com
Дата:
Сообщение: pg_dump shell script with ~/.pgpass