3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.
13 # This file experiments with recursion using the "test_eval()" SQL function
14 # in order to make sure that SQLite is reentrant.
16 # $Id: eval.test,v 1.2 2008/10/13 10:37:50 danielk1977 Exp $
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
21 # Create a table to work with.
25 CREATE TABLE t1(x INTEGER PRIMARY KEY);
26 INSERT INTO t1 VALUES(1);
27 INSERT INTO t1 VALUES(2);
28 INSERT INTO t1 SELECT x+2 FROM t1;
29 INSERT INTO t1 SELECT x+4 FROM t1;
30 INSERT INTO t1 SELECT x+8 FROM t1;
31 INSERT INTO t1 SELECT x+16 FROM t1;
32 INSERT INTO t1 SELECT x+32 FROM t1;
33 INSERT INTO t1 SELECT x+64 FROM t1;
34 INSERT INTO t1 SELECT x+128 FROM t1;
35 INSERT INTO t1 SELECT x+256 FROM t1;
36 SELECT count(*), max(x) FROM t1;
41 SELECT x, test_eval('SELECT max(x) FROM t1 WHERE x<' || x) FROM t1 LIMIT 5
43 } {1 {} 2 1 3 2 4 3 5 4}
45 # Delete a row out from under a read cursor in the middle of
46 # collecting the arguments for a single row in a result set.
47 # Verify that subsequent rows come out as NULL.
52 INSERT INTO t2 SELECT x, x+1 FROM t1 WHERE x<5;
53 SELECT x, test_eval('DELETE FROM t2 WHERE x='||x), y FROM t2;
55 } {1 {} {} 2 {} {} 3 {} {} 4 {} {}}
63 INSERT INTO t2 SELECT x, x+1 FROM t1 WHERE x<5;
64 SELECT x, test_eval('DELETE FROM t2 WHERE x='||x), y FROM t2
67 } {4 {} {} 3 {} {} 2 {} {} 1 {} {}}
74 # Modify a row while it is being read.
78 INSERT INTO t2 SELECT x, x+1 FROM t1 WHERE x<5;
79 SELECT x, test_eval('UPDATE t2 SET y=y+100 WHERE x='||x), y FROM t2;
81 } {1 {} 102 2 {} 103 3 {} 104 4 {} 105}
84 execsql { SELECT test_eval('SELECT ''abcdefghij''') }