Hello,
I'm trying to create a plugin using the libpq.

Almost everything is working, and now I want to implememt the asynchronous 
issue.

I send the SQL using the PQsendQuery, and my interface is not blocking, great.

Now, everytime I check fot the PQgetResult my interface gets blocked.

So, now I'm using the PQisBusy to check if postgre is still busy and I can 
safely call the PQgetResult wihtout blocking, or just wait *some time* before 
sending a new PQisBusy.

Before every PQisBusy i call PQconsumeInput to update the status.

So, in pseudo code:


1. PQsendQuery (a really slow select just to check the asyncronous)

2. From a timer every 0.2 seconds, I call:
2.1 PQconsumeInput
2.2 PQisBusy
2.3 evaluate => if it's busy => sleep and start again from 2 ; if it's not 
busy, continue
2.4 call PQgetResult

Using PQisBusy it's not working, it's taking really longer to just send the 0 
(non-busy) and at this moment the PQgetResult is null.

If I force to call the PQgetResult after just one second of the PQsendQuery I 
can get the PQgetResult, without testing the PQisBusy.


here is my montxPG_isBusy

static long montxPG_isBusy()

{       int execStatus;
        int consumeeVar;
        
        consumeeVar = PQconsumeInput(gPGconn);
        
        if (consumeeVar == 0) return (long) PGRES_FATAL_ERROR;
                
                execStatus = PQisBusy(gPGconn);
        
        return (long) execStatus;
        
}


thanks,

regards,

r.

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to