-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Abort running query #461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It is not possible to abort a running query in the current sql.js. Your best bet for the moment is to kill the worker. You could try to implement that using emscripten's pthread support and sqlite3_interrupt, but this would probably be a lot of work, make the library slower, require you to serve your pages with custom headers, and not work on all browsers... |
Note that you can interrupt a query between output rows, simply by not continuing to call I think there might be one way to do that with the current sql.js, though it is pretty limited. If you use The easiest way to implement and use this interrupting function would be to make it just return its argument: function interruptible(x) {
if (checkForInterrupt()) {
throw new Error('interrupt');
}
return x;
} Then just wrap one of the SELECT expressions in the SQL query: SELECT SUM(interruptible(x)) FROM my_large_view; Alternatively, if you're not opposed to forking sql.js and hacking the SQLite C source, you could find a spot in the SQLite code to insert a call to Javascript and conditionally return an error code (somewhere in the pager might work). Basically a similar approach as above but one that works with any query. |
Thanks @lovasoa and @rhashimoto great insight. I was able to make a sub select as a start time, use time in the main select, calculate the difference in time, then throw the Error which halted the query. Convoluted but worked. Thanks, hopefully over time it wont get so convoluted. |
Does anyone know how to abort a running query?
I added the sqlite3_interruput to SQL-JS, however since the underlying code is really synchronous, this really does nothing. I found an abort controller, issue with great discussion but without any outcome. There is a pragma busy-timeout which does not seem to abort the query. The only other method I have used is terminating the worker, however, then I have to reload the database.
Any thoughts?
The text was updated successfully, but these errors were encountered: