Open krlmlr opened 8 years ago
Also need to make sure everything is cleaned up correctly if there is an interrupt. This is quite hard.
To me, it looks like we need to add the following methods to DBI:
dbWait(DBIResult)
dbFetchAsync(DBIResult)
dbSendQuery()
and dbSendUpdate()
(#20) can be non-blocking by default at the backend's choice, only dbFetch()
and dbWait()
and perhaps dbGetRowsAffected()
are blocking. Query cancellation would be done by dbClearResult()
.
I think this is backwards-compatible to the current specification.
On second thought, it's safer to be explicit and define dbSendQueryAsync()
and dbSendUpdateAsync()
. The default DBI implementation of dbSendQuery()
could be:
res <- dbSendQueryAsync(con, sql)
dbWait(res)
res
Similar for dbSendUpdate().
@krlmlr any update on the asynchronous methods?
I think in practice it's important to ensure at least that dbFetch()
and dbGetRowsAffected()
are safely interruptible. This means to me:
Rcpp::checkInterrupt()
calls.dbFetch()
and then calling dbFetch()
again should return the same results as a single call to dbFetch()
. Once data collection has started, the data should be part of the result object until returned.Once this is in place, adding a timeout means checking elapsed time with each checkInterrupt()
call, or perhaps scheduling a signal with timer_create()
.
This issue is about safe interruption of fetching, once the database has started delivering data. r-dbi/DBI#290 is about query cancellation, which looks like an entirely different problem.
Let's flesh this out in RPostgres.
select count(*) from a cross join a cross join a ...
Important for "big data" backends.