Annotation of embedaddon/sqlite3/test/eval.test, revision 1.1.1.1
1.1 misho 1: # 2008 July 11
2: #
3: # The author disclaims copyright to this source code. In place of
4: # 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 function
14: # 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:
18: set testdir [file dirname $argv0]
19: source $testdir/tester.tcl
20:
21: # Create a table to work with.
22: #
23: do_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}
39: do_test eval-1.2 {
40: execsql {
41: SELECT x, test_eval('SELECT max(x) FROM t1 WHERE x<' || x) FROM t1 LIMIT 5
42: }
43: } {1 {} 2 1 3 2 4 3 5 4}
44:
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.
48: #
49: do_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 {} {}}
56: do_test eval-2.2 {
57: execsql {
58: SELECT * FROM t2
59: }
60: } {}
61:
62: # Modify a row while it is being read.
63: #
64: do_test eval-3.1 {
65: execsql {
66: INSERT INTO t2 SELECT x, x+1 FROM t1 WHERE x<5;
67: SELECT x, test_eval('UPDATE t2 SET y=y+100 WHERE x='||x), y FROM t2;
68: }
69: } {1 {} 102 2 {} 103 3 {} 104 4 {} 105}
70:
71: do_test eval-4.1 {
72: execsql { SELECT test_eval('SELECT "abcdefghij"') }
73: } {abcdefghij}
74:
75: finish_test
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>