sl@0: # 2008 July 11 sl@0: # sl@0: # The author disclaims copyright to this source code. In place of sl@0: # a legal notice, here is a blessing: sl@0: # sl@0: # May you do good and not evil. sl@0: # May you find forgiveness for yourself and forgive others. sl@0: # May you share freely, never taking more than you give. sl@0: # sl@0: #*********************************************************************** sl@0: # This file implements regression tests for SQLite library. sl@0: # sl@0: # This file experiments with recursion using the "test_eval()" SQL function sl@0: # in order to make sure that SQLite is reentrant. sl@0: # sl@0: # $Id: eval.test,v 1.1 2008/07/11 21:02:54 drh Exp $ sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: sl@0: # Create a table to work with. sl@0: # sl@0: do_test eval-1.1 { sl@0: execsql { sl@0: CREATE TABLE t1(x INTEGER PRIMARY KEY); sl@0: INSERT INTO t1 VALUES(1); sl@0: INSERT INTO t1 VALUES(2); sl@0: INSERT INTO t1 SELECT x+2 FROM t1; sl@0: INSERT INTO t1 SELECT x+4 FROM t1; sl@0: INSERT INTO t1 SELECT x+8 FROM t1; sl@0: INSERT INTO t1 SELECT x+16 FROM t1; sl@0: INSERT INTO t1 SELECT x+32 FROM t1; sl@0: INSERT INTO t1 SELECT x+64 FROM t1; sl@0: INSERT INTO t1 SELECT x+128 FROM t1; sl@0: INSERT INTO t1 SELECT x+256 FROM t1; sl@0: SELECT count(*), max(x) FROM t1; sl@0: } sl@0: } {512 512} sl@0: do_test eval-1.2 { sl@0: execsql { sl@0: SELECT x, test_eval('SELECT max(x) FROM t1 WHERE x<' || x) FROM t1 LIMIT 5 sl@0: } sl@0: } {1 {} 2 1 3 2 4 3 5 4} sl@0: sl@0: # Delete a row out from under a read cursor in the middle of sl@0: # collecting the arguments for a single row in a result set. sl@0: # Verify that subsequent rows come out as NULL. sl@0: # sl@0: do_test eval-2.1 { sl@0: execsql { sl@0: CREATE TABLE t2(x,y); sl@0: INSERT INTO t2 SELECT x, x+1 FROM t1 WHERE x<5; sl@0: SELECT x, test_eval('DELETE FROM t2 WHERE x='||x), y FROM t2; sl@0: } sl@0: } {1 {} {} 2 {} {} 3 {} {} 4 {} {}} sl@0: do_test eval-2.2 { sl@0: execsql { sl@0: SELECT * FROM t2 sl@0: } sl@0: } {} sl@0: sl@0: # Modify a row while it is being read. sl@0: # sl@0: do_test eval-3.1 { sl@0: execsql { sl@0: INSERT INTO t2 SELECT x, x+1 FROM t1 WHERE x<5; sl@0: SELECT x, test_eval('UPDATE t2 SET y=y+100 WHERE x='||x), y FROM t2; sl@0: } sl@0: } {1 {} 102 2 {} 103 3 {} 104 4 {} 105} sl@0: sl@0: finish_test