digital-fabric / extralite

Ruby on SQLite
http://www.rubydoc.info/gems/extralite
MIT License
255 stars 8 forks source link

add db.interrupt support for long running queries #13

Closed sitano closed 1 year ago

sitano commented 1 year ago

add db.interrupt support for long-running queries

t = Thread.new do
  sleep 0.5
  @db.interrupt
end

n = 2**31
# extralite::error: query was interrupted
assert_raises(Extralite::Error) {
  @db.query <<-SQL
    WITH RECURSIVE
      fibo (curr, next)
    AS
    ( SELECT 1,1
      UNION ALL
      SELECT next, curr+next FROM fibo
      LIMIT #{n} )
    SELECT curr, next FROM fibo LIMIT 1 OFFSET #{n}-1;
  SQL
}
t.join