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

View File

@ -1,5 +1,5 @@
C Change\sthe\simplementation\sof\sALTER\sTABLE\sso\sthat\sit\sdoes\snot\suse\sthe\sIN()\soperattor.\s(CVS\s2249)
D 2005-01-21T00:44:22
C Add\sa\snew\stest\sfile\sfor\ssubqueries.\s(CVS\s2250)
D 2005-01-21T02:34:44
F Makefile.in ffd81f5e926d40b457071b4de8d7c1fa18f39b5a
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1
@ -182,6 +182,7 @@ F test/select5.test 94db800bbeff2e426c0175e07f7a71d4617853b5
F test/select6.test c00d300d90f0ae3fa4e4f4336c71b2345bfa819c
F test/select7.test f567a61c3a8a91bdbb376c4525caec3fa0ea8cea
F test/sort.test 87882e6c72a75d45e98a1c802c1ded0eac557d85
F test/subquery.test 34ee5ea73751f880e4d9af9149bd9e14156347ae
F test/subselect.test ff3850d0aab1443dafa4ecbdab1d01e58e7b366d
F test/table.test b8b0bee2ac2f3d36a674bc68344c1bdd80e99a18
F test/tableapi.test b21ab097e87a5484bb61029e69e1a4e5c5e65ede
@ -270,7 +271,7 @@ F www/tclsqlite.tcl e73f8f8e5f20e8277619433f7970060ab01088fc
F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
F www/whentouse.tcl 3e522a06ad41992023c80ca29a048ae2331ca5bd
P d1166472fd17960eb3016f3d5d3bf44afc9f5bc8
R d3c76340d5c2b36ec4f3164c5b3ed7ff
U danielk1977
Z e8d416a6477130fce4f05937d70746ae
P 06887afb323fa1fb6988a136f96a456467cf7b2f
R db55597e35dc9a9288564c0678d66f41
U drh
Z 9ca18e5fa8587d49ad6cdd58c232af3c

View File

@ -1 +1 @@
06887afb323fa1fb6988a136f96a456467cf7b2f
de8ee3a29e1aafcfa05841cb44da0a05f0579596

58
test/subquery.test Normal file
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