Add tests for the EXISTS operator to e_expr.test.
FossilOrigin-Name: 9f9a95cc80961b2733d34bd66cfccfbffb358ed6
This commit is contained in:
parent
b0c6a8884b
commit
4336cc45c5
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C If\sMEM_STATUS\sis\sdisabled,\savoid\sholding\sthe\sSTATIC_MEM\smutex\swhen\scalling\sthe\suser-defined\sxMalloc\smethod.\sHolding\sthe\smutex\scauses\sproblems\sfor\smemsys3\sand\smemsys5.
|
||||
D 2010-09-02T10:08:41
|
||||
C Add\stests\sfor\sthe\sEXISTS\soperator\sto\se_expr.test.
|
||||
D 2010-09-02T11:53:12
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in c599a15d268b1db2aeadea19df2adc3bf2eb6bee
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -346,7 +346,7 @@ F test/descidx2.test 9f1a0c83fd57f8667c82310ca21b30a350888b5d
|
||||
F test/descidx3.test fe720e8b37d59f4cef808b0bf4e1b391c2e56b6f
|
||||
F test/diskfull.test 0cede7ef9d8f415d9d3944005c76be7589bb5ebb
|
||||
F test/distinctagg.test 1a6ef9c87a58669438fc771450d7a72577417376
|
||||
F test/e_expr.test 401066cd26a992270dca0d38e4162e9a3dc158b1
|
||||
F test/e_expr.test 1d4437a740dcffa675aa33d50d3440be9805f922
|
||||
F test/e_fkey.test 6721a741c6499b3ab7e5385923233343c8f1ad05
|
||||
F test/e_fts3.test 75bb0aee26384ef586165e21018a17f7cd843469
|
||||
F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea
|
||||
@ -853,7 +853,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
P c90a68b77e03bb351a7781f1b9dea38f5f571dcf
|
||||
R 8ea9ea167aeaca9c298d5f0ede771876
|
||||
P 4f20f8ba73691c8a1dc33d2fcd1e793dd08f00a8
|
||||
R 56226584a3a9f449af1f96c66ab8d183
|
||||
U dan
|
||||
Z d79bb8b6ec3d7a429b2e5218ed3eb161
|
||||
Z 0980fdb8cedd555819cdc0c243aa9897
|
||||
|
@ -1 +1 @@
|
||||
4f20f8ba73691c8a1dc33d2fcd1e793dd08f00a8
|
||||
9f9a95cc80961b2733d34bd66cfccfbffb358ed6
|
107
test/e_expr.test
107
test/e_expr.test
@ -17,6 +17,17 @@ set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
source $testdir/malloc_common.tcl
|
||||
|
||||
|
||||
proc do_expr_test {tn expr type value} {
|
||||
uplevel do_execsql_test $tn [list "SELECT typeof($expr), $expr"] [
|
||||
list [list $type $value]
|
||||
]
|
||||
}
|
||||
|
||||
proc do_qexpr_test {tn expr value} {
|
||||
uplevel do_execsql_test $tn [list "SELECT quote($expr)"] [list $value]
|
||||
}
|
||||
|
||||
# Set up three global variables:
|
||||
#
|
||||
# ::opname An array mapping from SQL operator to an easy to parse
|
||||
@ -1399,15 +1410,6 @@ do_execsql_test e_expr-27.1.2 {
|
||||
typeof(CAST(4.5 as INTEGER)), CAST(4.5 as INTEGER)
|
||||
} {text UVU real 1.23 integer 4}
|
||||
|
||||
proc do_expr_test {tn expr type value} {
|
||||
uplevel do_execsql_test $tn [list "SELECT typeof($expr), $expr"] [
|
||||
list [list $type $value]
|
||||
]
|
||||
}
|
||||
proc do_qexpr_test {tn expr value} {
|
||||
uplevel do_execsql_test $tn [list "SELECT quote($expr)"] [list $value]
|
||||
}
|
||||
|
||||
# EVIDENCE-OF: R-27225-65050 If the value of <expr> is NULL, then
|
||||
# the result of the CAST expression is also NULL.
|
||||
#
|
||||
@ -1647,4 +1649,91 @@ db1 close
|
||||
db2 close
|
||||
db3 close
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test statements related to the EXISTS and NOT EXISTS operators.
|
||||
#
|
||||
catch { db close }
|
||||
file delete -force test.db
|
||||
sqlite3 db test.db
|
||||
|
||||
do_execsql_test e_expr-34.1 {
|
||||
CREATE TABLE t1(a, b);
|
||||
INSERT INTO t1 VALUES(1, 2);
|
||||
INSERT INTO t1 VALUES(NULL, 2);
|
||||
INSERT INTO t1 VALUES(1, NULL);
|
||||
INSERT INTO t1 VALUES(NULL, NULL);
|
||||
} {}
|
||||
|
||||
# EVIDENCE-OF: R-25588-27181 The EXISTS operator always evaluates to one
|
||||
# of the integer values 0 and 1.
|
||||
#
|
||||
# This statement is not tested by itself. Instead, all e_expr-34.* tests
|
||||
# following this point explicitly test that specific invocations of EXISTS
|
||||
# return either integer 0 or integer 1.
|
||||
#
|
||||
|
||||
# EVIDENCE-OF: R-58553-63740 If executing the SELECT statement specified
|
||||
# as the right-hand operand of the EXISTS operator would return one or
|
||||
# more rows, then the EXISTS operator evaluates to 1.
|
||||
#
|
||||
foreach {tn expr} {
|
||||
1 { EXISTS ( SELECT a FROM t1 ) }
|
||||
2 { EXISTS ( SELECT b FROM t1 ) }
|
||||
3 { EXISTS ( SELECT 24 ) }
|
||||
4 { EXISTS ( SELECT NULL ) }
|
||||
5 { EXISTS ( SELECT a FROM t1 WHERE a IS NULL ) }
|
||||
} {
|
||||
do_expr_test e_expr-34.2.$tn $expr integer 1
|
||||
}
|
||||
|
||||
# EVIDENCE-OF: R-19673-40972 If executing the SELECT would return no
|
||||
# rows at all, then the EXISTS operator evaluates to 0.
|
||||
#
|
||||
foreach {tn expr} {
|
||||
1 { EXISTS ( SELECT a FROM t1 WHERE 0) }
|
||||
2 { EXISTS ( SELECT b FROM t1 WHERE a = 5) }
|
||||
3 { EXISTS ( SELECT 24 WHERE 0) }
|
||||
4 { EXISTS ( SELECT NULL WHERE 1=2) }
|
||||
} {
|
||||
do_expr_test e_expr-34.3.$tn $expr integer 0
|
||||
}
|
||||
|
||||
# EVIDENCE-OF: R-35109-49139 The number of columns in each row returned
|
||||
# by the SELECT statement (if any) and the specific values returned have
|
||||
# no effect on the results of the EXISTS operator.
|
||||
#
|
||||
foreach {tn expr res} {
|
||||
1 { EXISTS ( SELECT * FROM t1 ) } 1
|
||||
2 { EXISTS ( SELECT *, *, * FROM t1 ) } 1
|
||||
3 { EXISTS ( SELECT 24, 25 ) } 1
|
||||
4 { EXISTS ( SELECT NULL, NULL, NULL ) } 1
|
||||
5 { EXISTS ( SELECT a,b,a||b FROM t1 WHERE a IS NULL ) } 1
|
||||
|
||||
6 { EXISTS ( SELECT a, a FROM t1 WHERE 0) } 0
|
||||
7 { EXISTS ( SELECT b, b, a FROM t1 WHERE a = 5) } 0
|
||||
8 { EXISTS ( SELECT 24, 46, 89 WHERE 0) } 0
|
||||
9 { EXISTS ( SELECT NULL, NULL WHERE 1=2) } 0
|
||||
} {
|
||||
do_expr_test e_expr-34.4.$tn $expr integer $res
|
||||
}
|
||||
|
||||
# EVIDENCE-OF: R-10645-12439 In particular, rows containing NULL values
|
||||
# are not handled any differently from rows without NULL values.
|
||||
#
|
||||
foreach {tn e1 e2} {
|
||||
1 { EXISTS (SELECT 'not null') } { EXISTS (SELECT NULL) }
|
||||
2 { EXISTS (SELECT NULL FROM t1) } { EXISTS (SELECT 'bread' FROM t1) }
|
||||
} {
|
||||
set res [db one "SELECT $e1"]
|
||||
do_expr_test e_expr-34.5.${tn}a $e1 integer $res
|
||||
do_expr_test e_expr-34.5.${tn}b $e2 integer $res
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test statements related to the IN and NOT IN operators.
|
||||
#
|
||||
|
||||
finish_test
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user