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:

[EMAIL PROTECTED] 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



---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to