Add a new test file for subqueries. (CVS 2250)

FossilOrigin-Name: de8ee3a29e1aafcfa05841cb44da0a05f0579596
This commit is contained in:
drh
2005-01-21 02:34:44 +00:00
parent 83715c3edd
commit 801845fb2d
3 changed files with 66 additions and 7 deletions
+58
View File
@@ -0,0 +1,58 @@
# 2005 January 19
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#*************************************************************************
# This file implements regression tests for SQLite library. The
# focus of this script is testing correlated subqueries
#
# $Id: subquery.test,v 1.1 2005/01/21 02:34:44 drh Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
do_test subquery-1.1 {
execsql {
BEGIN;
CREATE TABLE t1(a,b);
INSERT INTO t1 VALUES(1,2);
INSERT INTO t1 VALUES(3,4);
INSERT INTO t1 VALUES(5,6);
INSERT INTO t1 VALUES(7,8);
CREATE TABLE t2(x,y);
INSERT INTO t2 VALUES(1,1);
INSERT INTO t2 VALUES(3,9);
INSERT INTO t2 VALUES(5,25);
INSERT INTO t2 VALUES(7,49);
COMMIT;
}
execsql {
SELECT a, (SELECT y FROM t2 WHERE x=a) FROM t1 WHERE b<8
}
} {1 1 3 9 5 25}
do_test subquery-1.2 {
execsql {
UPDATE t1 SET b=b+(SELECT y FROM t2 WHERE x=a);
SELECT * FROM t1;
}
} {1 3 3 13 5 31 7 57}
do_test subquery-1.3 {
execsql {
SELECT b FROM t1 WHERE EXISTS(SELECT * FROM t2 WHERE y=a)
}
} {3}
do_test subquery-1.4 {
execsql {
SELECT b FROM t1 WHERE NOT EXISTS(SELECT * FROM t2 WHERE y=a)
}
} {13 31 57}
finish_test