Hi,

I would like to submit the following patch for inclusion in the next release of DBD::Pg:

http://staff.oxado.com/~jc/patch.dbd-pg.async+cancel

This pretty much trivial patch adds 5 new methods:
$sth->pg_sendquery is equivalent to $sth->execute, but only sends the request, and does not wait for the results
$sth->pg_getresult handles the results
$dbh->pg_busy tells if $sth->getresult will block
$dbh->pg_consume handles incoming data from the server
$dbh->pg_cancel cancels the existing query

pg_sendquery and pg_getresult are really just a split of the existing execute method, using PQsendQuery* calls then PQgetResult rather than the original PQexec* calls. The original execute function now just successively calls both methods (it avoids a lot of code duplication). Apparently the PQsenqQuery* functions have been there for quite a while so I believe it should work in all cases, but if they don't leaving the execute function untouched is always an option.

I have tested a few simple scenarios, but haven't tried it in production yet, so I can't vouch for the validity of the code, but the changes are quite minimal and straightforward so I don't expect much complication.

Any comments welcome.

Jacques.

Reply via email to