Add test cases to e_select.test.
FossilOrigin-Name: 9db26d5ef5a4c6f9fe0adf2ff306f6f07b6cc60c
This commit is contained in:
parent
96110deb6a
commit
8663d0fb80
24
manifest
24
manifest
@ -1,8 +1,5 @@
|
||||
-----BEGIN PGP SIGNED MESSAGE-----
|
||||
Hash: SHA1
|
||||
|
||||
C Remove\sproprietary\sinformation\sfrom\sthe\sreleasetest.tcl\sscript\sand\sadd\sit\nto\sthe\spublic\srepository.
|
||||
D 2010-09-06T18:44:14
|
||||
C Add\stest\scases\sto\se_select.test.
|
||||
D 2010-09-06T18:50:55
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in c599a15d268b1db2aeadea19df2adc3bf2eb6bee
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -352,7 +349,7 @@ F test/distinctagg.test 1a6ef9c87a58669438fc771450d7a72577417376
|
||||
F test/e_expr.test 164e87c1d7b40ceb47c57c3bffa384c81d009aa7
|
||||
F test/e_fkey.test 6721a741c6499b3ab7e5385923233343c8f1ad05
|
||||
F test/e_fts3.test 75bb0aee26384ef586165e21018a17f7cd843469
|
||||
F test/e_select.test f2469d2c2081610c3f85f2b85dda9026d343393f
|
||||
F test/e_select.test 0c491c94d69adad307fbd331530c012f64984b7a
|
||||
F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea
|
||||
F test/enc2.test 6d91a5286f59add0cfcbb2d0da913b76f2242398
|
||||
F test/enc3.test 5c550d59ff31dccdba5d1a02ae11c7047d77c041
|
||||
@ -859,14 +856,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
P 8b9d8c226e5d95584c1e61a796dc23b780a300cb
|
||||
R 98dea5240f80f8174c5125044e6828fb
|
||||
U drh
|
||||
Z 0392d0f0caa40596afb3d46f32529306
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1.4.6 (GNU/Linux)
|
||||
|
||||
iD8DBQFMhTaBoxKgR168RlERAn1UAJwNSxNdDB4M8CdfcOLn13Q/PByDLwCfTCOc
|
||||
2twVoGYmMf1gW4MdyOjJ5f0=
|
||||
=zO5S
|
||||
-----END PGP SIGNATURE-----
|
||||
P e1d4a87e4e195b3a217f6d8a15d6beceb7c22a53
|
||||
R 0534cdf52440ad0ba2335607dfae2462
|
||||
U dan
|
||||
Z 0301c14d315e0aaf5f3d743cbab168a6
|
||||
|
@ -1 +1 @@
|
||||
e1d4a87e4e195b3a217f6d8a15d6beceb7c22a53
|
||||
9db26d5ef5a4c6f9fe0adf2ff306f6f07b6cc60c
|
@ -51,6 +51,50 @@ set t1_cross_t1 [list \
|
||||
]
|
||||
|
||||
|
||||
# This proc is a specialized version of [do_execsql_test].
|
||||
#
|
||||
# The second argument to this proc must be a SELECT statement that
|
||||
# features a cross join of some time. Instead of the usual ",",
|
||||
# "CROSS JOIN" or "INNER JOIN" join-op, the string %JOIN% must be
|
||||
# substituted.
|
||||
#
|
||||
# This test runs the SELECT three times - once with:
|
||||
#
|
||||
# * s/%JOIN%/,/
|
||||
# * s/%JOIN%/INNER JOIN/
|
||||
# * s/%JOIN%/CROSS JOIN/
|
||||
#
|
||||
# and checks that each time the results of the SELECT are $res.
|
||||
#
|
||||
proc do_join_test {tn select res} {
|
||||
foreach {tn2 joinop} [list 1 , 2 "CROSS JOIN" 3 "INNER JOIN"] {
|
||||
set S [string map [list %JOIN% $joinop] $select]
|
||||
uplevel do_execsql_test $tn.$tn2 [list $S] [list $res]
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# The following tests check that all paths on the syntax diagrams on
|
||||
# the lang_select.html page may be taken.
|
||||
#
|
||||
# EVIDENCE-OF: R-18428-22111 -- syntax diagram join-constraint
|
||||
#
|
||||
do_join_test e_select-0.1.1 {
|
||||
SELECT count(*) FROM t1 %JOIN% t2 ON (t1.a=t2.a)
|
||||
} {3}
|
||||
do_join_test e_select-0.1.2 {
|
||||
SELECT count(*) FROM t1 %JOIN% t2 USING (a)
|
||||
} {3}
|
||||
do_join_test e_select-0.1.3 {
|
||||
SELECT count(*) FROM t1 %JOIN% t2
|
||||
} {9}
|
||||
do_catchsql_test e_select-0.1.4 {
|
||||
SELECT count(*) FROM t1, t2 ON (t1.a=t2.a) USING (a)
|
||||
} {1 {cannot have both ON and USING clauses in the same join}}
|
||||
do_catchsql_test e_select-0.1.5 {
|
||||
SELECT count(*) FROM t1, t2 USING (a) ON (t1.a=t2.a)
|
||||
} {1 {near "ON": syntax error}}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# The following tests focus on FROM clause (join) processing.
|
||||
#
|
||||
@ -105,10 +149,7 @@ foreach {tn select res} [list \
|
||||
FROM t1 %JOIN% t2 ON (CASE WHEN t1.a = 'a' THEN NULL ELSE 1 END) } \
|
||||
{two I two II two III three I three II three III} \
|
||||
] {
|
||||
foreach {tn2 joinop} [list 1 , 2 "CROSS JOIN" 3 "INNER JOIN"] {
|
||||
set S [string map [list %JOIN% $joinop] $select]
|
||||
do_execsql_test e_select-1.3.$tn.$tn2 $S $res
|
||||
}
|
||||
do_join_test e_select-1.3.$tn $select $res
|
||||
}
|
||||
|
||||
# EVIDENCE-OF: R-63358-54862 If there is a USING clause specified as
|
||||
@ -163,22 +204,155 @@ foreach {tn select res} {
|
||||
{aa cc cc bb DD dd}
|
||||
4 { SELECT * FROM t5 %JOIN% t6 USING (a,b) } {AA cc}
|
||||
5 { SELECT * FROM t6 %JOIN% t5 USING (a,b) } {}
|
||||
|
||||
} {
|
||||
foreach {tn2 joinop} [list 1 , 2 "CROSS JOIN" 3 "INNER JOIN"] {
|
||||
set S [string map [list %JOIN% $joinop] $select]
|
||||
do_execsql_test e_select-1.6.$tn.$tn2 $S $res
|
||||
}
|
||||
do_join_test e_select-1.6.$tn $select $res
|
||||
}
|
||||
|
||||
# EVIDENCE-OF: R-57047-10461 For each pair of columns identified by a
|
||||
# USING clause, the column from the right-hand dataset is omitted from
|
||||
# the joined dataset.
|
||||
#
|
||||
# EVIDENCE-OF: R-56132-15700 This is the only difference between a USING
|
||||
# clause and its equivalent ON constraint.
|
||||
#
|
||||
foreach {tn select res} {
|
||||
1a { SELECT * FROM t1 %JOIN% t2 USING (a) }
|
||||
{a one I b two II c three III}
|
||||
1b { SELECT * FROM t1 %JOIN% t2 ON (t1.a=t2.a) }
|
||||
{a one a I b two b II c three c III}
|
||||
|
||||
2a { SELECT * FROM t3 %JOIN% t4 USING (a) }
|
||||
{a 1 {} b 2 2}
|
||||
2b { SELECT * FROM t3 %JOIN% t4 ON (t3.a=t4.a) }
|
||||
{a 1 a {} b 2 b 2}
|
||||
|
||||
3a { SELECT * FROM t3 %JOIN% t4 USING (a,c) } {b 2}
|
||||
3b { SELECT * FROM t3 %JOIN% t4 ON (t3.a=t4.a AND t3.c=t4.c) } {b 2 b 2}
|
||||
|
||||
4a { SELECT * FROM (SELECT a COLLATE nocase, b FROM t6) AS x
|
||||
%JOIN% t5 USING (a) }
|
||||
{aa cc cc bb DD dd}
|
||||
4b { SELECT * FROM (SELECT a COLLATE nocase, b FROM t6) AS x
|
||||
%JOIN% t5 ON (x.a=t5.a) }
|
||||
{aa cc AA cc bb DD BB dd}
|
||||
} {
|
||||
do_join_test e_select-1.7.$tn $select $res
|
||||
}
|
||||
|
||||
# EVIDENCE-OF: R-04095-00676 If the join-op is a "LEFT JOIN" or "LEFT
|
||||
# OUTER JOIN", then the composite dataset is created as for an "INNER
|
||||
# JOIN". Except, after the ON or USING filtering clauses have been
|
||||
# applied, an extra row is added to the output for each row in the
|
||||
# original left-hand input dataset (if any) that corresponds to no rows
|
||||
# at all in the composite dataset.
|
||||
#
|
||||
do_execsql_test e_select-1.8.0 {
|
||||
CREATE TABLE t7(a, b, c);
|
||||
CREATE TABLE t8(a, d, e);
|
||||
|
||||
INSERT INTO t7 VALUES('x', 'ex', 24);
|
||||
INSERT INTO t7 VALUES('y', 'why', 25);
|
||||
|
||||
INSERT INTO t8 VALUES('x', 'abc', 24);
|
||||
INSERT INTO t8 VALUES('z', 'ghi', 26);
|
||||
} {}
|
||||
|
||||
do_execsql_test e_select-1.8.1a {
|
||||
SELECT count(*) FROM t7 JOIN t8 ON (t7.a=t8.a)
|
||||
} {1}
|
||||
do_execsql_test e_select-1.8.1b {
|
||||
SELECT count(*) FROM t7 LEFT JOIN t8 ON (t7.a=t8.a)
|
||||
} {2}
|
||||
|
||||
do_execsql_test e_select-1.8.2a {
|
||||
SELECT count(*) FROM t7 JOIN t8 USING (a)
|
||||
} {1}
|
||||
do_execsql_test e_select-1.8.2b {
|
||||
SELECT count(*) FROM t7 LEFT JOIN t8 USING (a)
|
||||
} {2}
|
||||
|
||||
# EVIDENCE-OF: R-15607-52988 The added rows contain NULL values in the
|
||||
# columns that would normally contain values copied from the right-hand
|
||||
# input dataset.
|
||||
#
|
||||
do_execsql_test e_select-1.9.1a {
|
||||
SELECT * FROM t7 JOIN t8 ON (t7.a=t8.a)
|
||||
} {x ex 24 x abc 24}
|
||||
do_execsql_test e_select-1.9.1b {
|
||||
SELECT * FROM t7 LEFT JOIN t8 ON (t7.a=t8.a)
|
||||
} {x ex 24 x abc 24 y why 25 {} {} {}}
|
||||
|
||||
do_execsql_test e_select-1.9.2a {
|
||||
SELECT * FROM t7 JOIN t8 USING (a)
|
||||
} {x ex 24 abc 24}
|
||||
do_execsql_test e_select-1.9.2b {
|
||||
SELECT * FROM t7 LEFT JOIN t8 USING (a)
|
||||
} {x ex 24 abc 24 y why 25 {} {}}
|
||||
|
||||
# EVIDENCE-OF: R-01809-52134 If the NATURAL keyword is added to any of
|
||||
# the join-ops, then an implicit USING clause is added to the
|
||||
# join-constraints. The implicit USING clause contains each of the
|
||||
# column names that appear in both the left and right-hand input
|
||||
# datasets.
|
||||
#
|
||||
foreach {tn s1 s2 res} {
|
||||
1 { SELECT * FROM t7 JOIN t8 USING (a) }
|
||||
{ SELECT * FROM t7 NATURAL JOIN t8 }
|
||||
{x ex 24 abc 24}
|
||||
|
||||
2 { SELECT * FROM t8 JOIN t7 USING (a) }
|
||||
{ SELECT * FROM t8 NATURAL JOIN t7 }
|
||||
{x abc 24 ex 24}
|
||||
|
||||
3 { SELECT * FROM t7 LEFT JOIN t8 USING (a) }
|
||||
{ SELECT * FROM t7 NATURAL LEFT JOIN t8 }
|
||||
{x ex 24 abc 24 y why 25 {} {}}
|
||||
|
||||
4 { SELECT * FROM t8 LEFT JOIN t7 USING (a) }
|
||||
{ SELECT * FROM t8 NATURAL LEFT JOIN t7 }
|
||||
{x abc 24 ex 24 z ghi 26 {} {}}
|
||||
|
||||
5 { SELECT * FROM t3 JOIN t4 USING (a,c) }
|
||||
{ SELECT * FROM t3 NATURAL JOIN t4 }
|
||||
{b 2}
|
||||
|
||||
6 { SELECT * FROM t3 LEFT JOIN t4 USING (a,c) }
|
||||
{ SELECT * FROM t3 NATURAL LEFT JOIN t4 }
|
||||
{a 1 b 2}
|
||||
} {
|
||||
do_execsql_test e_select-1.10.${tn}a $s1 $res
|
||||
do_execsql_test e_select-1.10.${tn}b $s2 $res
|
||||
}
|
||||
|
||||
# EVIDENCE-OF: R-49566-01570 If the left and right-hand input datasets
|
||||
# feature no common column names, then the NATURAL keyword has no effect
|
||||
# on the results of the join.
|
||||
#
|
||||
do_execsql_test e_select-1.11.0 {
|
||||
CREATE TABLE t10(x, y);
|
||||
INSERT INTO t10 VALUES(1, 'true');
|
||||
INSERT INTO t10 VALUES(0, 'false');
|
||||
} {}
|
||||
foreach {tn s1 s2 res} {
|
||||
1 { SELECT a, x FROM t1 CROSS JOIN t10 }
|
||||
{ SELECT a, x FROM t1 NATURAL CROSS JOIN t10 }
|
||||
{a 1 a 0 b 1 b 0 c 1 c 0}
|
||||
} {
|
||||
do_execsql_test e_select-1.11.${tn}a $s1 $res
|
||||
do_execsql_test e_select-1.11.${tn}b $s2 $res
|
||||
}
|
||||
|
||||
# EVIDENCE-OF: R-39625-59133 A USING or ON clause may not be added to a
|
||||
# join that specifies the NATURAL keyword.
|
||||
#
|
||||
foreach {tn sql} {
|
||||
1 {SELECT * FROM t1 NATURAL LEFT JOIN t2 USING (a)}
|
||||
2 {SELECT * FROM t1 NATURAL LEFT JOIN t2 ON (t1.a=t2.a)}
|
||||
3 {SELECT * FROM t1 NATURAL LEFT JOIN t2 ON (45)}
|
||||
} {
|
||||
do_catchsql_test e_select-1.12.$tn "
|
||||
$sql
|
||||
" {1 {a NATURAL join may not have an ON or USING clause}}
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user