os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/eval.test
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/eval.test	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,71 @@
     1.4 +# 2008 July 11
     1.5 +#
     1.6 +# The author disclaims copyright to this source code.  In place of
     1.7 +# a legal notice, here is a blessing:
     1.8 +#
     1.9 +#    May you do good and not evil.
    1.10 +#    May you find forgiveness for yourself and forgive others.
    1.11 +#    May you share freely, never taking more than you give.
    1.12 +#
    1.13 +#***********************************************************************
    1.14 +# This file implements regression tests for SQLite library.
    1.15 +#
    1.16 +# This file experiments with recursion using the "test_eval()" SQL function
    1.17 +# in order to make sure that SQLite is reentrant.
    1.18 +#
    1.19 +# $Id: eval.test,v 1.1 2008/07/11 21:02:54 drh Exp $
    1.20 +
    1.21 +set testdir [file dirname $argv0]
    1.22 +source $testdir/tester.tcl
    1.23 +
    1.24 +# Create a table to work with.
    1.25 +#
    1.26 +do_test eval-1.1 {
    1.27 +  execsql {
    1.28 +    CREATE TABLE t1(x INTEGER PRIMARY KEY); 
    1.29 +    INSERT INTO t1 VALUES(1);
    1.30 +    INSERT INTO t1 VALUES(2);
    1.31 +    INSERT INTO t1 SELECT x+2 FROM t1;
    1.32 +    INSERT INTO t1 SELECT x+4 FROM t1;
    1.33 +    INSERT INTO t1 SELECT x+8 FROM t1;
    1.34 +    INSERT INTO t1 SELECT x+16 FROM t1;
    1.35 +    INSERT INTO t1 SELECT x+32 FROM t1;
    1.36 +    INSERT INTO t1 SELECT x+64 FROM t1;
    1.37 +    INSERT INTO t1 SELECT x+128 FROM t1;
    1.38 +    INSERT INTO t1 SELECT x+256 FROM t1;
    1.39 +    SELECT count(*), max(x) FROM t1;
    1.40 +  }
    1.41 +} {512 512}
    1.42 +do_test eval-1.2 {
    1.43 +  execsql {
    1.44 +    SELECT x, test_eval('SELECT max(x) FROM t1 WHERE x<' || x) FROM t1 LIMIT 5
    1.45 +  }
    1.46 +} {1 {} 2 1 3 2 4 3 5 4}
    1.47 +
    1.48 +# Delete a row out from under a read cursor in the middle of
    1.49 +# collecting the arguments for a single row in a result set.
    1.50 +# Verify that subsequent rows come out as NULL.
    1.51 +#
    1.52 +do_test eval-2.1 {
    1.53 +  execsql {
    1.54 +    CREATE TABLE t2(x,y);
    1.55 +    INSERT INTO t2 SELECT x, x+1 FROM t1 WHERE x<5;
    1.56 +    SELECT x, test_eval('DELETE FROM t2 WHERE x='||x), y FROM t2;
    1.57 +  }
    1.58 +} {1 {} {} 2 {} {} 3 {} {} 4 {} {}}
    1.59 +do_test eval-2.2 {
    1.60 +  execsql {
    1.61 +    SELECT * FROM t2
    1.62 +  }
    1.63 +} {}
    1.64 +
    1.65 +# Modify a row while it is being read.
    1.66 +#
    1.67 +do_test eval-3.1 {
    1.68 +  execsql {
    1.69 +    INSERT INTO t2 SELECT x, x+1 FROM t1 WHERE x<5;
    1.70 +    SELECT x, test_eval('UPDATE t2 SET y=y+100 WHERE x='||x), y FROM t2;
    1.71 +  }
    1.72 +} {1 {} 102 2 {} 103 3 {} 104 4 {} 105}
    1.73 +
    1.74 +finish_test