mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Added tests for the new IN operator optimizer and fixed a bug that the
new tests found. This completes the implementation of enhancement #63. (CVS 612) FossilOrigin-Name: 2a710e18176c486525f0abb06644a511a2cd1d7a
This commit is contained in:
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the use of indices in WHERE clases.
|
||||
#
|
||||
# $Id: where.test,v 1.6 2002/04/30 19:20:29 drh Exp $
|
||||
# $Id: where.test,v 1.7 2002/06/09 01:55:20 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -261,5 +261,87 @@ do_test where-4.4 {
|
||||
}
|
||||
} {99}
|
||||
|
||||
# Verify that IN operators in a WHERE clause are handled correctly.
|
||||
#
|
||||
do_test where-5.1 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE rowid IN (1,2,3,1234) order by 1;
|
||||
}
|
||||
} {1 0 4 2 1 9 3 1 16 0}
|
||||
do_test where-5.2 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE rowid+0 IN (1,2,3,1234) order by 1;
|
||||
}
|
||||
} {1 0 4 2 1 9 3 1 16 99}
|
||||
do_test where-5.3 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE w IN (-1,1,2,3) order by 1;
|
||||
}
|
||||
} {1 0 4 2 1 9 3 1 16 10}
|
||||
do_test where-5.4 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE w+0 IN (-1,1,2,3) order by 1;
|
||||
}
|
||||
} {1 0 4 2 1 9 3 1 16 99}
|
||||
do_test where-5.5 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE rowid IN
|
||||
(select rowid from t1 where rowid IN (-1,2,4))
|
||||
ORDER BY 1;
|
||||
}
|
||||
} {2 1 9 4 2 25 1}
|
||||
do_test where-5.6 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE rowid+0 IN
|
||||
(select rowid from t1 where rowid IN (-1,2,4))
|
||||
ORDER BY 1;
|
||||
}
|
||||
} {2 1 9 4 2 25 99}
|
||||
do_test where-5.7 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE w IN
|
||||
(select rowid from t1 where rowid IN (-1,2,4))
|
||||
ORDER BY 1;
|
||||
}
|
||||
} {2 1 9 4 2 25 7}
|
||||
do_test where-5.8 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE w+0 IN
|
||||
(select rowid from t1 where rowid IN (-1,2,4))
|
||||
ORDER BY 1;
|
||||
}
|
||||
} {2 1 9 4 2 25 99}
|
||||
do_test where-5.9 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE x IN (1,7) ORDER BY 1;
|
||||
}
|
||||
} {2 1 9 3 1 16 6}
|
||||
do_test where-5.10 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE x+0 IN (1,7) ORDER BY 1;
|
||||
}
|
||||
} {2 1 9 3 1 16 99}
|
||||
do_test where-5.11 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE y IN (6400,8100) ORDER BY 1;
|
||||
}
|
||||
} {79 6 6400 89 6 8100 99}
|
||||
do_test where-5.12 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE x=6 AND y IN (6400,8100) ORDER BY 1;
|
||||
}
|
||||
} {79 6 6400 89 6 8100 74}
|
||||
do_test where-5.13 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE x IN (1,7) AND y NOT IN (6400,8100) ORDER BY 1;
|
||||
}
|
||||
} {2 1 9 3 1 16 6}
|
||||
do_test where-5.14 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE x IN (1,7) AND y IN (9,10) ORDER BY 1;
|
||||
}
|
||||
} {2 1 9 6}
|
||||
|
||||
|
||||
|
||||
finish_test
|
||||
|
Reference in New Issue
Block a user