Search Postgresql Archives

Re: PQisBusy() always returns TRUE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx 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 majordomo@xxxxxxxxxxxxxx)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux