Extension Wraping functions with ability to throw error and abort query
Does anyone know of a wrapper extension which has a function wrapping other functions to monitor the time that has passed and if it exceeds an argument value it throws an error or interrupt and aborts the query? I am using the JSON1 extension and periodically I write a bad query and the database freezes and stops working. Something like select watcher_function(json_extracts(arguments), 30) from table.. where 30 would be the number of seconds the json_extract function could run or abort. On the desktop you can use cmd-c, however, I am not using the command-line tools.
Thanks for the input
Do you know about sqlite3_interrupt()?
I do, was hoping someone might have already created the extension, my c skills are rusty at best. I thought about trying to tweak the json extension but thought there might be a more reusable way.
Define database freezes and stops working. The only way to recover from an Operating System crash is to reboot the computer.
Or do you mean that, like Spock, you asked the computer to calculate the value of Pi to the last decimal place and then report the answer and it is off busily complying with your request (that is, it has neither frozen nor stopped working, it is just very busy trying to do what you told it to do).
Exactly like Spock. I do have the occasional overloading of the Enterprise due to memory constraints but likely that happens after a little while. If a query doesn't return in 20 seconds or less it's typically throwaway and I messed up. Trying to do it more gracefully and keep marching
You should take a look at https://sqlite.org/c3ref/progress_handler.html which you can use to have the database engine callback your code periodically while executing a VDBE program. If it finds that the execution has taken too long it can issue an sqlite3_interrupt on the connection.