CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
eval.test88 linesDownload Raw Back to test
1# 2008 July 112#3# The author disclaims copyright to this source code.  In place of4# a legal notice, here is a blessing:5#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.9#10#***********************************************************************11# This file implements regression tests for SQLite library.12#13# This file experiments with recursion using the "test_eval()" SQL function14# in order to make sure that SQLite is reentrant.15#16# $Id: eval.test,v 1.2 2008/10/13 10:37:50 danielk1977 Exp $17 18set testdir [file dirname $argv0]19source $testdir/tester.tcl20 21# Create a table to work with.22#23do_test eval-1.1 {24  execsql {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;37  }38} {512 512}39do_test eval-1.2 {40  execsql {41    SELECT x, test_eval('SELECT max(x) FROM t1 WHERE x<' || x) FROM t1 LIMIT 542  }43} {1 {} 2 1 3 2 4 3 5 4}44 45# Delete a row out from under a read cursor in the middle of46# collecting the arguments for a single row in a result set.47# Verify that subsequent rows come out as NULL.48#49do_test eval-2.1 {50  execsql {51    CREATE TABLE t2(x,y);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;54  }55} {1 {} {} 2 {} {} 3 {} {} 4 {} {}}56do_test eval-2.2 {57  execsql {58    SELECT * FROM t259  }60} {}61do_test eval-2.3 {62  execsql {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 t265     ORDER BY rowid DESC;66  }67} {4 {} {} 3 {} {} 2 {} {} 1 {} {}}68do_test eval-2.4 {69  execsql {70    SELECT * FROM t271  }72} {}73 74# Modify a row while it is being read.75#76do_test eval-3.1 {77  execsql {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;80  }81} {1 {} 102 2 {} 103 3 {} 104 4 {} 105}82 83do_test eval-4.1 {84  execsql { SELECT test_eval('SELECT ''abcdefghij''') }85} {abcdefghij}86 87finish_test88