Extension Wraping functions with ability to throw error and abort query
(1) By anonymous on 2021-06-21 19:52:01 [link] [source]
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
(2) By Richard Hipp (drh) on 2021-06-21 21:15:23 in reply to 1 [link] [source]
Do you know about sqlite3_interrupt()?
(3) By anonymous on 2021-06-21 21:55:57 in reply to 2 [link] [source]
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.
(4) By Keith Medcalf (kmedcalf) on 2021-06-21 23:48:03 in reply to 3 [link] [source]
Define database freezes and stops working. The only way to recover from an Operating System crash is to reboot the computer.
(5) By Keith Medcalf (kmedcalf) on 2021-06-21 23:53:08 in reply to 3 [link] [source]
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).
(6) By anonymous on 2021-06-22 00:29:10 in reply to 5 [source]
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
(7) By Keith Medcalf (kmedcalf) on 2021-06-22 01:38:17 in reply to 6 [link] [source]
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.
(8) By anonymous on 2021-06-22 23:11:52 in reply to 7 [link] [source]
Will do. This combined with the eval.c extension I think gets me where I am going. Thanks.