[yunqa.de] Re: SQLiteSpy: no way to stop the query

  • From: Миронов Леонид <l.mironov@xxxxxxx>
  • To: "yunqa@xxxxxxxxxxxxx" <yunqa@xxxxxxxxxxxxx>
  • Date: Mon, 17 Jun 2019 10:45:58 +0000

Damn, you made me feel stupid :) I tried all sorts of key combinations - ^c, 
^break... Still, the fact that it throws an exception if closed while the query 
is running is not cool.

And yes, you are quite correct, in production one does things the proper way, 
but for me SQLiteSpy is not a production but a debugging tool I use to poke 
around databases using hastily coded queries, and sometimes shit happens.

-----Original Message-----
From: yunqa-bounce@xxxxxxxxxxxxx <yunqa-bounce@xxxxxxxxxxxxx> On Behalf Of 
Delphi Inspiration
Sent: Monday, June 17, 2019 12:05 PM
To: yunqa@xxxxxxxxxxxxx
Subject: [!!Mass Mail][yunqa.de] Re: SQLiteSpy: no way to stop the query

Your recursive Common Table Expression (CTE) lacks a limit or where clause. 
Without a limit or where clause, recursive CTEs generate an unlimited number of 
rows. They take SQLiteSpy forever to display.

To remedy this, SQLiteSpy allows to abort any query by pressing the [ESC] key. 
The [ESC] key triggers sqlite3_interrupt(), which aborts the query and returns 
as early as possible. SQLiteSpy then displays all records which the SQLite 
engine has produced so far.

The [ESC] key cancels any kind of queries, not just recursive CTEs. This makes 
the [ESC] key ideal for testing, especially queries which generate lots of 
output or just take a long time to run.

In production, you might want to make sure you add a limit clause to your 
recursive CTE so your application does not stall.

This example takes SQLiteSpy about 30 ms and never produces more than
10000 rows:

WITH RECURSIVE r(i) AS (
     values(0)
     UNION ALL SELECT i+1 AS x FROM r limit 10000
) SELECT * FROM r

Ralf

On 13.06.2019 12:39, Миронов Леонид wrote:

You may use the following infinitely looping code for testing

WITH RECURSIVE r(i) AS (
     values(0)
     UNION ALL SELECT i+1 AS x FROM r
) SELECT * FROM r
_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: