Bring the sessions branch up-to-date with all the latest trunk changes.

FossilOrigin-Name: 086a127236ee99d67513490fb7b5549e8b752c44
This commit is contained in:
drh
2013-06-26 13:31:50 +00:00
186 changed files with 26930 additions and 3294 deletions
+1 -2
View File
@@ -39,6 +39,7 @@ run_test_suite pcache50
run_test_suite pcache90
run_test_suite pcache100
run_test_suite prepare
run_test_suite mmap
if {$::tcl_platform(platform)=="unix"} {
ifcapable !default_autovacuum {
@@ -47,5 +48,3 @@ if {$::tcl_platform(platform)=="unix"} {
}
finish_test
+9 -9
View File
@@ -97,10 +97,10 @@ do_test analyze3-1.1.1 {
do_eqp_test analyze3-1.1.2 {
SELECT sum(y) FROM t1 WHERE x>200 AND x<300
} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (x>? AND x<?) (~179 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (x>? AND x<?)}}
do_eqp_test analyze3-1.1.3 {
SELECT sum(y) FROM t1 WHERE x>0 AND x<1100
} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (x>? AND x<?) (~959 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (x>? AND x<?)}}
do_test analyze3-1.1.4 {
sf_execsql { SELECT sum(y) FROM t1 WHERE x>200 AND x<300 }
@@ -146,10 +146,10 @@ do_test analyze3-1.2.1 {
} {}
do_eqp_test analyze3-1.2.2 {
SELECT sum(y) FROM t2 WHERE x>1 AND x<2
} {0 0 0 {SEARCH TABLE t2 USING INDEX i2 (x>? AND x<?) (~196 rows)}}
} {0 0 0 {SEARCH TABLE t2 USING INDEX i2 (x>? AND x<?)}}
do_eqp_test analyze3-1.2.3 {
SELECT sum(y) FROM t2 WHERE x>0 AND x<99
} {0 0 0 {SEARCH TABLE t2 USING INDEX i2 (x>? AND x<?) (~968 rows)}}
} {0 0 0 {SEARCH TABLE t2 USING INDEX i2 (x>? AND x<?)}}
do_test analyze3-1.2.4 {
sf_execsql { SELECT sum(y) FROM t2 WHERE x>12 AND x<20 }
} {161 0 4760}
@@ -193,10 +193,10 @@ do_test analyze3-1.3.1 {
} {}
do_eqp_test analyze3-1.3.2 {
SELECT sum(y) FROM t3 WHERE x>200 AND x<300
} {0 0 0 {SEARCH TABLE t3 USING INDEX i3 (x>? AND x<?) (~156 rows)}}
} {0 0 0 {SEARCH TABLE t3 USING INDEX i3 (x>? AND x<?)}}
do_eqp_test analyze3-1.3.3 {
SELECT sum(y) FROM t3 WHERE x>0 AND x<1100
} {0 0 0 {SEARCH TABLE t3 USING INDEX i3 (x>? AND x<?) (~989 rows)}}
} {0 0 0 {SEARCH TABLE t3 USING INDEX i3 (x>? AND x<?)}}
do_test analyze3-1.3.4 {
sf_execsql { SELECT sum(y) FROM t3 WHERE x>200 AND x<300 }
@@ -248,10 +248,10 @@ do_test analyze3-2.1 {
} {}
do_eqp_test analyze3-2.2 {
SELECT count(a) FROM t1 WHERE b LIKE 'a%'
} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (b>? AND b<?) (~31250 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (b>? AND b<?)}}
do_eqp_test analyze3-2.3 {
SELECT count(a) FROM t1 WHERE b LIKE '%a'
} {0 0 0 {SCAN TABLE t1 (~500000 rows)}}
} {0 0 0 {SCAN TABLE t1}}
do_test analyze3-2.4 {
sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE 'a%' }
@@ -330,7 +330,7 @@ do_test analyze3-3.2.5 {
do_test analyze3-3.2.6 {
sqlite3_bind_text $S 1 "abc" 3
sqlite3_expired $S
} {0}
} {1}
do_test analyze3-3.2.7 {
sqlite3_finalize $S
} {SQLITE_OK}
+1 -1
View File
@@ -38,7 +38,7 @@ do_test analyze4-1.0 {
# Should choose the t1a index since it is more specific than t1b.
db eval {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=5 AND b IS NULL}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}
# Verify that the t1b index shows that it does not narrow down the
# search any at all.
+16 -16
View File
@@ -156,13 +156,14 @@ foreach {testid where index rows} {
} {
# Verify that the expected index is used with the expected row count
do_test analyze5-1.${testid}a {
set x [lindex [eqp "SELECT * FROM t1 WHERE $where"] 3]
set idx {}
regexp {INDEX (t1.) } $x all idx
regexp {~([0-9]+) rows} $x all nrow
list $idx $nrow
} [list $index $rows]
# No longer valid due to an EXPLAIN QUERY PLAN output format change
# do_test analyze5-1.${testid}a {
# set x [lindex [eqp "SELECT * FROM t1 WHERE $where"] 3]
# set idx {}
# regexp {INDEX (t1.) } $x all idx
# regexp {~([0-9]+) rows} $x all nrow
# list $idx $nrow
# } [list $index $rows]
# Verify that the same result is achieved regardless of whether or not
# the index is used
@@ -202,15 +203,14 @@ foreach {testid where index rows} {
} {
# Verify that the expected index is used with the expected row count
if {$testid==50299} {breakpoint; set sqlite_where_trace 1}
do_test analyze5-1.${testid}a {
set x [lindex [eqp "SELECT * FROM t1 WHERE $where"] 3]
set idx {}
regexp {INDEX (t1.) } $x all idx
regexp {~([0-9]+) rows} $x all nrow
list $idx $nrow
} [list $index $rows]
if {$testid==50299} exit
# No longer valid due to an EXPLAIN QUERY PLAN format change
# do_test analyze5-1.${testid}a {
# set x [lindex [eqp "SELECT * FROM t1 WHERE $where"] 3]
# set idx {}
# regexp {INDEX (t1.) } $x all idx
# regexp {~([0-9]+) rows} $x all nrow
# list $idx $nrow
# } [list $index $rows]
# Verify that the same result is achieved regardless of whether or not
# the index is used
+11 -11
View File
@@ -61,14 +61,14 @@ do_test analyze6-1.0 {
#
do_test analyze6-1.1 {
eqp {SELECT count(*) FROM ev, cat WHERE x=y}
} {0 0 1 {SCAN TABLE cat USING COVERING INDEX catx (~16 rows)} 0 1 0 {SEARCH TABLE ev USING COVERING INDEX evy (y=?) (~32 rows)}}
} {0 0 1 {SCAN TABLE cat USING COVERING INDEX catx} 0 1 0 {SEARCH TABLE ev USING COVERING INDEX evy (y=?)}}
# The same plan is chosen regardless of the order of the tables in the
# FROM clause.
#
do_test analyze6-1.2 {
eqp {SELECT count(*) FROM cat, ev WHERE x=y}
} {0 0 0 {SCAN TABLE cat USING COVERING INDEX catx (~16 rows)} 0 1 1 {SEARCH TABLE ev USING COVERING INDEX evy (y=?) (~32 rows)}}
} {0 0 0 {SCAN TABLE cat USING COVERING INDEX catx} 0 1 1 {SEARCH TABLE ev USING COVERING INDEX evy (y=?)}}
# Ticket [83ea97620bd3101645138b7b0e71c12c5498fe3d] 2011-03-30
@@ -82,26 +82,26 @@ do_test analyze6-2.1 {
ANALYZE;
}
eqp {SELECT * FROM t201 WHERE z=5}
} {0 0 0 {SEARCH TABLE t201 USING INDEX t201z (z=?) (~10 rows)}}
} {0 0 0 {SEARCH TABLE t201 USING INDEX t201z (z=?)}}
do_test analyze6-2.2 {
eqp {SELECT * FROM t201 WHERE y=5}
} {0 0 0 {SEARCH TABLE t201 USING INDEX sqlite_autoindex_t201_1 (y=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE t201 USING INDEX sqlite_autoindex_t201_1 (y=?)}}
do_test analyze6-2.3 {
eqp {SELECT * FROM t201 WHERE x=5}
} {0 0 0 {SEARCH TABLE t201 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE t201 USING INTEGER PRIMARY KEY (rowid=?)}}
do_test analyze6-2.4 {
execsql {
INSERT INTO t201 VALUES(1,2,3);
ANALYZE t201;
}
eqp {SELECT * FROM t201 WHERE z=5}
} {0 0 0 {SEARCH TABLE t201 USING INDEX t201z (z=?) (~10 rows)}}
} {0 0 0 {SEARCH TABLE t201 USING INDEX t201z (z=?)}}
do_test analyze6-2.5 {
eqp {SELECT * FROM t201 WHERE y=5}
} {0 0 0 {SEARCH TABLE t201 USING INDEX sqlite_autoindex_t201_1 (y=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE t201 USING INDEX sqlite_autoindex_t201_1 (y=?)}}
do_test analyze6-2.6 {
eqp {SELECT * FROM t201 WHERE x=5}
} {0 0 0 {SEARCH TABLE t201 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE t201 USING INTEGER PRIMARY KEY (rowid=?)}}
do_test analyze6-2.7 {
execsql {
INSERT INTO t201 VALUES(4,5,7);
@@ -111,12 +111,12 @@ do_test analyze6-2.7 {
ANALYZE t201;
}
eqp {SELECT * FROM t201 WHERE z=5}
} {0 0 0 {SEARCH TABLE t201 USING INDEX t201z (z=?) (~10 rows)}}
} {0 0 0 {SEARCH TABLE t201 USING INDEX t201z (z=?)}}
do_test analyze6-2.8 {
eqp {SELECT * FROM t201 WHERE y=5}
} {0 0 0 {SEARCH TABLE t201 USING INDEX sqlite_autoindex_t201_1 (y=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE t201 USING INDEX sqlite_autoindex_t201_1 (y=?)}}
do_test analyze6-2.9 {
eqp {SELECT * FROM t201 WHERE x=5}
} {0 0 0 {SEARCH TABLE t201 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE t201 USING INTEGER PRIMARY KEY (rowid=?)}}
finish_test
+16 -16
View File
@@ -37,13 +37,13 @@ do_test analyze7-1.0 {
WHERE value BETWEEN 1 AND 256;
EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=123;
}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~10 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}
do_test analyze7-1.1 {
execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=123;}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?) (~10 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?)}}
do_test analyze7-1.2 {
execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=2;}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?) (~10 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?)}}
# Run an analyze on one of the three indices. Verify that this
# effects the row-count estimate on the one query that uses that
@@ -53,20 +53,20 @@ do_test analyze7-2.0 {
execsql {ANALYZE t1a;}
db cache flush
execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=123;}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}
do_test analyze7-2.1 {
execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=123;}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?) (~10 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?)}}
do_test analyze7-2.2 {
execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=2;}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?) (~10 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?)}}
# Verify that since the query planner now things that t1a is more
# selective than t1b, it prefers to use t1a.
#
do_test analyze7-2.3 {
execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=123 AND b=123}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}
# Run an analysis on another of the three indices. Verify that this
# new analysis works and does not disrupt the previous analysis.
@@ -75,39 +75,39 @@ do_test analyze7-3.0 {
execsql {ANALYZE t1cd;}
db cache flush;
execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=123;}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}
do_test analyze7-3.1 {
execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=123;}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?) (~10 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?)}}
do_test analyze7-3.2.1 {
execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=?;}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?) (~86 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?)}}
ifcapable stat3 {
# If ENABLE_STAT3 is defined, SQLite comes up with a different estimated
# row count for (c=2) than it does for (c=?).
do_test analyze7-3.2.2 {
execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=2;}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?) (~57 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?)}}
} else {
# If ENABLE_STAT3 is not defined, the expected row count for (c=2) is the
# same as that for (c=?).
do_test analyze7-3.2.3 {
execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=2;}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?) (~86 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?)}}
}
do_test analyze7-3.3 {
execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=123 AND b=123}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}
ifcapable {!stat3} {
do_test analyze7-3.4 {
execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=123 AND b=123}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?) (~2 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?)}}
do_test analyze7-3.5 {
execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=123 AND c=123}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}
}
do_test analyze7-3.6 {
execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=123 AND d=123 AND b=123}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=? AND d=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=? AND d=?)}}
finish_test
+11 -11
View File
@@ -61,25 +61,25 @@ do_test 1.0 {
#
do_test 1.1 {
eqp {SELECT * FROM t1 WHERE a=100 AND b=55}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?) (~2 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?)}}
do_test 1.2 {
eqp {SELECT * FROM t1 WHERE a=99 AND b=55}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}
do_test 1.3 {
eqp {SELECT * FROM t1 WHERE a=101 AND b=55}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}
do_test 1.4 {
eqp {SELECT * FROM t1 WHERE a=100 AND b=56}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?) (~2 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?)}}
do_test 1.5 {
eqp {SELECT * FROM t1 WHERE a=99 AND b=56}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}
do_test 1.6 {
eqp {SELECT * FROM t1 WHERE a=101 AND b=56}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}
do_test 2.1 {
eqp {SELECT * FROM t1 WHERE a=100 AND b BETWEEN 50 AND 54}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b>? AND b<?) (~2 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b>? AND b<?)}}
# There are many more values of c between 0 and 100000 than there are
# between 800000 and 900000. So t1c is more selective for the latter
@@ -87,17 +87,17 @@ do_test 2.1 {
#
do_test 3.1 {
eqp {SELECT * FROM t1 WHERE b BETWEEN 50 AND 54 AND c BETWEEN 0 AND 100000}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b>? AND b<?) (~6 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b>? AND b<?)}}
do_test 3.2 {
eqp {SELECT * FROM t1
WHERE b BETWEEN 50 AND 54 AND c BETWEEN 800000 AND 900000}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c>? AND c<?) (~4 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c>? AND c<?)}}
do_test 3.3 {
eqp {SELECT * FROM t1 WHERE a=100 AND c BETWEEN 0 AND 100000}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?) (~63 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}
do_test 3.4 {
eqp {SELECT * FROM t1
WHERE a=100 AND c BETWEEN 800000 AND 900000}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c>? AND c<?) (~2 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c>? AND c<?)}}
finish_test
-1
View File
@@ -66,4 +66,3 @@ sqlite3async_control halt never
sqlite3async_shutdown
set sqlite3async_trace 0
finish_test
+18 -12
View File
@@ -78,6 +78,9 @@ do_test autoindex1-202 {
do_test autoindex1-210 {
db eval {
PRAGMA automatic_index=ON;
ANALYZE;
UPDATE sqlite_stat1 SET stat='10000' WHERE tbl='t1';
ANALYZE sqlite_master;
SELECT b, (SELECT d FROM t2 WHERE c=a) FROM t1;
}
} {11 911 22 922 33 933 44 944 55 955 66 966 77 977 88 988}
@@ -143,22 +146,25 @@ do_test autoindex1-401 {
do_execsql_test autoindex1-500 {
CREATE TABLE t501(a INTEGER PRIMARY KEY, b);
CREATE TABLE t502(x INTEGER PRIMARY KEY, y);
INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t501',null,'1000000');
INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t502',null,'1000');
ANALYZE sqlite_master;
EXPLAIN QUERY PLAN
SELECT b FROM t501
WHERE t501.a IN (SELECT x FROM t502 WHERE y=?);
} {
0 0 0 {SEARCH TABLE t501 USING INTEGER PRIMARY KEY (rowid=?) (~25 rows)}
0 0 0 {SEARCH TABLE t501 USING INTEGER PRIMARY KEY (rowid=?)}
0 0 0 {EXECUTE LIST SUBQUERY 1}
1 0 0 {SCAN TABLE t502 (~100000 rows)}
1 0 0 {SCAN TABLE t502}
}
do_execsql_test autoindex1-501 {
EXPLAIN QUERY PLAN
SELECT b FROM t501
WHERE t501.a IN (SELECT x FROM t502 WHERE y=t501.b);
} {
0 0 0 {SCAN TABLE t501 (~500000 rows)}
0 0 0 {SCAN TABLE t501}
0 0 0 {EXECUTE CORRELATED LIST SUBQUERY 1}
1 0 0 {SEARCH TABLE t502 USING AUTOMATIC COVERING INDEX (y=?) (~7 rows)}
1 0 0 {SEARCH TABLE t502 USING AUTOMATIC COVERING INDEX (y=?)}
}
do_execsql_test autoindex1-502 {
EXPLAIN QUERY PLAN
@@ -166,9 +172,9 @@ do_execsql_test autoindex1-502 {
WHERE t501.a=123
AND t501.a IN (SELECT x FROM t502 WHERE y=t501.b);
} {
0 0 0 {SEARCH TABLE t501 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
0 0 0 {SEARCH TABLE t501 USING INTEGER PRIMARY KEY (rowid=?)}
0 0 0 {EXECUTE CORRELATED LIST SUBQUERY 1}
1 0 0 {SCAN TABLE t502 (~100000 rows)}
1 0 0 {SCAN TABLE t502}
}
@@ -240,12 +246,12 @@ do_execsql_test autoindex1-600 {
WHERE y.sheep_no IS NULL
ORDER BY x.registering_flock;
} {
1 0 0 {SCAN TABLE sheep AS s (~1000000 rows)}
1 1 1 {SEARCH TABLE flock_owner AS prev USING INDEX sqlite_autoindex_flock_owner_1 (flock_no=? AND owner_change_date<?) (~2 rows)}
1 0 0 {SCAN TABLE sheep AS s}
1 1 1 {SEARCH TABLE flock_owner AS prev USING INDEX sqlite_autoindex_flock_owner_1 (flock_no=? AND owner_change_date<?)}
1 0 0 {EXECUTE CORRELATED SCALAR SUBQUERY 2}
2 0 0 {SEARCH TABLE flock_owner AS later USING COVERING INDEX sqlite_autoindex_flock_owner_1 (flock_no=? AND owner_change_date>? AND owner_change_date<?) (~1 rows)}
0 0 0 {SCAN TABLE sheep AS x USING INDEX sheep_reg_flock_index (~1000000 rows)}
0 1 1 {SEARCH SUBQUERY 1 AS y USING AUTOMATIC COVERING INDEX (sheep_no=?) (~8 rows)}
2 0 0 {SEARCH TABLE flock_owner AS later USING COVERING INDEX sqlite_autoindex_flock_owner_1 (flock_no=? AND owner_change_date>? AND owner_change_date<?)}
0 0 0 {SCAN TABLE sheep AS x USING INDEX sheep_reg_flock_index}
0 1 1 {SEARCH SUBQUERY 1 AS y USING AUTOMATIC COVERING INDEX (sheep_no=?)}
}
@@ -253,7 +259,7 @@ do_execsql_test autoindex1-700 {
CREATE TABLE t5(a, b, c);
EXPLAIN QUERY PLAN SELECT a FROM t5 WHERE b=10 ORDER BY c;
} {
0 0 0 {SCAN TABLE t5 (~100000 rows)}
0 0 0 {SCAN TABLE t5}
0 0 0 {USE TEMP B-TREE FOR ORDER BY}
}
-1
View File
@@ -101,4 +101,3 @@ do_test 3.3 {
do_test 3.4 { file size test.db2 } 0
finish_test
+17 -7
View File
@@ -48,14 +48,24 @@ do_test between-1.0 {
# This procedure executes the SQL. Then it appends to the result the
# "sort" or "nosort" keyword depending on whether or not any sorting
# is done. Then it appends the ::sqlite_query_plan variable.
# is done. Then it appends the names of the table and index used.
#
proc queryplan {sql} {
set ::sqlite_sort_count 0
set data [execsql $sql]
if {$::sqlite_sort_count} {set x sort} {set x nosort}
lappend data $x
return [concat $data $::sqlite_query_plan]
set eqp [execsql "EXPLAIN QUERY PLAN $sql"]
# puts eqp=$eqp
foreach {a b c x} $eqp {
if {[regexp { TABLE (\w+ AS )?(\w+) USING.* INDEX (\w+)\y} \
$x all as tab idx]} {
lappend data $tab $idx
} elseif {[regexp { TABLE (\w+ AS )?(\w+)\y} $x all as tab]} {
lappend data $tab *
}
}
return $data
}
do_test between-1.1.1 {
@@ -67,7 +77,7 @@ do_test between-1.1.2 {
queryplan {
SELECT * FROM t1 WHERE +w BETWEEN 5 AND 6 ORDER BY +w
}
} {5 2 36 38 6 2 49 51 sort t1 {}}
} {5 2 36 38 6 2 49 51 sort t1 *}
do_test between-1.2.1 {
queryplan {
SELECT * FROM t1 WHERE w BETWEEN 5 AND 65-y ORDER BY +w
@@ -77,7 +87,7 @@ do_test between-1.2.2 {
queryplan {
SELECT * FROM t1 WHERE +w BETWEEN 5 AND 65-y ORDER BY +w
}
} {5 2 36 38 6 2 49 51 sort t1 {}}
} {5 2 36 38 6 2 49 51 sort t1 *}
do_test between-1.3.1 {
queryplan {
SELECT * FROM t1 WHERE w BETWEEN 41-y AND 6 ORDER BY +w
@@ -87,12 +97,12 @@ do_test between-1.3.2 {
queryplan {
SELECT * FROM t1 WHERE +w BETWEEN 41-y AND 6 ORDER BY +w
}
} {5 2 36 38 6 2 49 51 sort t1 {}}
} {5 2 36 38 6 2 49 51 sort t1 *}
do_test between-1.4 {
queryplan {
SELECT * FROM t1 WHERE w BETWEEN 41-y AND 65-y ORDER BY +w
}
} {5 2 36 38 6 2 49 51 sort t1 {}}
} {5 2 36 38 6 2 49 51 sort t1 *}
do_test between-1.5.1 {
queryplan {
SELECT * FROM t1 WHERE 26 BETWEEN y AND z ORDER BY +w
@@ -107,7 +117,7 @@ do_test between-1.5.3 {
queryplan {
SELECT * FROM t1 WHERE 26 BETWEEN y AND +z ORDER BY +w
}
} {4 2 25 27 sort t1 {}}
} {4 2 25 27 sort t1 *}
finish_test
-1
View File
@@ -55,4 +55,3 @@ do_faultsim_test 1 -prep {
}
finish_test
+1 -1
View File
@@ -60,7 +60,7 @@ proc utf8 {str} {
db close
# here's the list of file names we're testing
set names {t 1 t. 1. t.d 1.d t-1 1-1 t.db ä.db ë.db ö.db ü.db ÿ.db}
set names {t 1 t. 1. t.d 1.d t-1 1-1 t.db ä.db ë.db ö.db ü.db ÿ.db}
set i 0
foreach name $names {
-1
View File
@@ -76,4 +76,3 @@ do_test 1.4.4 {
} {SQLITE_OK}
finish_test
+29
View File
@@ -305,4 +305,33 @@ do_test collate1-4.5 {
}
} {}
# A problem reported on the mailing list: A CREATE TABLE statement
# is allowed to have two or more COLLATE clauses on the same column.
# That probably ought to be an error, but we allow it for backwards
# compatibility. Just make sure it works and doesn't leak memory.
#
do_test collate1-5.1 {
execsql {
CREATE TABLE c5(
id INTEGER PRIMARY KEY,
a TEXT COLLATE binary COLLATE nocase COLLATE rtrim,
b TEXT COLLATE nocase COLLATE binary,
c TEXT COLLATE rtrim COLLATE binary COLLATE rtrim COLLATE nocase
);
INSERT INTO c5 VALUES(1, 'abc','abc','abc');
INSERT INTO c5 VALUES(2, 'abc ','ABC','ABC');
SELECT id FROM c5 WHERE a='abc' ORDER BY id;
}
} {1 2}
do_test collate1-5.2 {
execsql {
SELECT id FROM c5 WHERE b='abc' ORDER BY id;
}
} {1}
do_test collate1-5.3 {
execsql {
SELECT id FROM c5 WHERE c='abc' ORDER BY id;
}
} {1 2}
finish_test
+4 -2
View File
@@ -636,13 +636,15 @@ do_test collate2-4.2 {
do_test collate2-4.3 {
execsql {
SELECT collate2t1.a FROM collate2t1, collate2t3
WHERE collate2t1.b = collate2t3.b||'';
WHERE collate2t1.b = collate2t3.b||''
ORDER BY +collate2t1.a DESC;
}
} {aa aA Aa AA}
do_test collate2-4.4 {
execsql {
SELECT collate2t1.a FROM collate2t1, collate2t3
WHERE collate2t3.b||'' = collate2t1.b;
WHERE collate2t3.b||'' = collate2t1.b
ORDER BY +collate2t1.a DESC;
}
} {aa aA Aa AA}
+90
View File
@@ -0,0 +1,90 @@
# 2013-06-05
#
# 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.
#
# This file contains test cases that were contributed on the sqlite-users
# mailing list on 2013-06-05 by Mi Chen at mi.chen@echostar.com.
#
# At the time it was contributed, this test failed on trunk, but
# worked on the NGQP.
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Build some test data
#
do_test contrib01-1.0 {
db eval {
CREATE TABLE T1 (B INTEGER NOT NULL,
C INTEGER NOT NULL,
D INTEGER NOT NULL,
E INTEGER NOT NULL,
F INTEGER NOT NULL,
G INTEGER NOT NULL,
H INTEGER NOT NULL,
PRIMARY KEY (B, C, D));
CREATE TABLE T2 (A INTEGER NOT NULL,
B INTEGER NOT NULL,
C INTEGER NOT NULL,
PRIMARY KEY (A, B, C));
INSERT INTO T2(A, B, C) VALUES(702118,16183,15527);
INSERT INTO T2(A, B, C) VALUES(702118,16183,15560);
INSERT INTO T2(A, B, C) VALUES(702118,16183,15561);
INSERT INTO T2(A, B, C) VALUES(702118,16183,15563);
INSERT INTO T2(A, B, C) VALUES(702118,16183,15564);
INSERT INTO T2(A, B, C) VALUES(702118,16183,15566);
INSERT INTO T2(A, B, C) VALUES(702118,16183,15567);
INSERT INTO T2(A, B, C) VALUES(702118,16183,15569);
INSERT INTO T2(A, B, C) VALUES(702118,16183,15612);
INSERT INTO T2(A, B, C) VALUES(702118,16183,15613);
INSERT INTO T2(A, B, C) VALUES(702118,16183,15638);
INSERT INTO T2(A, B, C) VALUES(702118,16183,15681);
INSERT INTO T2(A, B, C) VALUES(702118,16183,15682);
INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15527,6,0,5,5,0);
INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15560,6,0,5,2,0);
INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15561,6,0,5,2,0);
INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15563,6,0,5,2,0);
INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15564,6,0,5,2,0);
INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15566,6,0,5,2,0);
INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15567,6,0,5,2,0);
INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15569,6,0,5,2,0);
INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15612,6,0,5,5,0);
INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15613,6,0,5,2,0);
INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15638,6,0,5,2,0);
INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15681,6,0,5,5,0);
INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15682,6,0,5,2,0);
}
} {}
do_test contrib01-1.1 {
db eval {
SELECT T2.A, T2.B, T1.D, T1.E, T1.F, T1.G, T1.H, MAX(T1.C), '^'
FROM T1, T2
WHERE T1.B = T2.B
AND T1.C = T2.C
GROUP BY T2.A, T2.B, T1.D, T1.E, T1.F, T1.G, T1.H
ORDER BY +max(t1.c);
}
} {702118 16183 6 0 5 5 0 15681 ^ 702118 16183 6 0 5 2 0 15682 ^}
do_test contrib01-1.2 {
db eval {
SELECT T2.A, T2.B, T1.D, T1.E, T1.F, T1.G, T1.H, MAX(T1.C), '^'
FROM T1, T2
WHERE T1.B = T2.B
AND T1.C = T2.C
GROUP BY T2.A, T2.B, T1.F, T1.D, T1.E, T1.G, T1.H
ORDER BY +max(t1.c);
}
} {702118 16183 6 0 5 5 0 15681 ^ 702118 16183 6 0 5 2 0 15682 ^}
finish_test
-1
View File
@@ -147,4 +147,3 @@ for {set i 127} {$i >= 0} {incr i -1} {
}
finish_test
+2 -2
View File
@@ -197,12 +197,12 @@ ifcapable bloblit {
} {1.0 2.2 2.0 2.1 2.3 3.0 4.0 5.0 6.0}
do_test descidx1-4.3 {
execsql {
SELECT d FROM t2 WHERE a>=2;
SELECT d FROM t2 WHERE a>=2 ORDER BY a;
}
} {2.2 2.0 2.1 2.3 3.0 4.0 5.0 6.0}
do_test descidx1-4.4 {
execsql {
SELECT d FROM t2 WHERE a>2;
SELECT d FROM t2 WHERE a>2 ORDER BY a;
}
} {3.0 4.0 5.0 6.0}
do_test descidx1-4.5 {
+1 -1
View File
@@ -165,7 +165,7 @@ foreach {tn sql temptables res} {
3 "a, b, c FROM t1" {hash} {a b c A B C}
4 "a, b, c FROM t1 ORDER BY a, b, c" {btree} {A B C a b c}
5 "b FROM t1 WHERE a = 'a'" {} {b}
6 "b FROM t1" {hash} {b B}
6 "b FROM t1 ORDER BY +b COLLATE binary" {btree hash} {B b}
7 "a FROM t1" {} {A a}
8 "b COLLATE nocase FROM t1" {} {b}
9 "b COLLATE nocase FROM t1 ORDER BY b COLLATE nocase" {} {b}
+3 -3
View File
@@ -1368,13 +1368,13 @@ do_execsql_test 4.10.0 {
}
do_createtable_tests 4.10 {
1 "EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b = 5"
{0 0 0 {SEARCH TABLE t1 USING INDEX sqlite_autoindex_t1_1 (b=?) (~1 rows)}}
{0 0 0 {SEARCH TABLE t1 USING INDEX sqlite_autoindex_t1_1 (b=?)}}
2 "EXPLAIN QUERY PLAN SELECT * FROM t2 ORDER BY b, c"
{0 0 0 {SCAN TABLE t2 USING INDEX sqlite_autoindex_t2_1 (~1000000 rows)}}
{0 0 0 {SCAN TABLE t2 USING INDEX sqlite_autoindex_t2_1}}
3 "EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE b=10 AND c>10"
{0 0 0 {SEARCH TABLE t2 USING INDEX sqlite_autoindex_t2_1 (b=? AND c>?) (~2 rows)}}
{0 0 0 {SEARCH TABLE t2 USING INDEX sqlite_autoindex_t2_1 (b=? AND c>?)}}
}
# EVIDENCE-OF: R-45493-35653 A CHECK constraint may be attached to a
+9 -9
View File
@@ -974,15 +974,15 @@ do_execsql_test e_fkey-25.2 {
EXPLAIN QUERY PLAN DELETE FROM artist WHERE 1;
EXPLAIN QUERY PLAN SELECT rowid FROM track WHERE trackartist = ?;
} {
0 0 0 {SCAN TABLE artist (~1000000 rows)}
0 0 0 {SCAN TABLE track (~100000 rows)}
0 0 0 {SCAN TABLE artist}
0 0 0 {SCAN TABLE track}
}
do_execsql_test e_fkey-25.3 {
PRAGMA foreign_keys = ON;
EXPLAIN QUERY PLAN DELETE FROM artist WHERE 1;
} {
0 0 0 {SCAN TABLE artist (~1000000 rows)}
0 0 0 {SCAN TABLE track (~100000 rows)}
0 0 0 {SCAN TABLE artist}
0 0 0 {SCAN TABLE track}
}
do_test e_fkey-25.4 {
execsql {
@@ -1099,15 +1099,15 @@ do_test e_fkey-27.2 {
do_execsql_test e_fkey-27.3 {
EXPLAIN QUERY PLAN UPDATE artist SET artistid = ?, artistname = ?
} {
0 0 0 {SCAN TABLE artist (~1000000 rows)}
0 0 0 {SEARCH TABLE track USING COVERING INDEX trackindex (trackartist=?) (~10 rows)}
0 0 0 {SEARCH TABLE track USING COVERING INDEX trackindex (trackartist=?) (~10 rows)}
0 0 0 {SCAN TABLE artist}
0 0 0 {SEARCH TABLE track USING COVERING INDEX trackindex (trackartist=?)}
0 0 0 {SEARCH TABLE track USING COVERING INDEX trackindex (trackartist=?)}
}
do_execsql_test e_fkey-27.4 {
EXPLAIN QUERY PLAN DELETE FROM artist
} {
0 0 0 {SCAN TABLE artist (~1000000 rows)}
0 0 0 {SEARCH TABLE track USING COVERING INDEX trackindex (trackartist=?) (~10 rows)}
0 0 0 {SCAN TABLE artist}
0 0 0 {SEARCH TABLE track USING COVERING INDEX trackindex (trackartist=?)}
}
+1 -1
View File
@@ -98,7 +98,7 @@ proc sort_by_length {lhs rhs} {
array set V {one 1 two 2 three 3 four 4 five 5 six 6 seven 7 eight 8}
proc sort_by_value {lhs rhs} {
global V
set res [expr {$V($lhs) - $V(rhs)}]
set res [expr {$V($lhs) - $V($rhs)}]
if {$res!=0} {return $res}
return [string compare $lhs $rhs]
}
+130 -130
View File
@@ -43,37 +43,37 @@ do_execsql_test 1.1 {
do_eqp_test 1.2 {
SELECT * FROM t2, t1 WHERE t1.a=1 OR t1.b=2;
} {
0 0 1 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~10 rows)}
0 0 1 {SEARCH TABLE t1 USING INDEX i2 (b=?) (~10 rows)}
0 1 0 {SCAN TABLE t2 (~1000000 rows)}
0 0 1 {SEARCH TABLE t1 USING INDEX i1 (a=?)}
0 0 1 {SEARCH TABLE t1 USING INDEX i2 (b=?)}
0 1 0 {SCAN TABLE t2}
}
do_eqp_test 1.3 {
SELECT * FROM t2 CROSS JOIN t1 WHERE t1.a=1 OR t1.b=2;
} {
0 0 0 {SCAN TABLE t2 (~1000000 rows)}
0 1 1 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~10 rows)}
0 1 1 {SEARCH TABLE t1 USING INDEX i2 (b=?) (~10 rows)}
0 0 0 {SCAN TABLE t2}
0 1 1 {SEARCH TABLE t1 USING INDEX i1 (a=?)}
0 1 1 {SEARCH TABLE t1 USING INDEX i2 (b=?)}
}
do_eqp_test 1.3 {
SELECT a FROM t1 ORDER BY a
} {
0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1 (~1000000 rows)}
0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1}
}
do_eqp_test 1.4 {
SELECT a FROM t1 ORDER BY +a
} {
0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1 (~1000000 rows)}
0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1}
0 0 0 {USE TEMP B-TREE FOR ORDER BY}
}
do_eqp_test 1.5 {
SELECT a FROM t1 WHERE a=4
} {
0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (a=?) (~10 rows)}
0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (a=?)}
}
do_eqp_test 1.6 {
SELECT DISTINCT count(*) FROM t3 GROUP BY a;
} {
0 0 0 {SCAN TABLE t3 (~1000000 rows)}
0 0 0 {SCAN TABLE t3}
0 0 0 {USE TEMP B-TREE FOR GROUP BY}
0 0 0 {USE TEMP B-TREE FOR DISTINCT}
}
@@ -81,40 +81,40 @@ do_eqp_test 1.6 {
do_eqp_test 1.7 {
SELECT * FROM t3 JOIN (SELECT 1)
} {
0 0 1 {SCAN SUBQUERY 1 (~1 rows)}
0 1 0 {SCAN TABLE t3 (~1000000 rows)}
0 0 1 {SCAN SUBQUERY 1}
0 1 0 {SCAN TABLE t3}
}
do_eqp_test 1.8 {
SELECT * FROM t3 JOIN (SELECT 1 UNION SELECT 2)
} {
1 0 0 {COMPOUND SUBQUERIES 2 AND 3 USING TEMP B-TREE (UNION)}
0 0 1 {SCAN SUBQUERY 1 (~2 rows)}
0 1 0 {SCAN TABLE t3 (~1000000 rows)}
0 0 1 {SCAN SUBQUERY 1}
0 1 0 {SCAN TABLE t3}
}
do_eqp_test 1.9 {
SELECT * FROM t3 JOIN (SELECT 1 EXCEPT SELECT a FROM t3 LIMIT 17)
} {
3 0 0 {SCAN TABLE t3 (~1000000 rows)}
3 0 0 {SCAN TABLE t3}
1 0 0 {COMPOUND SUBQUERIES 2 AND 3 USING TEMP B-TREE (EXCEPT)}
0 0 1 {SCAN SUBQUERY 1 (~17 rows)}
0 1 0 {SCAN TABLE t3 (~1000000 rows)}
0 0 1 {SCAN SUBQUERY 1}
0 1 0 {SCAN TABLE t3}
}
do_eqp_test 1.10 {
SELECT * FROM t3 JOIN (SELECT 1 INTERSECT SELECT a FROM t3 LIMIT 17)
} {
3 0 0 {SCAN TABLE t3 (~1000000 rows)}
3 0 0 {SCAN TABLE t3}
1 0 0 {COMPOUND SUBQUERIES 2 AND 3 USING TEMP B-TREE (INTERSECT)}
0 0 1 {SCAN SUBQUERY 1 (~1 rows)}
0 1 0 {SCAN TABLE t3 (~1000000 rows)}
0 0 1 {SCAN SUBQUERY 1}
0 1 0 {SCAN TABLE t3}
}
do_eqp_test 1.11 {
SELECT * FROM t3 JOIN (SELECT 1 UNION ALL SELECT a FROM t3 LIMIT 17)
} {
3 0 0 {SCAN TABLE t3 (~1000000 rows)}
3 0 0 {SCAN TABLE t3}
1 0 0 {COMPOUND SUBQUERIES 2 AND 3 (UNION ALL)}
0 0 1 {SCAN SUBQUERY 1 (~17 rows)}
0 1 0 {SCAN TABLE t3 (~1000000 rows)}
0 0 1 {SCAN SUBQUERY 1}
0 1 0 {SCAN TABLE t3}
}
#-------------------------------------------------------------------------
@@ -129,48 +129,48 @@ do_execsql_test 2.1 {
}
det 2.2.1 "SELECT DISTINCT min(x), max(x) FROM t1 GROUP BY x ORDER BY 1" {
0 0 0 {SCAN TABLE t1 (~1000000 rows)}
0 0 0 {SCAN TABLE t1}
0 0 0 {USE TEMP B-TREE FOR GROUP BY}
0 0 0 {USE TEMP B-TREE FOR DISTINCT}
0 0 0 {USE TEMP B-TREE FOR ORDER BY}
}
det 2.2.2 "SELECT DISTINCT min(x), max(x) FROM t2 GROUP BY x ORDER BY 1" {
0 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1 (~1000000 rows)}
0 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1}
0 0 0 {USE TEMP B-TREE FOR DISTINCT}
0 0 0 {USE TEMP B-TREE FOR ORDER BY}
}
det 2.2.3 "SELECT DISTINCT * FROM t1" {
0 0 0 {SCAN TABLE t1 (~1000000 rows)}
0 0 0 {SCAN TABLE t1}
0 0 0 {USE TEMP B-TREE FOR DISTINCT}
}
det 2.2.4 "SELECT DISTINCT * FROM t1, t2" {
0 0 0 {SCAN TABLE t1 (~1000000 rows)}
0 1 1 {SCAN TABLE t2 (~1000000 rows)}
0 0 0 {SCAN TABLE t1}
0 1 1 {SCAN TABLE t2}
0 0 0 {USE TEMP B-TREE FOR DISTINCT}
}
det 2.2.5 "SELECT DISTINCT * FROM t1, t2 ORDER BY t1.x" {
0 0 0 {SCAN TABLE t1 (~1000000 rows)}
0 1 1 {SCAN TABLE t2 (~1000000 rows)}
0 0 0 {SCAN TABLE t1}
0 1 1 {SCAN TABLE t2}
0 0 0 {USE TEMP B-TREE FOR DISTINCT}
0 0 0 {USE TEMP B-TREE FOR ORDER BY}
}
det 2.2.6 "SELECT DISTINCT t2.x FROM t1, t2 ORDER BY t2.x" {
0 0 1 {SCAN TABLE t2 USING COVERING INDEX t2i1 (~1000000 rows)}
0 1 0 {SCAN TABLE t1 (~1000000 rows)}
0 0 1 {SCAN TABLE t2 USING COVERING INDEX t2i1}
0 1 0 {SCAN TABLE t1}
}
det 2.3.1 "SELECT max(x) FROM t2" {
0 0 0 {SEARCH TABLE t2 USING COVERING INDEX t2i1 (~1 rows)}
0 0 0 {SEARCH TABLE t2 USING COVERING INDEX t2i1}
}
det 2.3.2 "SELECT min(x) FROM t2" {
0 0 0 {SEARCH TABLE t2 USING COVERING INDEX t2i1 (~1 rows)}
0 0 0 {SEARCH TABLE t2 USING COVERING INDEX t2i1}
}
det 2.3.3 "SELECT min(x), max(x) FROM t2" {
0 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1 (~1000000 rows)}
0 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1}
}
det 2.4.1 "SELECT * FROM t1 WHERE rowid=?" {
0 0 0 {SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
0 0 0 {SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?)}
}
@@ -181,39 +181,39 @@ det 2.4.1 "SELECT * FROM t1 WHERE rowid=?" {
do_eqp_test 3.1.1 {
SELECT (SELECT x FROM t1 AS sub) FROM t1;
} {
0 0 0 {SCAN TABLE t1 (~1000000 rows)}
0 0 0 {SCAN TABLE t1}
0 0 0 {EXECUTE SCALAR SUBQUERY 1}
1 0 0 {SCAN TABLE t1 AS sub (~1000000 rows)}
1 0 0 {SCAN TABLE t1 AS sub}
}
do_eqp_test 3.1.2 {
SELECT * FROM t1 WHERE (SELECT x FROM t1 AS sub);
} {
0 0 0 {SCAN TABLE t1 (~1000000 rows)}
0 0 0 {SCAN TABLE t1}
0 0 0 {EXECUTE SCALAR SUBQUERY 1}
1 0 0 {SCAN TABLE t1 AS sub (~1000000 rows)}
1 0 0 {SCAN TABLE t1 AS sub}
}
do_eqp_test 3.1.3 {
SELECT * FROM t1 WHERE (SELECT x FROM t1 AS sub ORDER BY y);
} {
0 0 0 {SCAN TABLE t1 (~1000000 rows)}
0 0 0 {SCAN TABLE t1}
0 0 0 {EXECUTE SCALAR SUBQUERY 1}
1 0 0 {SCAN TABLE t1 AS sub (~1000000 rows)}
1 0 0 {SCAN TABLE t1 AS sub}
1 0 0 {USE TEMP B-TREE FOR ORDER BY}
}
do_eqp_test 3.1.4 {
SELECT * FROM t1 WHERE (SELECT x FROM t2 ORDER BY x);
} {
0 0 0 {SCAN TABLE t1 (~1000000 rows)}
0 0 0 {SCAN TABLE t1}
0 0 0 {EXECUTE SCALAR SUBQUERY 1}
1 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1 (~1000000 rows)}
1 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1}
}
det 3.2.1 {
SELECT * FROM (SELECT * FROM t1 ORDER BY x LIMIT 10) ORDER BY y LIMIT 5
} {
1 0 0 {SCAN TABLE t1 (~1000000 rows)}
1 0 0 {SCAN TABLE t1}
1 0 0 {USE TEMP B-TREE FOR ORDER BY}
0 0 0 {SCAN SUBQUERY 1 (~10 rows)}
0 0 0 {SCAN SUBQUERY 1}
0 0 0 {USE TEMP B-TREE FOR ORDER BY}
}
det 3.2.2 {
@@ -222,34 +222,34 @@ det 3.2.2 {
(SELECT * FROM t2 ORDER BY x LIMIT 10) AS x2
ORDER BY x2.y LIMIT 5
} {
1 0 0 {SCAN TABLE t1 (~1000000 rows)}
1 0 0 {SCAN TABLE t1}
1 0 0 {USE TEMP B-TREE FOR ORDER BY}
2 0 0 {SCAN TABLE t2 USING INDEX t2i1 (~1000000 rows)}
0 0 0 {SCAN SUBQUERY 1 AS x1 (~10 rows)}
0 1 1 {SCAN SUBQUERY 2 AS x2 (~10 rows)}
2 0 0 {SCAN TABLE t2 USING INDEX t2i1}
0 0 0 {SCAN SUBQUERY 1 AS x1}
0 1 1 {SCAN SUBQUERY 2 AS x2}
0 0 0 {USE TEMP B-TREE FOR ORDER BY}
}
det 3.3.1 {
SELECT * FROM t1 WHERE y IN (SELECT y FROM t2)
} {
0 0 0 {SCAN TABLE t1 (~100000 rows)}
0 0 0 {SCAN TABLE t1}
0 0 0 {EXECUTE LIST SUBQUERY 1}
1 0 0 {SCAN TABLE t2 (~1000000 rows)}
1 0 0 {SCAN TABLE t2}
}
det 3.3.2 {
SELECT * FROM t1 WHERE y IN (SELECT y FROM t2 WHERE t1.x!=t2.x)
} {
0 0 0 {SCAN TABLE t1 (~500000 rows)}
0 0 0 {SCAN TABLE t1}
0 0 0 {EXECUTE CORRELATED LIST SUBQUERY 1}
1 0 0 {SCAN TABLE t2 (~500000 rows)}
1 0 0 {SCAN TABLE t2}
}
det 3.3.3 {
SELECT * FROM t1 WHERE EXISTS (SELECT y FROM t2 WHERE t1.x!=t2.x)
} {
0 0 0 {SCAN TABLE t1 (~500000 rows)}
0 0 0 {SCAN TABLE t1}
0 0 0 {EXECUTE CORRELATED SCALAR SUBQUERY 1}
1 0 0 {SCAN TABLE t2 (~500000 rows)}
1 0 0 {SCAN TABLE t2}
}
#-------------------------------------------------------------------------
@@ -258,43 +258,43 @@ det 3.3.3 {
do_eqp_test 4.1.1 {
SELECT * FROM t1 UNION ALL SELECT * FROM t2
} {
1 0 0 {SCAN TABLE t1 (~1000000 rows)}
2 0 0 {SCAN TABLE t2 (~1000000 rows)}
1 0 0 {SCAN TABLE t1}
2 0 0 {SCAN TABLE t2}
0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (UNION ALL)}
}
do_eqp_test 4.1.2 {
SELECT * FROM t1 UNION ALL SELECT * FROM t2 ORDER BY 2
} {
1 0 0 {SCAN TABLE t1 (~1000000 rows)}
1 0 0 {SCAN TABLE t1}
1 0 0 {USE TEMP B-TREE FOR ORDER BY}
2 0 0 {SCAN TABLE t2 (~1000000 rows)}
2 0 0 {SCAN TABLE t2}
2 0 0 {USE TEMP B-TREE FOR ORDER BY}
0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (UNION ALL)}
}
do_eqp_test 4.1.3 {
SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY 2
} {
1 0 0 {SCAN TABLE t1 (~1000000 rows)}
1 0 0 {SCAN TABLE t1}
1 0 0 {USE TEMP B-TREE FOR ORDER BY}
2 0 0 {SCAN TABLE t2 (~1000000 rows)}
2 0 0 {SCAN TABLE t2}
2 0 0 {USE TEMP B-TREE FOR ORDER BY}
0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (UNION)}
}
do_eqp_test 4.1.4 {
SELECT * FROM t1 INTERSECT SELECT * FROM t2 ORDER BY 2
} {
1 0 0 {SCAN TABLE t1 (~1000000 rows)}
1 0 0 {SCAN TABLE t1}
1 0 0 {USE TEMP B-TREE FOR ORDER BY}
2 0 0 {SCAN TABLE t2 (~1000000 rows)}
2 0 0 {SCAN TABLE t2}
2 0 0 {USE TEMP B-TREE FOR ORDER BY}
0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (INTERSECT)}
}
do_eqp_test 4.1.5 {
SELECT * FROM t1 EXCEPT SELECT * FROM t2 ORDER BY 2
} {
1 0 0 {SCAN TABLE t1 (~1000000 rows)}
1 0 0 {SCAN TABLE t1}
1 0 0 {USE TEMP B-TREE FOR ORDER BY}
2 0 0 {SCAN TABLE t2 (~1000000 rows)}
2 0 0 {SCAN TABLE t2}
2 0 0 {USE TEMP B-TREE FOR ORDER BY}
0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)}
}
@@ -302,35 +302,35 @@ do_eqp_test 4.1.5 {
do_eqp_test 4.2.2 {
SELECT * FROM t1 UNION ALL SELECT * FROM t2 ORDER BY 1
} {
1 0 0 {SCAN TABLE t1 (~1000000 rows)}
1 0 0 {SCAN TABLE t1}
1 0 0 {USE TEMP B-TREE FOR ORDER BY}
2 0 0 {SCAN TABLE t2 USING INDEX t2i1 (~1000000 rows)}
2 0 0 {SCAN TABLE t2 USING INDEX t2i1}
0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (UNION ALL)}
}
do_eqp_test 4.2.3 {
SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY 1
} {
1 0 0 {SCAN TABLE t1 (~1000000 rows)}
1 0 0 {SCAN TABLE t1}
1 0 0 {USE TEMP B-TREE FOR ORDER BY}
2 0 0 {SCAN TABLE t2 (~1000000 rows)}
2 0 0 {SCAN TABLE t2}
2 0 0 {USE TEMP B-TREE FOR ORDER BY}
0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (UNION)}
}
do_eqp_test 4.2.4 {
SELECT * FROM t1 INTERSECT SELECT * FROM t2 ORDER BY 1
} {
1 0 0 {SCAN TABLE t1 (~1000000 rows)}
1 0 0 {SCAN TABLE t1}
1 0 0 {USE TEMP B-TREE FOR ORDER BY}
2 0 0 {SCAN TABLE t2 (~1000000 rows)}
2 0 0 {SCAN TABLE t2}
2 0 0 {USE TEMP B-TREE FOR ORDER BY}
0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (INTERSECT)}
}
do_eqp_test 4.2.5 {
SELECT * FROM t1 EXCEPT SELECT * FROM t2 ORDER BY 1
} {
1 0 0 {SCAN TABLE t1 (~1000000 rows)}
1 0 0 {SCAN TABLE t1}
1 0 0 {USE TEMP B-TREE FOR ORDER BY}
2 0 0 {SCAN TABLE t2 (~1000000 rows)}
2 0 0 {SCAN TABLE t2}
2 0 0 {USE TEMP B-TREE FOR ORDER BY}
0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)}
}
@@ -338,28 +338,28 @@ do_eqp_test 4.2.5 {
do_eqp_test 4.3.1 {
SELECT x FROM t1 UNION SELECT x FROM t2
} {
1 0 0 {SCAN TABLE t1 (~1000000 rows)}
2 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1 (~1000000 rows)}
1 0 0 {SCAN TABLE t1}
2 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1}
0 0 0 {COMPOUND SUBQUERIES 1 AND 2 USING TEMP B-TREE (UNION)}
}
do_eqp_test 4.3.2 {
SELECT x FROM t1 UNION SELECT x FROM t2 UNION SELECT x FROM t1
} {
2 0 0 {SCAN TABLE t1 (~1000000 rows)}
3 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1 (~1000000 rows)}
2 0 0 {SCAN TABLE t1}
3 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1}
1 0 0 {COMPOUND SUBQUERIES 2 AND 3 USING TEMP B-TREE (UNION)}
4 0 0 {SCAN TABLE t1 (~1000000 rows)}
4 0 0 {SCAN TABLE t1}
0 0 0 {COMPOUND SUBQUERIES 1 AND 4 USING TEMP B-TREE (UNION)}
}
do_eqp_test 4.3.3 {
SELECT x FROM t1 UNION SELECT x FROM t2 UNION SELECT x FROM t1 ORDER BY 1
} {
2 0 0 {SCAN TABLE t1 (~1000000 rows)}
2 0 0 {SCAN TABLE t1}
2 0 0 {USE TEMP B-TREE FOR ORDER BY}
3 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1 (~1000000 rows)}
3 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1}
1 0 0 {COMPOUND SUBQUERIES 2 AND 3 (UNION)}
4 0 0 {SCAN TABLE t1 (~1000000 rows)}
4 0 0 {SCAN TABLE t1}
4 0 0 {USE TEMP B-TREE FOR ORDER BY}
0 0 0 {COMPOUND SUBQUERIES 1 AND 4 (UNION)}
}
@@ -371,127 +371,127 @@ do_eqp_test 4.3.3 {
drop_all_tables
# EVIDENCE-OF: R-64208-08323 sqlite> EXPLAIN QUERY PLAN SELECT a, b
# FROM t1 WHERE a=1; 0|0|0|SCAN TABLE t1 (~100000 rows)
# FROM t1 WHERE a=1; 0|0|0|SCAN TABLE t1
do_execsql_test 5.1.0 { CREATE TABLE t1(a, b) }
det 5.1.1 "SELECT a, b FROM t1 WHERE a=1" {
0 0 0 {SCAN TABLE t1 (~100000 rows)}
0 0 0 {SCAN TABLE t1}
}
# EVIDENCE-OF: R-09022-44606 sqlite> CREATE INDEX i1 ON t1(a);
# sqlite> EXPLAIN QUERY PLAN SELECT a, b FROM t1 WHERE a=1;
# 0|0|0|SEARCH TABLE t1 USING INDEX i1 (a=?) (~10 rows)
# 0|0|0|SEARCH TABLE t1 USING INDEX i1 (a=?)
do_execsql_test 5.2.0 { CREATE INDEX i1 ON t1(a) }
det 5.2.1 "SELECT a, b FROM t1 WHERE a=1" {
0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~10 rows)}
0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}
}
# EVIDENCE-OF: R-62228-34103 sqlite> CREATE INDEX i2 ON t1(a, b);
# sqlite> EXPLAIN QUERY PLAN SELECT a, b FROM t1 WHERE a=1;
# 0|0|0|SEARCH TABLE t1 USING COVERING INDEX i2 (a=?) (~10 rows)
# 0|0|0|SEARCH TABLE t1 USING COVERING INDEX i2 (a=?)
do_execsql_test 5.3.0 { CREATE INDEX i2 ON t1(a, b) }
det 5.3.1 "SELECT a, b FROM t1 WHERE a=1" {
0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i2 (a=?) (~10 rows)}
0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i2 (a=?)}
}
# EVIDENCE-OF: R-22253-05302 sqlite> EXPLAIN QUERY PLAN SELECT t1.*,
# t2.* FROM t1, t2 WHERE t1.a=1 AND t1.b>2; 0|0|0|SEARCH TABLE t1
# USING COVERING INDEX i2 (a=? AND b>?) (~3 rows) 0|1|1|SCAN TABLE t2
# (~1000000 rows)
# USING COVERING INDEX i2 (a=? AND b>?) 0|1|1|SCAN TABLE t2
#
do_execsql_test 5.4.0 {CREATE TABLE t2(c, d)}
det 5.4.1 "SELECT t1.*, t2.* FROM t1, t2 WHERE t1.a=1 AND t1.b>2" {
0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i2 (a=? AND b>?) (~2 rows)}
0 1 1 {SCAN TABLE t2 (~1000000 rows)}
0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i2 (a=? AND b>?)}
0 1 1 {SCAN TABLE t2}
}
# EVIDENCE-OF: R-21040-07025 sqlite> EXPLAIN QUERY PLAN SELECT t1.*,
# t2.* FROM t2, t1 WHERE t1.a=1 AND t1.b>2; 0|0|1|SEARCH TABLE t1
# USING COVERING INDEX i2 (a=? AND b>?) (~3 rows) 0|1|0|SCAN TABLE t2
# (~1000000 rows)
# USING COVERING INDEX i2 (a=? AND b>?) 0|1|0|SCAN TABLE t2
#
det 5.5 "SELECT t1.*, t2.* FROM t2, t1 WHERE t1.a=1 AND t1.b>2" {
0 0 1 {SEARCH TABLE t1 USING COVERING INDEX i2 (a=? AND b>?) (~2 rows)}
0 1 0 {SCAN TABLE t2 (~1000000 rows)}
0 0 1 {SEARCH TABLE t1 USING COVERING INDEX i2 (a=? AND b>?)}
0 1 0 {SCAN TABLE t2}
}
# EVIDENCE-OF: R-39007-61103 sqlite> CREATE INDEX i3 ON t1(b);
# sqlite> EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=1 OR b=2;
# 0|0|0|SEARCH TABLE t1 USING COVERING INDEX i2 (a=?) (~10 rows)
# 0|0|0|SEARCH TABLE t1 USING INDEX i3 (b=?) (~10 rows)
# 0|0|0|SEARCH TABLE t1 USING COVERING INDEX i2 (a=?)
# 0|0|0|SEARCH TABLE t1 USING INDEX i3 (b=?)
do_execsql_test 5.5.0 {CREATE INDEX i3 ON t1(b)}
det 5.6.1 "SELECT * FROM t1 WHERE a=1 OR b=2" {
0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i2 (a=?) (~10 rows)}
0 0 0 {SEARCH TABLE t1 USING INDEX i3 (b=?) (~10 rows)}
0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i2 (a=?)}
0 0 0 {SEARCH TABLE t1 USING INDEX i3 (b=?)}
}
# EVIDENCE-OF: R-33025-54904 sqlite> EXPLAIN QUERY PLAN SELECT c, d
# FROM t2 ORDER BY c; 0|0|0|SCAN TABLE t2 (~1000000 rows) 0|0|0|USE TEMP
# FROM t2 ORDER BY c; 0|0|0|SCAN TABLE t2 0|0|0|USE TEMP
# B-TREE FOR ORDER BY
det 5.7 "SELECT c, d FROM t2 ORDER BY c" {
0 0 0 {SCAN TABLE t2 (~1000000 rows)}
0 0 0 {SCAN TABLE t2}
0 0 0 {USE TEMP B-TREE FOR ORDER BY}
}
# EVIDENCE-OF: R-38854-22809 sqlite> CREATE INDEX i4 ON t2(c);
# sqlite> EXPLAIN QUERY PLAN SELECT c, d FROM t2 ORDER BY c;
# 0|0|0|SCAN TABLE t2 USING INDEX i4 (~1000000 rows)
# 0|0|0|SCAN TABLE t2 USING INDEX i4
do_execsql_test 5.8.0 {CREATE INDEX i4 ON t2(c)}
det 5.8.1 "SELECT c, d FROM t2 ORDER BY c" {
0 0 0 {SCAN TABLE t2 USING INDEX i4 (~1000000 rows)}
0 0 0 {SCAN TABLE t2 USING INDEX i4}
}
# EVIDENCE-OF: R-29884-43993 sqlite> EXPLAIN QUERY PLAN SELECT
# (SELECT b FROM t1 WHERE a=0), (SELECT a FROM t1 WHERE b=t2.c) FROM t2;
# 0|0|0|SCAN TABLE t2 (~1000000 rows) 0|0|0|EXECUTE SCALAR SUBQUERY 1
# 1|0|0|SEARCH TABLE t1 USING COVERING INDEX i2 (a=?) (~10 rows)
# 0|0|0|SCAN TABLE t2 0|0|0|EXECUTE SCALAR SUBQUERY 1
# 1|0|0|SEARCH TABLE t1 USING COVERING INDEX i2 (a=?)
# 0|0|0|EXECUTE CORRELATED SCALAR SUBQUERY 2 2|0|0|SEARCH TABLE t1 USING
# INDEX i3 (b=?) (~10 rows)
# INDEX i3 (b=?)
det 5.9 {
SELECT (SELECT b FROM t1 WHERE a=0), (SELECT a FROM t1 WHERE b=t2.c) FROM t2
} {
0 0 0 {SCAN TABLE t2 USING COVERING INDEX i4 (~1000000 rows)}
0 0 0 {SCAN TABLE t2 USING COVERING INDEX i4}
0 0 0 {EXECUTE SCALAR SUBQUERY 1}
1 0 0 {SEARCH TABLE t1 USING COVERING INDEX i2 (a=?) (~10 rows)}
1 0 0 {SEARCH TABLE t1 USING COVERING INDEX i2 (a=?)}
0 0 0 {EXECUTE CORRELATED SCALAR SUBQUERY 2}
2 0 0 {SEARCH TABLE t1 USING INDEX i3 (b=?) (~10 rows)}
2 0 0 {SEARCH TABLE t1 USING INDEX i3 (b=?)}
}
# EVIDENCE-OF: R-17911-16445 sqlite> EXPLAIN QUERY PLAN SELECT
# count(*) FROM (SELECT max(b) AS x FROM t1 GROUP BY a) GROUP BY x;
# 1|0|0|SCAN TABLE t1 USING COVERING INDEX i2 (~1000000 rows) 0|0|0|SCAN
# SUBQUERY 1 (~1000000 rows) 0|0|0|USE TEMP B-TREE FOR GROUP BY
# 1|0|0|SCAN TABLE t1 USING COVERING INDEX i2 0|0|0|SCAN
# SUBQUERY 1 0|0|0|USE TEMP B-TREE FOR GROUP BY
det 5.10 {
SELECT count(*) FROM (SELECT max(b) AS x FROM t1 GROUP BY a) GROUP BY x
} {
1 0 0 {SCAN TABLE t1 USING COVERING INDEX i2 (~1000000 rows)}
0 0 0 {SCAN SUBQUERY 1 (~100 rows)}
1 0 0 {SCAN TABLE t1 USING COVERING INDEX i2}
0 0 0 {SCAN SUBQUERY 1}
0 0 0 {USE TEMP B-TREE FOR GROUP BY}
}
# EVIDENCE-OF: R-18544-33103 sqlite> EXPLAIN QUERY PLAN SELECT * FROM
# (SELECT * FROM t2 WHERE c=1), t1; 0|0|0|SEARCH TABLE t2 USING INDEX i4
# (c=?) (~10 rows) 0|1|1|SCAN TABLE t1 (~1000000 rows)
# (c=?) 0|1|1|SCAN TABLE t1
det 5.11 "SELECT * FROM (SELECT * FROM t2 WHERE c=1), t1" {
0 0 0 {SEARCH TABLE t2 USING INDEX i4 (c=?) (~10 rows)}
0 1 1 {SCAN TABLE t1 USING COVERING INDEX i2 (~1000000 rows)}
0 0 0 {SEARCH TABLE t2 USING INDEX i4 (c=?)}
0 1 1 {SCAN TABLE t1 USING COVERING INDEX i2}
}
# EVIDENCE-OF: R-40701-42164 sqlite> EXPLAIN QUERY PLAN SELECT a FROM
# t1 UNION SELECT c FROM t2; 1|0|0|SCAN TABLE t1 (~1000000 rows)
# 2|0|0|SCAN TABLE t2 (~1000000 rows) 0|0|0|COMPOUND SUBQUERIES 1 AND 2
# t1 UNION SELECT c FROM t2; 1|0|0|SCAN TABLE t1
# 2|0|0|SCAN TABLE t2 0|0|0|COMPOUND SUBQUERIES 1 AND 2
# USING TEMP B-TREE (UNION)
det 5.12 "SELECT a FROM t1 UNION SELECT c FROM t2" {
1 0 0 {SCAN TABLE t1 USING COVERING INDEX i1 (~1000000 rows)}
2 0 0 {SCAN TABLE t2 USING COVERING INDEX i4 (~1000000 rows)}
1 0 0 {SCAN TABLE t1 USING COVERING INDEX i2}
2 0 0 {SCAN TABLE t2 USING COVERING INDEX i4}
0 0 0 {COMPOUND SUBQUERIES 1 AND 2 USING TEMP B-TREE (UNION)}
}
# EVIDENCE-OF: R-61538-24748 sqlite> EXPLAIN QUERY PLAN SELECT a FROM
# t1 EXCEPT SELECT d FROM t2 ORDER BY 1; 1|0|0|SCAN TABLE t1 USING
# COVERING INDEX i2 (~1000000 rows) 2|0|0|SCAN TABLE t2 (~1000000 rows)
# COVERING INDEX i2 2|0|0|SCAN TABLE t2
# 2|0|0|USE TEMP B-TREE FOR ORDER BY 0|0|0|COMPOUND SUBQUERIES 1 AND 2
# (EXCEPT)
det 5.13 "SELECT a FROM t1 EXCEPT SELECT d FROM t2 ORDER BY 1" {
1 0 0 {SCAN TABLE t1 USING COVERING INDEX i2 (~1000000 rows)}
2 0 0 {SCAN TABLE t2 (~1000000 rows)}
1 0 0 {SCAN TABLE t1 USING COVERING INDEX i2}
2 0 0 {SCAN TABLE t2}
2 0 0 {USE TEMP B-TREE FOR ORDER BY}
0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)}
}
@@ -531,8 +531,8 @@ proc do_peqp_test {tn sql res} {
do_peqp_test 6.1 {
SELECT a FROM t1 EXCEPT SELECT d FROM t2 ORDER BY 1
} [string trimleft {
1 0 0 SCAN TABLE t1 USING COVERING INDEX i2 (~1000000 rows)
2 0 0 SCAN TABLE t2 (~1000000 rows)
1 0 0 SCAN TABLE t1 USING COVERING INDEX i2
2 0 0 SCAN TABLE t2
2 0 0 USE TEMP B-TREE FOR ORDER BY
0 0 0 COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)
}]
@@ -550,11 +550,11 @@ do_execsql_test 7.0 {
}
det 7.1 "SELECT count(*) FROM t1" {
0 0 0 {SCAN TABLE t1 (~1000000 rows)}
0 0 0 {SCAN TABLE t1}
}
det 7.2 "SELECT count(*) FROM t2" {
0 0 0 {SCAN TABLE t2 USING COVERING INDEX i1(~1000000 rows)}
0 0 0 {SCAN TABLE t2 USING COVERING INDEX i1}
}
do_execsql_test 7.3 {
@@ -572,11 +572,11 @@ db close
sqlite3 db test.db
det 7.4 "SELECT count(*) FROM t1" {
0 0 0 {SCAN TABLE t1 (~2 rows)}
0 0 0 {SCAN TABLE t1}
}
det 7.5 "SELECT count(*) FROM t2" {
0 0 0 {SCAN TABLE t2 USING COVERING INDEX i1(~3 rows)}
0 0 0 {SCAN TABLE t2 USING COVERING INDEX i1}
}
-1
View File
@@ -506,4 +506,3 @@ do_execsql_test exclusive-6.5 {
} {exclusive}
finish_test
-1
View File
@@ -143,4 +143,3 @@ if {!$skipwaltests} {
finish_test
-1
View File
@@ -248,4 +248,3 @@ do_test filefmt-4.4 {
db2 close
finish_test
-1
View File
@@ -224,4 +224,3 @@ do_catchsql_test fts3aa-7.5 {
finish_test
-1
View File
@@ -220,4 +220,3 @@ do_execsql_test 5.2 {
} {0 6}
finish_test
-2
View File
@@ -193,5 +193,3 @@ do_test fts3token-internal {
finish_test
-1
View File
@@ -707,4 +707,3 @@ foreach {tn create} {
set sqlite_fts3_enable_parentheses $sfep
finish_test
+17 -18
View File
@@ -105,10 +105,10 @@ db func rec rec
#
do_execsql_test 2.1.1.1 {
EXPLAIN QUERY PLAN SELECT * FROM terms WHERE term='braid'
} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 1: (~0 rows)} }
} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 1:} }
do_execsql_test 2.1.1.2 {
EXPLAIN QUERY PLAN SELECT * FROM terms WHERE +term='braid'
} {0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0: (~0 rows)}}
} {0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0:}}
# Now show that using "term='braid'" means the virtual table returns
# only 1 row to SQLite, but "+term='braid'" means all 19 are returned.
@@ -154,24 +154,24 @@ do_execsql_test 2.1.5 { SELECT * FROM terms WHERE term=NULL } {}
do_execsql_test 2.2.1.1 {
EXPLAIN QUERY PLAN SELECT * FROM terms WHERE term>'brain'
} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 2: (~0 rows)} }
} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 2:} }
do_execsql_test 2.2.1.2 {
EXPLAIN QUERY PLAN SELECT * FROM terms WHERE +term>'brain'
} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0: (~0 rows)} }
} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0:} }
do_execsql_test 2.2.1.3 {
EXPLAIN QUERY PLAN SELECT * FROM terms WHERE term<'brain'
} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 4: (~0 rows)} }
} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 4:} }
do_execsql_test 2.2.1.4 {
EXPLAIN QUERY PLAN SELECT * FROM terms WHERE +term<'brain'
} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0: (~0 rows)} }
} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0:} }
do_execsql_test 2.2.1.5 {
EXPLAIN QUERY PLAN SELECT * FROM terms WHERE term BETWEEN 'brags' AND 'brain'
} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 6: (~0 rows)} }
} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 6:} }
do_execsql_test 2.2.1.6 {
EXPLAIN QUERY PLAN SELECT * FROM terms WHERE +term BETWEEN 'brags' AND 'brain'
} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0: (~0 rows)} }
} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0:} }
do_test 2.2.2.1 {
set cnt 0
@@ -335,7 +335,7 @@ foreach {tn sort orderby} {
9 1 "ORDER BY occurrences DESC"
} {
set res [list 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0: (~0 rows)}]
set res [list 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0:}]
if {$sort} { lappend res 0 0 0 {USE TEMP B-TREE FOR ORDER BY} }
set sql "SELECT * FROM terms $orderby"
@@ -410,32 +410,32 @@ proc do_plansql_test {tn sql r} {
do_plansql_test 4.2 {
SELECT y FROM x2, terms WHERE y = term AND col = '*'
} {
0 0 0 {SCAN TABLE x2 (~1000000 rows)}
0 1 1 {SCAN TABLE terms VIRTUAL TABLE INDEX 1: (~0 rows)}
0 0 0 {SCAN TABLE x2}
0 1 1 {SCAN TABLE terms VIRTUAL TABLE INDEX 1:}
a b c d e f g h i j k l
}
do_plansql_test 4.3 {
SELECT y FROM terms, x2 WHERE y = term AND col = '*'
} {
0 0 1 {SCAN TABLE x2 (~1000000 rows)}
0 1 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 1: (~0 rows)}
0 0 1 {SCAN TABLE x2}
0 1 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 1:}
a b c d e f g h i j k l
}
do_plansql_test 4.4 {
SELECT y FROM x3, terms WHERE y = term AND col = '*'
} {
0 0 1 {SCAN TABLE terms VIRTUAL TABLE INDEX 0: (~0 rows)}
0 1 0 {SEARCH TABLE x3 USING COVERING INDEX i1 (y=?) (~10 rows)}
0 0 1 {SCAN TABLE terms VIRTUAL TABLE INDEX 0:}
0 1 0 {SEARCH TABLE x3 USING COVERING INDEX i1 (y=?)}
a b c d e f g h i j k l
}
do_plansql_test 4.5 {
SELECT y FROM terms, x3 WHERE y = term AND occurrences>1 AND col = '*'
} {
0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0: (~0 rows)}
0 1 1 {SEARCH TABLE x3 USING COVERING INDEX i1 (y=?) (~10 rows)}
0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0:}
0 1 1 {SEARCH TABLE x3 USING COVERING INDEX i1 (y=?)}
a k l
}
@@ -519,4 +519,3 @@ do_test 8.2 {
} {1 {SQL logic error or missing database}}
finish_test
-1
View File
@@ -166,4 +166,3 @@ do_test 5.3.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB
finish_test
-1
View File
@@ -153,4 +153,3 @@ foreach {tn sql} {
finish_test
-4
View File
@@ -204,7 +204,3 @@ do_faultsim_test fts3expr3-fault-1 -faults oom-* -body {
set sqlite_fts3_enable_parentheses 0
finish_test
+4 -1
View File
@@ -62,6 +62,9 @@ do_error_test fts3_malloc-1.5 {
do_write_test fts3_malloc-1.6 sqlite_master {
CREATE VIRTUAL TABLE ft6 USING fts3(a, b, tokenize porter)
}
do_write_test fts3_malloc-1.7 sqlite_master {
CREATE VIRTUAL TABLE ft7 USING fts4(a, b, notindexed=b)
}
# Test the xConnect/xDisconnect methods:
#db eval { ATTACH 'test2.db' AS aux }
@@ -81,6 +84,7 @@ do_test fts3_malloc-2.0 {
DROP TABLE ft3;
DROP TABLE ft4;
DROP TABLE ft6;
DROP TABLE ft7;
}
execsql { CREATE VIRTUAL TABLE ft USING fts3(a, b) }
for {set ii 1} {$ii < 32} {incr ii} {
@@ -301,4 +305,3 @@ do_write_test fts3_malloc-5.3 ft_content {
finish_test
-1
View File
@@ -427,4 +427,3 @@ do_execsql_test 8.3 {
}
finish_test
-1
View File
@@ -59,4 +59,3 @@ do_execsql_test 1.3 {
}
finish_test
+8 -9
View File
@@ -118,26 +118,26 @@ do_test fts3query-4.1 {
do_eqp_test fts3query-4.2 {
SELECT t1.number FROM t1, ft WHERE t1.number=ft.rowid ORDER BY t1.date
} {
0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1 (~1000000 rows)}
0 1 1 {SCAN TABLE ft VIRTUAL TABLE INDEX 1: (~0 rows)}
0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1}
0 1 1 {SCAN TABLE ft VIRTUAL TABLE INDEX 1:}
}
do_eqp_test fts3query-4.3 {
SELECT t1.number FROM ft, t1 WHERE t1.number=ft.rowid ORDER BY t1.date
} {
0 0 1 {SCAN TABLE t1 USING COVERING INDEX i1 (~1000000 rows)}
0 1 0 {SCAN TABLE ft VIRTUAL TABLE INDEX 1: (~0 rows)}
0 0 1 {SCAN TABLE t1 USING COVERING INDEX i1}
0 1 0 {SCAN TABLE ft VIRTUAL TABLE INDEX 1:}
}
do_eqp_test fts3query-4.4 {
SELECT t1.number FROM t1, bt WHERE t1.number=bt.rowid ORDER BY t1.date
} {
0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1 (~1000000 rows)}
0 1 1 {SEARCH TABLE bt USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1}
0 1 1 {SEARCH TABLE bt USING INTEGER PRIMARY KEY (rowid=?)}
}
do_eqp_test fts3query-4.5 {
SELECT t1.number FROM bt, t1 WHERE t1.number=bt.rowid ORDER BY t1.date
} {
0 0 1 {SCAN TABLE t1 USING COVERING INDEX i1 (~1000000 rows)}
0 1 0 {SEARCH TABLE bt USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
0 0 1 {SCAN TABLE t1 USING COVERING INDEX i1}
0 1 0 {SEARCH TABLE bt USING INTEGER PRIMARY KEY (rowid=?)}
}
@@ -210,4 +210,3 @@ do_select_tests 6.2 {
finish_test
+105 -1
View File
@@ -1,3 +1,4 @@
#
# 2010 September 17
#
# May you do good and not evil.
@@ -5,6 +6,9 @@
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library. The
# focus of this file is the interactions between the FTS3/4 module
# and shared-cache mode.
#
set testdir [file dirname $argv0]
@@ -14,6 +18,7 @@ ifcapable !fts3||!shared_cache {
finish_test
return
}
set ::testprefix fts3shared
db close
set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
@@ -67,6 +72,105 @@ do_test fts3shared-1.6 { sqlite3_get_autocommit db2 } 0
db close
db2 close
#-------------------------------------------------------------------------
# The following tests - fts3shared-2.* - test that unless FTS is bypassed
# and the underlying tables accessed directly, it is not possible for an
# SQLITE_LOCKED error to be enountered when committing an FTS transaction.
#
# Any SQLITE_LOCKED error should be returned when the fts4 (or fts4aux)
# table is first read/written within a transaction, not later on.
#
set LOCKED {1 {database table is locked}}
forcedelete test.db
sqlite3 dbR test.db
sqlite3 dbW test.db
do_test 2.1 {
execsql {
CREATE VIRTUAL TABLE t1 USING fts4;
CREATE TABLE t2ext(a, b);
CREATE VIRTUAL TABLE t2 USING fts4(content=t2ext);
CREATE VIRTUAL TABLE t1aux USING fts4aux(t1);
CREATE VIRTUAL TABLE t2aux USING fts4aux(t2);
INSERT INTO t1 VALUES('a b c');
INSERT INTO t2(rowid, a, b) VALUES(1, 'd e f', 'g h i');
} dbW
} {}
# Test that once [dbW] has written to the FTS table, no client may read
# from the FTS or fts4aux table.
do_test 2.2.1 {
execsql {
BEGIN;
INSERT INTO t1 VALUES('j k l');
} dbW
execsql BEGIN dbR
} {}
do_test 2.2.2 { catchsql "SELECT * FROM t1 WHERE rowid=1" dbR } $LOCKED
do_test 2.2.3 { catchsql "SELECT * FROM t1 WHERE t1 MATCH 'a'" dbR } $LOCKED
do_test 2.2.4 { catchsql "SELECT rowid FROM t1 WHERE t1 MATCH 'a'" dbR } $LOCKED
do_test 2.2.5 { catchsql "SELECT * FROM t1" dbR } $LOCKED
do_test 2.2.6 { catchsql "SELECT * FROM t1aux" dbR } $LOCKED
do_test 2.2.7 { execsql COMMIT dbW } {}
do_test 2.2.8 { execsql COMMIT dbR } {}
# Same test as 2.2.*, except with a content= table.
#
do_test 2.3.1 {
execsql {
BEGIN;
INSERT INTO t2(rowid, a, b) VALUES(2, 'j k l', 'm n o');
} dbW
execsql BEGIN dbR
} {}
do_test 2.3.3 { catchsql "SELECT * FROM t2 WHERE t2 MATCH 'a'" dbR } $LOCKED
do_test 2.3.4 { catchsql "SELECT rowid FROM t2 WHERE t2 MATCH 'a'" dbR } $LOCKED
do_test 2.3.6 { catchsql "SELECT * FROM t2aux" dbR } $LOCKED
do_test 2.3.7 { execsql COMMIT dbW } {}
do_test 2.3.8 { execsql COMMIT dbR } {}
# Test that once a connection has read from the FTS or fts4aux table,
# another connection may not write to the FTS table.
#
foreach {tn sql} {
1 "SELECT * FROM t1 WHERE rowid=1"
2 "SELECT * FROM t1 WHERE t1 MATCH 'a'"
3 "SELECT rowid FROM t1 WHERE t1 MATCH 'a'"
4 "SELECT * FROM t1"
5 "SELECT * FROM t1aux"
} {
do_test 2.4.$tn {
execsql BEGIN dbR
execsql $::sql dbR
execsql BEGIN dbW
catchsql "INSERT INTO t1 VALUES('p q r')" dbW
} $LOCKED
execsql ROLLBACK dbR
execsql ROLLBACK dbW
}
# Same test as 2.4.*, except with a content= table.
#
foreach {tn sql} {
2 "SELECT * FROM t2 WHERE t2 MATCH 'a'"
3 "SELECT rowid FROM t2 WHERE t2 MATCH 'a'"
5 "SELECT * FROM t2aux"
} {
do_test 2.5.$tn {
execsql BEGIN dbR
execsql $::sql dbR
execsql BEGIN dbW
catchsql "INSERT INTO t2(rowid, a, b) VALUES(3, 's t u', 'v w x')" dbW
} $LOCKED
execsql ROLLBACK dbR
execsql ROLLBACK dbW
}
dbW close
dbR close
sqlite3_enable_shared_cache $::enable_shared_cache
finish_test
+4 -4
View File
@@ -432,10 +432,10 @@ foreach {DO_MALLOC_TEST enc} {
{2 2 1 3 3 3 6 3 0 0 0 2 3 2}
}]
# EVIDENCE-OF: R-40630-02268 If used within a SELECT that uses the
# "query by rowid" or "linear scan" strategies, then the snippet and
# offsets both return an empty string, and the matchinfo function
# returns a blob value zero bytes in size.
# EVIDENCE-OF: R-40630-02268 If used within a SELECT that uses the
# "query by rowid" or "linear scan" strategies, then the snippet and
# offsets both return an empty string, and the matchinfo function
# returns a blob value zero bytes in size.
#
set r 1000000 ;# A rowid that exists in table ft
do_select_test $T.10.0 { SELECT rowid FROM ft WHERE rowid = $r } $r
-1
View File
@@ -182,4 +182,3 @@ do_execsql_test 3.2 {
finish_test
-2
View File
@@ -113,5 +113,3 @@ do_catchsql_test 2.1 {
finish_test
-2
View File
@@ -45,5 +45,3 @@ do_faultsim_test fts3tok_err-2 -faults oom* -prep {
finish_test
-1
View File
@@ -623,4 +623,3 @@ do_execsql_test 10.7 {
}
finish_test
+58
View File
@@ -0,0 +1,58 @@
# 2013 May 29
#
# 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.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/fts3_common.tcl
set ::testprefix fts4merge4
ifcapable !fts3 {
finish_test
return
}
set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
do_execsql_test 1.1 { CREATE VIRTUAL TABLE t1 USING fts4 }
do_test 1.2 {
for {set i 0} {$i < 2000} {incr i} {
execsql {INSERT INTO t1 VALUES('a b c d e f g h i j k l');}
}
} {}
do_test 1.3 {
execsql BEGIN
for {set i 0} {$i < 2000} {incr i} {
execsql {INSERT INTO t1 VALUES('a b c d e f g h i j k l');}
}
execsql {
INSERT INTO t1(t1) VALUES('merge=8,50');
COMMIT
}
} {}
reset_db
do_execsql_test 2.0 { CREATE VIRTUAL TABLE t1 USING fts4 }
do_test 2.1 {
for {set i 0} {$i < 2000} {incr i} {
execsql {INSERT INTO t1 VALUES('a b c d e f g h i j k l');}
}
} {}
do_execsql_test 2.2 { SELECT count(*) FROM t1_segdir; } 35
do_execsql_test 2.3 { INSERT INTO t1(t1) VALUES('optimize') } {}
do_execsql_test 2.4 { SELECT count(*) FROM t1_segdir; } 1
sqlite3_enable_shared_cache $::enable_shared_cache
finish_test
+171
View File
@@ -0,0 +1,171 @@
# 2013 June 21
#
# 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 the notindexed=xxx FTS4 option.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set ::testprefix fts4noti
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
ifcapable !fts3 {
finish_test
return
}
#-------------------------------------------------------------------------
# Test that typos in "notindexed=" column names are detected.
#
do_execsql_test 1.0 {
CREATE TABLE cc(a, b, c);
}
foreach {tn arg res} {
1 "(b, c, notindexed=a)" {1 {no such column: a}}
2 "(a, b, notindexed=a)" {0 {}}
3 "(a, b, notindexed=a, notindexed=a)" {0 {}}
4 "(notindexed=a, a, b)" {0 {}}
5 "(notindexed=a, notindexed=b, notindexed=c, a, b, c, d)" {0 {}}
6 "(notindexed=a, notindexed=B, notindexed=c, a, b, c, d)" {0 {}}
7 "(notindexed=a, notindexed=b, notindexed=c, a, B, c, d)" {0 {}}
8 "(notindexed=d, content=cc)" {1 {no such column: d}}
9 "(notindexed=a, content=cc)" {0 {}}
10 "(notindexed=a, notindexed=b, a)" {1 {no such column: b}}
11 "(notindexed=a, notindexed=b, b)" {1 {no such column: a}}
} {
do_catchsql_test 1.$tn "CREATE VIRTUAL TABLE t1 USING fts4 $arg" $res
if {[lindex $res 0]==0} { execsql "DROP TABLE t1" }
}
do_execsql_test 1.x { SELECT name FROM sqlite_master } {cc}
#-------------------------------------------------------------------------
# Test that notindexed columns are not indexed.
#
foreach {tn schema} {
1 {
CREATE VIRTUAL TABLE t1 USING fts4(a, b, c, notindexed=b);
}
2 {
CREATE TABLE c1(a, b, c);
INSERT INTO c1 VALUES('one two', 'three four', 'five six');
INSERT INTO c1 VALUES('three four', 'five six', 'one two');
CREATE VIRTUAL TABLE t1 USING fts4(content=c1, notindexed=b);
}
3 {
CREATE VIRTUAL TABLE t1 USING fts4(content="", a, b, c, notindexed=b);
}
} {
execsql $schema
do_execsql_test 2.$tn.1 {
INSERT INTO t1(docid,a,b,c) VALUES(1, 'one two', 'three four', 'five six');
INSERT INTO t1(docid,a,b,c) VALUES(2, 'three four', 'five six', 'one two');
}
do_execsql_test 2.$tn.2 { SELECT docid FROM t1 WHERE t1 MATCH 'one' } {1 2}
do_execsql_test 2.$tn.3 { SELECT docid FROM t1 WHERE t1 MATCH 'three' } {2}
do_execsql_test 2.$tn.4 { SELECT docid FROM t1 WHERE t1 MATCH 'five' } {1}
do_execsql_test 2.$tn.5 { INSERT INTO t1(t1) VALUES('optimize') }
do_execsql_test 2.$tn.6 { SELECT docid FROM t1 WHERE t1 MATCH 'one' } {1 2}
do_execsql_test 2.$tn.7 { SELECT docid FROM t1 WHERE t1 MATCH 'three' } {2}
do_execsql_test 2.$tn.8 { SELECT docid FROM t1 WHERE t1 MATCH 'five' } {1}
if {$tn!=3} {
do_execsql_test 2.$tn.9 { INSERT INTO t1(t1) VALUES('rebuild') }
do_execsql_test 2.$tn.10 { SELECT docid FROM t1 WHERE t1 MATCH 'one' } {1 2}
do_execsql_test 2.$tn.11 { SELECT docid FROM t1 WHERE t1 MATCH 'three' } {2}
do_execsql_test 2.$tn.12 { SELECT docid FROM t1 WHERE t1 MATCH 'five' } {1}
do_execsql_test 2.$tn.13 {
SELECT a,b,c FROM t1 WHERE docid=1
} {{one two} {three four} {five six}}
do_execsql_test 2.$tn.14 {
SELECT a,b,c FROM t1 WHERE docid=2
} {{three four} {five six} {one two}}
}
do_execsql_test 2.x { DROP TABLE t1 }
}
#-------------------------------------------------------------------------
# Test that notindexed columns are not scanned for deferred tokens.
#
do_execsql_test 3.1 {
CREATE VIRTUAL TABLE t2 USING fts4(x, y, notindexed=x);
}
do_test 3.2 {
set v [string repeat " 1" 50000]
set v1 "x $v"
set v2 "y $v"
execsql {
INSERT INTO t2 VALUES(1, 'x y z');
INSERT INTO t2 VALUES(2, $v1);
INSERT INTO t2 VALUES(3, $v2);
INSERT INTO t2 VALUES(4, $v2);
INSERT INTO t2 VALUES(5, $v2);
INSERT INTO t2 VALUES(6, $v2);
}
} {}
do_execsql_test 3.3 { SELECT x FROM t2 WHERE t2 MATCH '2' } {}
do_execsql_test 3.4 { SELECT x FROM t2 WHERE t2 MATCH '1' } {2 3 4 5 6}
do_execsql_test 3.5 { SELECT x FROM t2 WHERE t2 MATCH 'x' } {1 2}
do_execsql_test 3.6 { SELECT x FROM t2 WHERE t2 MATCH 'x 1' } {2}
do_execsql_test 3.x { DROP TABLE t2 }
#-------------------------------------------------------------------------
# Test that the types of notindexed columns are not modified.
#
do_execsql_test 4.1 {
CREATE VIRTUAL TABLE t2 USING fts4(poi, addr, notindexed=poi);
INSERT INTO t2 VALUES(114, 'x x x');
INSERT INTO t2 VALUES(X'1234', 'y y y');
INSERT INTO t2 VALUES(NULL, 'z z z');
INSERT INTO t2 VALUES(113.2, 'w w w');
INSERT INTO t2 VALUES('poi', 'v v v');
}
do_execsql_test 4.2 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'x' } {integer}
do_execsql_test 4.3 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'y' } {blob}
do_execsql_test 4.4 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'z' } {null}
do_execsql_test 4.5 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'w' } {real}
do_execsql_test 4.6 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'v' } {text}
do_execsql_test 4.x { DROP TABLE t2 }
#-------------------------------------------------------------------------
# Test that multiple notindexed options on a single table work as expected.
#
do_execsql_test 5.1 {
CREATE VIRTUAL TABLE t2 USING fts4(
notindexed="three", one, two, three, notindexed="one",
);
INSERT INTO t2 VALUES('a', 'b', 'c');
INSERT INTO t2 VALUES('c', 'a', 'b');
INSERT INTO t2 VALUES('b', 'c', 'a');
}
do_execsql_test 5.2 { SELECT docid FROM t2 WHERE t2 MATCH 'a' } {2}
do_execsql_test 5.3 { SELECT docid FROM t2 WHERE t2 MATCH 'b' } {1}
do_execsql_test 5.4 { SELECT docid FROM t2 WHERE t2 MATCH 'c' } {3}
do_execsql_test 5.x { DROP TABLE t2 }
finish_test
+18
View File
@@ -384,5 +384,23 @@ foreach T $tokenizers {
do_isspace_test 6.$T.19 $T {8287 12288}
}
#-------------------------------------------------------------------------
# Test that the private use ranges are treated as alphanumeric.
#
breakpoint
foreach {tn1 c} {
1 \ue000 2 \ue001 3 \uf000 4 \uf8fe 5 \uf8ff
} {
foreach {tn2 config res} {
1 "" "0 hello*world hello*world"
2 "separators=*" "0 hello hello 1 world world"
} {
set config [string map [list * $c] $config]
set input [string map [list * $c] "hello*world"]
set output [string map [list * $c] $res]
do_unicode_token_test3 7.$tn1.$tn2 {*}$config $input $output
}
}
finish_test
+11 -6
View File
@@ -1728,36 +1728,41 @@ do_execsql_test 8.1 {
do_execsql_test 8.2.1 {
SELECT cFrom, cTo, word
FROM x3_rules CROSS JOIN x3
WHERE word MATCH 'a' AND cost=distance AND ruleset=2;
WHERE word MATCH 'a' AND cost=distance AND ruleset=2
ORDER BY +cTo;
} {a x x a y y a z z}
do_execsql_test 8.2.2 {
SELECT cFrom, cTo, word
FROM x3 CROSS JOIN x3_rules
WHERE word MATCH 'a' AND cost=distance AND ruleset=2;
WHERE word MATCH 'a' AND cost=distance AND ruleset=2
ORDER BY +cTo DESC
} {a z z a y y a x x}
do_execsql_test 8.2.3 {
SELECT cFrom, cTo, word
FROM x3_rules, x3
WHERE word MATCH 'a' AND cost=distance AND ruleset=2;
WHERE word MATCH 'a' AND cost=distance AND ruleset=2
ORDER BY +cTo DESC;
} {a z z a y y a x x}
do_execsql_test 8.2.4 {
SELECT cFrom, cTo, word
FROM x3, x3_rules
WHERE word MATCH 'a' AND cost=distance AND ruleset=2;
WHERE word MATCH 'a' AND cost=distance AND ruleset=2
ORDER BY +cTo DESC;
} {a z z a y y a x x}
do_execsql_test 8.2.5 {
CREATE INDEX i1 ON x3_rules(cost);
SELECT cFrom, cTo, word
FROM x3_rules, x3
WHERE word MATCH 'a' AND cost=distance AND ruleset=2;
WHERE word MATCH 'a' AND cost=distance AND ruleset=2
ORDER BY +cTo DESC;
} {a z z a y y a x x}
do_execsql_test 8.2.5 {
SELECT word FROM x3_rules, x3 WHERE word MATCH x3_rules.cFrom AND ruleset=2;
SELECT word FROM x3_rules, x3 WHERE word MATCH x3_rules.cFrom AND ruleset=2
} {a z y x a z y x a z y x}
do_execsql_test 8.2.6 {
-1
View File
@@ -269,4 +269,3 @@ db close
tvfs delete
finish_test
-1
View File
@@ -87,4 +87,3 @@ do_test 3.3 {
} {}
finish_test
-1
View File
@@ -67,4 +67,3 @@ do_faultsim_test 3 -prep {
}
finish_test
-1
View File
@@ -151,4 +151,3 @@ foreach {T jrnl_mode} {
}
finish_test
+37 -37
View File
@@ -42,15 +42,15 @@ proc EQP {sql} {
#
do_execsql_test indexedby-1.2 {
EXPLAIN QUERY PLAN select * from t1 WHERE a = 10;
} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~10 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}}
do_execsql_test indexedby-1.3 {
EXPLAIN QUERY PLAN select * from t1 ;
} {0 0 0 {SCAN TABLE t1 (~1000000 rows)}}
} {0 0 0 {SCAN TABLE t1}}
do_execsql_test indexedby-1.4 {
EXPLAIN QUERY PLAN select * from t1, t2 WHERE c = 10;
} {
0 0 1 {SEARCH TABLE t2 USING INDEX i3 (c=?) (~10 rows)}
0 1 0 {SCAN TABLE t1 (~1000000 rows)}
0 0 1 {SEARCH TABLE t2 USING INDEX i3 (c=?)}
0 1 0 {SCAN TABLE t1}
}
# Parser tests. Test that an INDEXED BY or NOT INDEX clause can be
@@ -85,21 +85,21 @@ do_test indexedby-2.7 {
#
do_execsql_test indexedby-3.1 {
EXPLAIN QUERY PLAN SELECT * FROM t1 NOT INDEXED WHERE a = 'one' AND b = 'two'
} {0 0 0 {SCAN TABLE t1 (~10000 rows)}}
} {0 0 0 {SCAN TABLE t1}}
do_execsql_test indexedby-3.2 {
EXPLAIN QUERY PLAN
SELECT * FROM t1 INDEXED BY i1 WHERE a = 'one' AND b = 'two'
} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~2 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}}
do_execsql_test indexedby-3.3 {
EXPLAIN QUERY PLAN
SELECT * FROM t1 INDEXED BY i2 WHERE a = 'one' AND b = 'two'
} {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (b=?) (~2 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (b=?)}}
do_test indexedby-3.4 {
catchsql { SELECT * FROM t1 INDEXED BY i2 WHERE a = 'one' }
} {1 {cannot use index: i2}}
} {1 {no query solution}}
do_test indexedby-3.5 {
catchsql { SELECT * FROM t1 INDEXED BY i2 ORDER BY a }
} {1 {cannot use index: i2}}
} {1 {no query solution}}
do_test indexedby-3.6 {
catchsql { SELECT * FROM t1 INDEXED BY i1 WHERE a = 'one' }
} {0 {}}
@@ -110,14 +110,14 @@ do_test indexedby-3.7 {
do_execsql_test indexedby-3.8 {
EXPLAIN QUERY PLAN
SELECT * FROM t3 INDEXED BY sqlite_autoindex_t3_1 ORDER BY e
} {0 0 0 {SCAN TABLE t3 USING INDEX sqlite_autoindex_t3_1 (~1000000 rows)}}
} {0 0 0 {SCAN TABLE t3 USING INDEX sqlite_autoindex_t3_1}}
do_execsql_test indexedby-3.9 {
EXPLAIN QUERY PLAN
SELECT * FROM t3 INDEXED BY sqlite_autoindex_t3_1 WHERE e = 10
} {0 0 0 {SEARCH TABLE t3 USING INDEX sqlite_autoindex_t3_1 (e=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE t3 USING INDEX sqlite_autoindex_t3_1 (e=?)}}
do_test indexedby-3.10 {
catchsql { SELECT * FROM t3 INDEXED BY sqlite_autoindex_t3_1 WHERE f = 10 }
} {1 {cannot use index: sqlite_autoindex_t3_1}}
} {1 {no query solution}}
do_test indexedby-3.11 {
catchsql { SELECT * FROM t3 INDEXED BY sqlite_autoindex_t3_2 WHERE f = 10 }
} {1 {no such index: sqlite_autoindex_t3_2}}
@@ -127,25 +127,25 @@ do_test indexedby-3.11 {
do_execsql_test indexedby-4.1 {
EXPLAIN QUERY PLAN SELECT * FROM t1, t2 WHERE a = c
} {
0 0 0 {SCAN TABLE t1 (~1000000 rows)}
0 1 1 {SEARCH TABLE t2 USING INDEX i3 (c=?) (~10 rows)}
0 0 0 {SCAN TABLE t1}
0 1 1 {SEARCH TABLE t2 USING INDEX i3 (c=?)}
}
do_execsql_test indexedby-4.2 {
EXPLAIN QUERY PLAN SELECT * FROM t1 INDEXED BY i1, t2 WHERE a = c
} {
0 0 1 {SCAN TABLE t2 (~1000000 rows)}
0 1 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~10 rows)}
0 0 1 {SCAN TABLE t2}
0 1 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}
}
do_test indexedby-4.3 {
catchsql {
SELECT * FROM t1 INDEXED BY i1, t2 INDEXED BY i3 WHERE a=c
}
} {1 {cannot use index: i1}}
} {1 {no query solution}}
do_test indexedby-4.4 {
catchsql {
SELECT * FROM t2 INDEXED BY i3, t1 INDEXED BY i1 WHERE a=c
}
} {1 {cannot use index: i3}}
} {1 {no query solution}}
# Test embedding an INDEXED BY in a CREATE VIEW statement. This block
# also tests that nothing bad happens if an index refered to by
@@ -154,10 +154,10 @@ do_test indexedby-4.4 {
do_execsql_test indexedby-5.1 {
CREATE VIEW v2 AS SELECT * FROM t1 INDEXED BY i1 WHERE a > 5;
EXPLAIN QUERY PLAN SELECT * FROM v2
} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a>?) (~250000 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a>?)}}
do_execsql_test indexedby-5.2 {
EXPLAIN QUERY PLAN SELECT * FROM v2 WHERE b = 10
} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a>?) (~25000 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a>?)}}
do_test indexedby-5.3 {
execsql { DROP INDEX i1 }
catchsql { SELECT * FROM v2 }
@@ -166,7 +166,7 @@ do_test indexedby-5.4 {
# Recreate index i1 in such a way as it cannot be used by the view query.
execsql { CREATE INDEX i1 ON t1(b) }
catchsql { SELECT * FROM v2 }
} {1 {cannot use index: i1}}
} {1 {no query solution}}
do_test indexedby-5.5 {
# Drop and recreate index i1 again. This time, create it so that it can
# be used by the query.
@@ -178,54 +178,54 @@ do_test indexedby-5.5 {
#
do_execsql_test indexedby-6.1 {
EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b = 10 ORDER BY rowid
} {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (b=?) (~10 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (b=?)}}
do_execsql_test indexedby-6.2 {
EXPLAIN QUERY PLAN SELECT * FROM t1 NOT INDEXED WHERE b = 10 ORDER BY rowid
} {0 0 0 {SCAN TABLE t1 USING INTEGER PRIMARY KEY (~100000 rows)}}
} {0 0 0 {SCAN TABLE t1}}
# Test that "INDEXED BY" can be used in a DELETE statement.
#
do_execsql_test indexedby-7.1 {
EXPLAIN QUERY PLAN DELETE FROM t1 WHERE a = 5
} {0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (a=?) (~10 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (a=?)}}
do_execsql_test indexedby-7.2 {
EXPLAIN QUERY PLAN DELETE FROM t1 NOT INDEXED WHERE a = 5
} {0 0 0 {SCAN TABLE t1 (~100000 rows)}}
} {0 0 0 {SCAN TABLE t1}}
do_execsql_test indexedby-7.3 {
EXPLAIN QUERY PLAN DELETE FROM t1 INDEXED BY i1 WHERE a = 5
} {0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (a=?) (~10 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (a=?)}}
do_execsql_test indexedby-7.4 {
EXPLAIN QUERY PLAN DELETE FROM t1 INDEXED BY i1 WHERE a = 5 AND b = 10
} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~2 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}}
do_execsql_test indexedby-7.5 {
EXPLAIN QUERY PLAN DELETE FROM t1 INDEXED BY i2 WHERE a = 5 AND b = 10
} {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (b=?) (~2 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (b=?)}}
do_test indexedby-7.6 {
catchsql { DELETE FROM t1 INDEXED BY i2 WHERE a = 5}
} {1 {cannot use index: i2}}
} {1 {no query solution}}
# Test that "INDEXED BY" can be used in an UPDATE statement.
#
do_execsql_test indexedby-8.1 {
EXPLAIN QUERY PLAN UPDATE t1 SET rowid=rowid+1 WHERE a = 5
} {0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (a=?) (~10 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (a=?)}}
do_execsql_test indexedby-8.2 {
EXPLAIN QUERY PLAN UPDATE t1 NOT INDEXED SET rowid=rowid+1 WHERE a = 5
} {0 0 0 {SCAN TABLE t1 (~100000 rows)}}
} {0 0 0 {SCAN TABLE t1}}
do_execsql_test indexedby-8.3 {
EXPLAIN QUERY PLAN UPDATE t1 INDEXED BY i1 SET rowid=rowid+1 WHERE a = 5
} {0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (a=?) (~10 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (a=?)}}
do_execsql_test indexedby-8.4 {
EXPLAIN QUERY PLAN
UPDATE t1 INDEXED BY i1 SET rowid=rowid+1 WHERE a = 5 AND b = 10
} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~2 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}}
do_execsql_test indexedby-8.5 {
EXPLAIN QUERY PLAN
UPDATE t1 INDEXED BY i2 SET rowid=rowid+1 WHERE a = 5 AND b = 10
} {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (b=?) (~2 rows)}}
} {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (b=?)}}
do_test indexedby-8.6 {
catchsql { UPDATE t1 INDEXED BY i2 SET rowid=rowid+1 WHERE a = 5}
} {1 {cannot use index: i2}}
} {1 {no query solution}}
# Test that bug #3560 is fixed.
#
@@ -243,10 +243,10 @@ do_test indexedby-9.2 {
joinme as j indexed by joinme_id_text_idx
on ( m.id = j.id_int)
}
} {1 {cannot use index: joinme_id_text_idx}}
} {1 {no query solution}}
do_test indexedby-9.3 {
catchsql { select * from maintable, joinme INDEXED by joinme_id_text_idx }
} {1 {cannot use index: joinme_id_text_idx}}
} {1 {no query solution}}
# Make sure we can still create tables, indices, and columns whose name
# is "indexed".
+5 -2
View File
@@ -125,8 +125,11 @@ do_test intpkey-1.12.1 {
}
} {4 one two}
do_test intpkey-1.12.2 {
set sqlite_query_plan
} {t1 *}
execsql {
EXPLAIN QUERY PLAN
SELECT * FROM t1 WHERE a==4;
}
} {/SEARCH TABLE t1 /}
# Try to insert a non-integer value into the primary key field. This
# should result in a data type mismatch.
-1
View File
@@ -641,4 +641,3 @@ foreach {tn sql} {
sqlite3_simulate_device -char {} -sectorsize 0
finish_test
-1
View File
@@ -89,4 +89,3 @@ do_faultsim_test 3 -faults full* -prep {
}
finish_test
+39 -18
View File
@@ -156,14 +156,27 @@ ifcapable !like_opt {
# This procedure executes the SQL. Then it appends to the result the
# "sort" or "nosort" keyword (as in the cksort procedure above) then
# it appends the ::sqlite_query_plan variable.
# it appends the names of the table and index used.
#
proc queryplan {sql} {
set ::sqlite_sort_count 0
set data [execsql $sql]
if {$::sqlite_sort_count} {set x sort} {set x nosort}
lappend data $x
return [concat $data $::sqlite_query_plan]
set eqp [execsql "EXPLAIN QUERY PLAN $sql"]
# puts eqp=$eqp
foreach {a b c x} $eqp {
if {[regexp { TABLE (\w+ AS )?(\w+) USING COVERING INDEX (\w+)\y} \
$x all as tab idx]} {
lappend data {} $idx
} elseif {[regexp { TABLE (\w+ AS )?(\w+) USING.* INDEX (\w+)\y} \
$x all as tab idx]} {
lappend data $tab $idx
} elseif {[regexp { TABLE (\w+ AS )?(\w+)\y} $x all as tab]} {
lappend data $tab *
}
}
return $data
}
# Perform tests on the like optimization.
@@ -176,7 +189,7 @@ do_test like-3.1 {
queryplan {
SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1;
}
} {ABC {ABC abc xyz} abc abcd sort t1 {}}
} {ABC {ABC abc xyz} abc abcd sort t1 *}
do_test like-3.2 {
set sqlite_like_count
} {12}
@@ -269,8 +282,8 @@ do_test like-3.12 {
#
do_test like-3.13 {
set sqlite_like_count 0
db eval {PRAGMA case_sensitive_like=off;}
queryplan {
PRAGMA case_sensitive_like=off;
SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1;
}
} {ABC {ABC abc xyz} abc abcd nosort {} i1}
@@ -282,12 +295,14 @@ do_test like-3.14 {
#
do_test like-3.15 {
set sqlite_like_count 0
queryplan {
db eval {
PRAGMA case_sensitive_like=on;
DROP INDEX i1;
}
queryplan {
SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1;
}
} {abc abcd sort t1 {}}
} {abc abcd sort t1 *}
do_test like-3.16 {
set sqlite_like_count
} 12
@@ -299,7 +314,7 @@ do_test like-3.17 {
queryplan {
SELECT x FROM t1 WHERE x GLOB 'abc*' ORDER BY 1;
}
} {abc abcd sort t1 {}}
} {abc abcd sort t1 *}
do_test like-3.18 {
set sqlite_like_count
} 12
@@ -318,8 +333,8 @@ do_test like-3.20 {
} 0
do_test like-3.21 {
set sqlite_like_count 0
db eval {PRAGMA case_sensitive_like=on;}
queryplan {
PRAGMA case_sensitive_like=on;
SELECT x FROM t1 WHERE x GLOB 'abc*' ORDER BY 1;
}
} {abc abcd nosort {} i1}
@@ -328,8 +343,8 @@ do_test like-3.22 {
} 0
do_test like-3.23 {
set sqlite_like_count 0
db eval {PRAGMA case_sensitive_like=off;}
queryplan {
PRAGMA case_sensitive_like=off;
SELECT x FROM t1 WHERE x GLOB 'a[bc]d' ORDER BY 1;
}
} {abd acd nosort {} i1}
@@ -809,60 +824,66 @@ do_test like-11.0 {
}
} {12}
do_test like-11.1 {
db eval {PRAGMA case_sensitive_like=OFF;}
queryplan {
PRAGMA case_sensitive_like=OFF;
SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY a;
}
} {abc abcd ABC ABCD nosort t11 *}
do_test like-11.2 {
db eval {PRAGMA case_sensitive_like=ON;}
queryplan {
PRAGMA case_sensitive_like=ON;
SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY a;
}
} {abc abcd nosort t11 *}
do_test like-11.3 {
queryplan {
db eval {
PRAGMA case_sensitive_like=OFF;
CREATE INDEX t11b ON t11(b);
}
queryplan {
SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY +a;
}
} {abc abcd ABC ABCD sort {} t11b}
do_test like-11.4 {
db eval {PRAGMA case_sensitive_like=ON;}
queryplan {
PRAGMA case_sensitive_like=ON;
SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY a;
}
} {abc abcd nosort t11 *}
do_test like-11.5 {
queryplan {
db eval {
PRAGMA case_sensitive_like=OFF;
DROP INDEX t11b;
CREATE INDEX t11bnc ON t11(b COLLATE nocase);
}
queryplan {
SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY +a;
}
} {abc abcd ABC ABCD sort {} t11bnc}
do_test like-11.6 {
db eval {CREATE INDEX t11bb ON t11(b COLLATE binary);}
queryplan {
CREATE INDEX t11bb ON t11(b COLLATE binary);
SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY +a;
}
} {abc abcd ABC ABCD sort {} t11bnc}
do_test like-11.7 {
db eval {PRAGMA case_sensitive_like=ON;}
queryplan {
PRAGMA case_sensitive_like=ON;
SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY +a;
}
} {abc abcd sort {} t11bb}
do_test like-11.8 {
db eval {PRAGMA case_sensitive_like=OFF;}
queryplan {
PRAGMA case_sensitive_like=OFF;
SELECT b FROM t11 WHERE b GLOB 'abc*' ORDER BY +a;
}
} {abc abcd sort {} t11bb}
do_test like-11.9 {
queryplan {
db eval {
CREATE INDEX t11cnc ON t11(c COLLATE nocase);
CREATE INDEX t11cb ON t11(c COLLATE binary);
}
queryplan {
SELECT c FROM t11 WHERE c LIKE 'abc%' ORDER BY +a;
}
} {abc abcd ABC ABCD sort {} t11cnc}
-1
View File
@@ -58,4 +58,3 @@ db1 close
db2 close
finish_test
+3 -3
View File
@@ -269,17 +269,17 @@ ifcapable explain {
CREATE TABLE abc(a PRIMARY KEY, b, c);
EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 WHERE rowid = 1;
} {
0 0 0 {SEARCH TABLE abc AS t2 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
0 0 0 {SEARCH TABLE abc AS t2 USING INTEGER PRIMARY KEY (rowid=?)}
}
do_execsql_test misc7-14.2 {
EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 WHERE a = 1;
} {0 0 0
{SEARCH TABLE abc AS t2 USING INDEX sqlite_autoindex_abc_1 (a=?) (~1 rows)}
{SEARCH TABLE abc AS t2 USING INDEX sqlite_autoindex_abc_1 (a=?)}
}
do_execsql_test misc7-14.3 {
EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 ORDER BY a;
} {0 0 0
{SCAN TABLE abc AS t2 USING INDEX sqlite_autoindex_abc_1 (~1000000 rows)}
{SCAN TABLE abc AS t2 USING INDEX sqlite_autoindex_abc_1}
}
}
+98
View File
@@ -0,0 +1,98 @@
# 2013-05-23
#
# 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.
#
#***********************************************************************
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !mmap {
finish_test
return
}
source $testdir/lock_common.tcl
set testprefix mmap3
do_test mmap3-1.0 {
load_static_extension db wholenumber
db eval {
PRAGMA mmap_size=100000;
CREATE TABLE t1(x, y);
CREATE VIRTUAL TABLE nums USING wholenumber;
INSERT INTO t1 SELECT value, randomblob(value) FROM nums
WHERE value BETWEEN 1 and 1000;
SELECT sum(x), sum(length(y)) from t1;
PRAGMA mmap_size;
}
} {100000 500500 500500 100000}
do_test mmap3-1.2 {
db eval {
PRAGMA mmap_size=50000;
CREATE TABLE t2(a,b);
SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;
PRAGMA quick_check;
PRAGMA mmap_size;
}
} {50000 nums t1 t2 ok 50000}
do_test mmap3-1.3 {
db eval {
PRAGMA mmap_size=250000;
DROP TABLE t2;
SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;
PRAGMA quick_check;
PRAGMA mmap_size;
}
} {250000 nums t1 ok 250000}
do_test mmap3-1.4 {
db eval {SELECT x FROM t1 WHERE +x BETWEEN 10 AND 15} {
db eval {PRAGMA mmap_size=150000}
}
db eval {
PRAGMA quick_check;
PRAGMA mmap_size;
}
} {ok 250000}
do_test mmap3-1.5 {
db eval {SELECT x FROM t1 WHERE +x BETWEEN 10 AND 15} {
db eval {PRAGMA mmap_size=0}
}
db eval {
PRAGMA quick_check;
PRAGMA mmap_size;
}
} {ok 250000}
do_test mmap3-1.6 {
db eval {SELECT x FROM t1 WHERE +x BETWEEN 10 AND 15} {
set x [db one {PRAGMA mmap_size}]
}
set x [concat $x [db eval {
PRAGMA quick_check;
PRAGMA mmap_size;
}]]
} {250000 ok 250000}
do_test mmap3-1.7 {
db eval {
PRAGMA mmap_size(0);
CREATE TABLE t3(a,b,c);
SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;
PRAGMA quick_check;
PRAGMA mmap_size;
}
} {0 nums t1 t3 ok 0}
do_test mmap3-1.8 {
db eval {SELECT x FROM t1 WHERE +x BETWEEN 10 AND 15} {
db eval {PRAGMA mmap_size=75000}
}
db eval {
PRAGMA quick_check;
PRAGMA mmap_size;
}
} {ok 75000}
finish_test
-1
View File
@@ -150,4 +150,3 @@ catch { db2 close }
sqlite3_enable_shared_cache $esc
finish_test
+73 -54
View File
@@ -48,7 +48,7 @@ do_test 1.0 {
} {}
do_test 1.1a {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn
SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn
}
} {one-a one-c two-a two-b three-a three-c}
@@ -66,7 +66,7 @@ do_test 1.1b {
#
do_test 1.2a {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY +title, +tn
SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn
}
} {one-a one-c two-a two-b three-a three-c}
@@ -75,7 +75,7 @@ do_test 1.2a {
do_test 1.2b {
db eval {
EXPLAIN QUERY PLAN
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY +title, +tn
SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn
}
} {/ORDER BY/} ;# separate sorting pass due to "+" on ORDER BY terms
@@ -85,13 +85,13 @@ do_test 1.3a {
optimization_control db order-by-idx-join 0
db cache flush
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn
SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn
}
} {one-a one-c two-a two-b three-a three-c}
do_test 1.3b {
db eval {
EXPLAIN QUERY PLAN
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn
SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn
}
} {/ORDER BY/} ;# separate sorting pass due to disabled optimization
optimization_control db all 1
@@ -101,55 +101,57 @@ db cache flush
#
do_test 1.4a {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title DESC, tn
SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn
}
} {three-a three-c two-a two-b one-a one-c}
do_test 1.4b {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY +title DESC, +tn
SELECT name FROM album JOIN track USING (aid) ORDER BY +title DESC, +tn
}
} {three-a three-c two-a two-b one-a one-c} ;# verify same order after sorting
do_test 1.4c {
db eval {
EXPLAIN QUERY PLAN
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title DESC, tn
SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn
}
} {~/ORDER BY/} ;# optimized out
} {~/ORDER BY/} ;# ORDER BY suppressed due to uniqueness constraints
do_test 1.5a {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn DESC
SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn DESC
}
} {one-c one-a two-b two-a three-c three-a}
do_test 1.5b {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY +title, +tn DESC
SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn DESC
}
} {one-c one-a two-b two-a three-c three-a} ;# verify same order after sorting
do_test 1.5c {
db eval {
EXPLAIN QUERY PLAN
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn DESC
SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn DESC
}
} {~/ORDER BY/} ;# optimized out
} {~/ORDER BY/} ;# ORDER BY suppressed due to uniqueness constraints
do_test 1.6a {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title DESC, tn DESC
SELECT name FROM album CROSS JOIN track USING (aid)
ORDER BY title DESC, tn DESC
}
} {three-c three-a two-b two-a one-c one-a}
do_test 1.6b {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY +title DESC, +tn DESC
SELECT name FROM album CROSS JOIN track USING (aid)
ORDER BY +title DESC, +tn DESC
}
} {three-c three-a two-b two-a one-c one-a} ;# verify same order after sorting
do_test 1.6c {
db eval {
EXPLAIN QUERY PLAN
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title DESC, tn DESC
SELECT name FROM album CROSS JOIN track USING (aid)
ORDER BY title DESC, tn DESC
}
} {~/ORDER BY/} ;# ORDER BY optimized-out
} {~/ORDER BY/} ;# ORDER BY
# Reconstruct the test data to use indices rather than integer primary keys.
@@ -183,7 +185,7 @@ do_test 2.0 {
} {}
do_test 2.1a {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn
SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn
}
} {one-a one-c two-a two-b three-a three-c}
@@ -192,28 +194,28 @@ do_test 2.1a {
do_test 2.1b {
db eval {
EXPLAIN QUERY PLAN
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn
SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn
}
} {~/ORDER BY/} ;# ORDER BY optimized out
} {/ORDER BY/} ;# ORDER BY required because of missing aid term in ORDER BY
do_test 2.1c {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, aid, tn
SELECT name FROM album JOIN track USING (aid) ORDER BY title, aid, tn
}
} {one-a one-c two-a two-b three-a three-c}
do_test 2.1d {
db eval {
EXPLAIN QUERY PLAN
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, aid, tn
SELECT name FROM album JOIN track USING (aid) ORDER BY title, aid, tn
}
} {~/ORDER BY/} ;# ORDER BY optimized out
} {/ORDER BY/} ;# ORDER BY required in this case
# The same query with ORDER BY clause optimization disabled via + operators
# should give exactly the same answer.
#
do_test 2.2a {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY +title, +tn
SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn
}
} {one-a one-c two-a two-b three-a three-c}
@@ -222,7 +224,7 @@ do_test 2.2a {
do_test 2.2b {
db eval {
EXPLAIN QUERY PLAN
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY +title, +tn
SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn
}
} {/ORDER BY/} ;# separate sorting pass due to "+" on ORDER BY terms
@@ -232,13 +234,13 @@ do_test 2.3a {
optimization_control db order-by-idx-join 0
db cache flush
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn
SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn
}
} {one-a one-c two-a two-b three-a three-c}
do_test 2.3b {
db eval {
EXPLAIN QUERY PLAN
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn
SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn
}
} {/ORDER BY/} ;# separate sorting pass due to disabled optimization
optimization_control db all 1
@@ -248,55 +250,55 @@ db cache flush
#
do_test 2.4a {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title DESC, tn
SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn
}
} {three-a three-c two-a two-b one-a one-c}
do_test 2.4b {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY +title DESC, +tn
SELECT name FROM album JOIN track USING (aid) ORDER BY +title DESC, +tn
}
} {three-a three-c two-a two-b one-a one-c} ;# verify same order after sorting
do_test 2.4c {
db eval {
EXPLAIN QUERY PLAN
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title DESC, tn
SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn
}
} {~/ORDER BY/} ;# optimized out
} {/ORDER BY/} ;# separate sorting pass due to mixed DESC/ASC
do_test 2.5a {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn DESC
SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn DESC
}
} {one-c one-a two-b two-a three-c three-a}
do_test 2.5b {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY +title, +tn DESC
SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn DESC
}
} {one-c one-a two-b two-a three-c three-a} ;# verify same order after sorting
do_test 2.5c {
db eval {
EXPLAIN QUERY PLAN
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn DESC
SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn DESC
}
} {~/ORDER BY/} ;# optimized out
} {/ORDER BY/} ;# separate sorting pass due to mixed ASC/DESC
do_test 2.6a {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title DESC, tn DESC
SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn DESC
}
} {three-c three-a two-b two-a one-c one-a}
do_test 2.6b {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY +title DESC, +tn DESC
SELECT name FROM album JOIN track USING (aid) ORDER BY +title DESC, +tn DESC
}
} {three-c three-a two-b two-a one-c one-a} ;# verify same order after sorting
do_test 2.6c {
db eval {
EXPLAIN QUERY PLAN
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title DESC, tn DESC
SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn DESC
}
} {~/ORDER BY/} ;# ORDER BY optimized out
} {/ORDER BY/} ;# ORDER BY required
# Generate another test dataset, but this time using mixed ASC/DESC indices.
@@ -348,7 +350,7 @@ do_test 3.1b {
#
do_test 3.2a {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY +title, +tn DESC
SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn DESC
}
} {one-c one-a two-b two-a three-c three-a}
@@ -357,7 +359,7 @@ do_test 3.2a {
do_test 3.2b {
db eval {
EXPLAIN QUERY PLAN
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY +title, +tn DESC
SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn DESC
}
} {/ORDER BY/} ;# separate sorting pass due to "+" on ORDER BY terms
@@ -367,13 +369,13 @@ do_test 3.3a {
optimization_control db order-by-idx-join 0
db cache flush
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn DESC
SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn DESC
}
} {one-c one-a two-b two-a three-c three-a}
do_test 3.3b {
db eval {
EXPLAIN QUERY PLAN
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn DESC
SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn DESC
}
} {/ORDER BY/} ;# separate sorting pass due to disabled optimization
optimization_control db all 1
@@ -383,38 +385,37 @@ db cache flush
#
do_test 3.4a {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn
SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn
}
} {one-a one-c two-a two-b three-a three-c}
do_test 3.4b {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY +title, +tn
SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn
}
} {one-a one-c two-a two-b three-a three-c} ;# verify same order after sorting
do_test 3.4c {
db eval {
EXPLAIN QUERY PLAN
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn
SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn
}
} {~/ORDER BY/} ;# optimized out
} {~/ORDER BY/} ;# ORDER BY suppressed by uniqueness constraints
do_test 3.5a {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title DESC, tn DESC
SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn DESC
}
} {three-c three-a two-b two-a one-c one-a}
do_test 3.5b {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY +title DESC, +tn DESC
SELECT name FROM album JOIN track USING (aid) ORDER BY +title DESC, +tn DESC
}
} {three-c three-a two-b two-a one-c one-a} ;# verify same order after sorting
do_test 3.5c {
db eval {
EXPLAIN QUERY PLAN
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title DESC, tn DESC
SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn DESC
}
} {~/ORDER BY/} ;# optimzed out
} {~/ORDER BY/} ;# ORDER BY suppressed by uniqueness constraints
do_test 3.6a {
@@ -424,7 +425,8 @@ do_test 3.6a {
} {three-a three-c two-a two-b one-a one-c}
do_test 3.6b {
db eval {
SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY +title DESC, +tn
SELECT name FROM album CROSS JOIN track USING (aid)
ORDER BY +title DESC, +tn
}
} {three-a three-c two-a two-b one-a one-c} ;# verify same order after sorting
do_test 3.6c {
@@ -434,5 +436,22 @@ do_test 3.6c {
}
} {~/ORDER BY/} ;# inverted ASC/DESC is optimized out
# Ticket 5ed1772895bf3deeab78c5e3519b1da9165c541b (2013-06-04)
# Incorrect ORDER BY on an indexed JOIN
#
do_test 4.0 {
db eval {
CREATE TABLE t41(a INT UNIQUE NOT NULL, b INT NOT NULL);
CREATE INDEX t41ba ON t41(b,a);
CREATE TABLE t42(x INT NOT NULL REFERENCES t41(a), y INT NOT NULL);
CREATE UNIQUE INDEX t42xy ON t42(x,y);
INSERT INTO t41 VALUES(1,1),(3,1);
INSERT INTO t42 VALUES(1,13),(1,15),(3,14),(3,16);
SELECT b, y FROM t41 CROSS JOIN t42 ON x=a ORDER BY b, y;
}
} {1 13 1 14 1 15 1 16}
finish_test
+97
View File
@@ -0,0 +1,97 @@
# 2013-06-14
#
# 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 file is testing that the optimizations that disable
# ORDER BY clauses work correctly
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set ::testprefix orderby5
# Generate test data for a join. Verify that the join gets the
# correct answer.
#
do_execsql_test 1.1 {
CREATE TABLE t1(a,b,c);
CREATE INDEX t1bc ON t1(b,c);
EXPLAIN QUERY PLAN
SELECT DISTINCT a, b, c FROM t1 WHERE a=0;
} {~/B-TREE/}
do_execsql_test 1.2.1 {
EXPLAIN QUERY PLAN
SELECT DISTINCT a, c, b FROM t1 WHERE a=0;
} {~/B-TREE/}
do_execsql_test 1.2.2 {
EXPLAIN QUERY PLAN
SELECT DISTINCT a, c, b FROM t1 WHERE a='xyz' COLLATE nocase;
} {/B-TREE/}
do_execsql_test 1.2.3 {
EXPLAIN QUERY PLAN
SELECT DISTINCT a COLLATE nocase, c, b FROM t1 WHERE a='xyz';
} {/B-TREE/}
do_execsql_test 1.2.4 {
EXPLAIN QUERY PLAN
SELECT DISTINCT a COLLATE nocase, c, b FROM t1 WHERE a='xyz' COLLATE nocase;
} {~/B-TREE/}
do_execsql_test 1.3 {
EXPLAIN QUERY PLAN
SELECT DISTINCT b, a, c FROM t1 WHERE a=0;
} {~/B-TREE/}
do_execsql_test 1.4 {
EXPLAIN QUERY PLAN
SELECT DISTINCT b, c, a FROM t1 WHERE a=0;
} {~/B-TREE/}
do_execsql_test 1.5 {
EXPLAIN QUERY PLAN
SELECT DISTINCT c, a, b FROM t1 WHERE a=0;
} {~/B-TREE/}
do_execsql_test 1.6 {
EXPLAIN QUERY PLAN
SELECT DISTINCT c, b, a FROM t1 WHERE a=0;
} {~/B-TREE/}
do_execsql_test 1.7 {
EXPLAIN QUERY PLAN
SELECT DISTINCT c, b, a FROM t1 WHERE +a=0;
} {/B-TREE/}
do_execsql_test 2.1 {
EXPLAIN QUERY PLAN
SELECT * FROM t1 WHERE a=0 ORDER BY a, b, c;
} {~/B-TREE/}
do_execsql_test 2.2 {
EXPLAIN QUERY PLAN
SELECT * FROM t1 WHERE +a=0 ORDER BY a, b, c;
} {/B-TREE/}
do_execsql_test 2.3 {
EXPLAIN QUERY PLAN
SELECT * FROM t1 WHERE a=0 ORDER BY b, a, c;
} {~/B-TREE/}
do_execsql_test 2.4 {
EXPLAIN QUERY PLAN
SELECT * FROM t1 WHERE a=0 ORDER BY b, c, a;
} {~/B-TREE/}
do_execsql_test 2.5 {
EXPLAIN QUERY PLAN
SELECT * FROM t1 WHERE a=0 ORDER BY a, c, b;
} {/B-TREE/}
do_execsql_test 2.6 {
EXPLAIN QUERY PLAN
SELECT * FROM t1 WHERE a=0 ORDER BY c, a, b;
} {/B-TREE/}
do_execsql_test 2.7 {
EXPLAIN QUERY PLAN
SELECT * FROM t1 WHERE a=0 ORDER BY c, b, a;
} {/B-TREE/}
finish_test
-1
View File
@@ -2815,4 +2815,3 @@ do_test 43.3 {
} {0 1 0}
finish_test
-1
View File
@@ -1546,4 +1546,3 @@ sqlite3_shutdown
sqlite3_config_uri 0
finish_test
-1
View File
@@ -96,4 +96,3 @@ do_faultsim_test pagerfault2-2 -faults oom-transient -prep {
sqlite3_memdebug_vfs_oom_test 1
finish_test
-1
View File
@@ -61,4 +61,3 @@ do_faultsim_test pagerfault3-1 -faults ioerr-transient -prep {
}
finish_test
+207
View File
@@ -0,0 +1,207 @@
# 2013-05-28
#
# 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 file is percentile.c extension
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Basic test of the percentile() function.
#
do_test percentile-1.0 {
load_static_extension db percentile
execsql {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(1),(4),(6),(7),(8),(9),(11),(11),(11);
}
execsql {SELECT percentile(x,0) FROM t1}
} {1.0}
foreach {in out} {
100 11.0
50 8.0
12.5 4.0
15 4.4
20 5.2
80 11.0
89 11.0
} {
do_test percentile-1.1.$in {
execsql {SELECT percentile(x,$in) FROM t1}
} $out
}
# Add some NULL values.
#
do_test percentile-1.2 {
execsql {INSERT INTO t1 VALUES(NULL),(NULL);}
} {}
foreach {in out} {
100 11.0
50 8.0
12.5 4.0
15 4.4
20 5.2
80 11.0
89 11.0
} {
do_test percentile-1.3.$in {
execsql {SELECT percentile(x,$in) FROM t1}
} $out
}
# The second argument to percentile can change some, but not much.
#
do_test percentile-1.4 {
catchsql {SELECT round(percentile(x, 15+0.000001*rowid),1) FROM t1}
} {0 4.4}
do_test percentile-1.5 {
catchsql {SELECT round(percentile(x, 15+0.1*rowid),1) FROM t1}
} {1 {2nd argument to percentile() is not the same for all input rows}}
# Input values in a random order
#
do_test percentile-1.6 {
execsql {
CREATE TABLE t2(x);
INSERT INTO t2 SELECT x+0.0 FROM t1 ORDER BY random();
}
} {}
foreach {in out} {
100 11.0
50 8.0
12.5 4.0
15 4.4
20 5.2
80 11.0
89 11.0
} {
do_test percentile-1.7.$in {
execsql {SELECT percentile(x,$in) FROM t2}
} $out
}
# Wrong number of arguments
#
do_test percentile-1.8 {
catchsql {SELECT percentile(x,0,1) FROM t1}
} {1 {wrong number of arguments to function percentile()}}
do_test percentile-1.9 {
catchsql {SELECT percentile(x) FROM t1}
} {1 {wrong number of arguments to function percentile()}}
# Second argument must be numeric
#
do_test percentile-1.10 {
catchsql {SELECT percentile(x,null) FROM t1}
} {1 {2nd argument to percentile() is not a number between 0.0 and 100.0}}
do_test percentile-1.11 {
catchsql {SELECT percentile(x,'fifty') FROM t1}
} {1 {2nd argument to percentile() is not a number between 0.0 and 100.0}}
do_test percentile-1.12 {
catchsql {SELECT percentile(x,x'3530') FROM t1}
} {1 {2nd argument to percentile() is not a number between 0.0 and 100.0}}
# Second argument is out of range
#
do_test percentile-1.13 {
catchsql {SELECT percentile(x,-0.0000001) FROM t1}
} {1 {2nd argument to percentile() is not a number between 0.0 and 100.0}}
do_test percentile-1.14 {
catchsql {SELECT percentile(x,100.0000001) FROM t1}
} {1 {2nd argument to percentile() is not a number between 0.0 and 100.0}}
# First argument is not NULL and is not NUMERIC
#
do_test percentile-1.15 {
catchsql {
BEGIN;
UPDATE t1 SET x='50' WHERE x IS NULL;
SELECT percentile(x, 50) FROM t1;
}
} {1 {1st argument to percentile() is not numeric}}
do_test percentile-1.16 {
catchsql {
ROLLBACK;
BEGIN;
UPDATE t1 SET x=x'3530' WHERE x IS NULL;
SELECT percentile(x, 50) FROM t1;
}
} {1 {1st argument to percentile() is not numeric}}
do_test percentile-1.17 {
catchsql {
ROLLBACK;
SELECT percentile(x, 50) FROM t1;
}
} {0 8.0}
# No non-NULL entries.
#
do_test percentile-1.18 {
execsql {
UPDATE t1 SET x=NULL;
SELECT ifnull(percentile(x, 50),'NULL') FROM t1
}
} {NULL}
# Exactly one non-NULL entry
#
do_test percentile-1.19 {
execsql {
UPDATE t1 SET x=12345 WHERE rowid=5;
SELECT percentile(x, 0), percentile(x, 50), percentile(x,100) FROM t1
}
} {12345.0 12345.0 12345.0}
# Infinity as an input
#
do_test percentile-1.20 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 SELECT x+0.0 FROM t2;
UPDATE t1 SET x=1.0e300*1.0e300 WHERE rowid=5;
SELECT percentile(x,50) from t1;
}
} {1 {Inf input to percentile()}}
do_test percentile-1.21 {
catchsql {
UPDATE t1 SET x=-1.0e300*1.0e300 WHERE rowid=5;
SELECT percentile(x,50) from t1;
}
} {1 {Inf input to percentile()}}
# Million-row Inputs
#
do_test percentile-2.0 {
load_static_extension db wholenumber
execsql {
CREATE VIRTUAL TABLE nums USING wholenumber;
CREATE TABLE t3(x);
INSERT INTO t3 SELECT value-1 FROM nums WHERE value BETWEEN 1 AND 500000;
INSERT INTO t3 SELECT value*10 FROM nums
WHERE value BETWEEN 500000 AND 999999;
SELECT count(*) FROM t3;
}
} {1000000}
foreach {in out} {
0 0.0
100 9999990.0
50 2749999.5
10 99999.9
} {
do_test percentile-2.1.$in {
execsql {
SELECT percentile(x, $in) from t3;
}
} $out
}
finish_test
+77 -1
View File
@@ -197,7 +197,7 @@ test_suite "fts3" -prefix "" -description {
fts4aa.test fts4content.test
fts3conf.test fts3prefix.test fts3fault2.test fts3corrupt.test
fts3corrupt2.test fts3first.test fts4langid.test fts4merge.test
fts4check.test fts4unicode.test
fts4check.test fts4unicode.test fts4noti.test
}
test_suite "nofaultsim" -prefix "" -description {
@@ -216,6 +216,82 @@ test_suite "nofaultsim" -prefix "" -description {
unset -nocomplain ::G(valgrind)
}
test_suite "queryplanner" -prefix "" -description {
Tests of the query planner and query optimizer
} -files {
alter2.test alter3.test alter4.test alter.test analyze3.test
analyze4.test analyze5.test analyze6.test analyze7.test analyze8.test
analyze.test attach2.test attach3.test attach4.test
attach.test autoinc.test autoindex1.test between.test cast.test
check.test closure01.test coalesce.test collate1.test collate2.test
collate3.test collate4.test collate5.test collate6.test collate7.test
collate8.test collate9.test collateA.test colmeta.test colname.test
conflict.test count.test coveridxscan.test createtab.test cse.test
date.test dbstatus2.test dbstatus.test default.test delete2.test
delete3.test delete.test descidx1.test descidx2.test descidx3.test
distinctagg.test distinct.test e_createtable.test e_delete.test
e_droptrigger.test e_dropview.test e_expr.test e_insert.test
eqp.test e_reindex.test e_resolve.test e_select2.test e_select.test
e_update.test exists.test expr.test fkey1.test fkey2.test fkey3.test
fkey4.test fkey5.test func2.test func3.test func.test
in3.test in4.test in5.test index2.test index3.test
index4.test index5.test indexedby.test index.test
insert2.test insert3.test insert4.test insert5.test insert.test
instr.test in.test intpkey.test join2.test join3.test join4.test
join5.test join6.test join.test like2.test like.test limit.test
minmax2.test minmax3.test minmax4.test minmax.test misc1.test misc2.test
misc3.test misc4.test misc5.test misc6.test misc7.test orderby1.test
orderby2.test orderby3.test orderby4.test randexpr1.test regexp1.test
reindex.test rowhash.test rowid.test schema2.test schema3.test
schema4.test schema5.test schema.test
select1.test select2.test select3.test select4.test select5.test
select6.test select7.test select8.test select9.test selectA.test
selectB.test selectC.test selectD.test selectE.test sidedelete.test
sort.test spellfix.test subquery2.test subquery.test subselect.test
substr.test tkt-02a8e81d44.test tkt1435.test tkt1443.test tkt1444.test
tkt1449.test tkt1473.test tkt1501.test tkt1512.test tkt1514.test
tkt1536.test tkt1537.test tkt1567.test tkt1644.test tkt1667.test
tkt1873.test tkt2141.test tkt2192.test tkt2213.test tkt2251.test
tkt2285.test tkt2332.test tkt2339.test tkt2391.test tkt2409.test
tkt2450.test tkt2565.test tkt2640.test tkt2643.test tkt2686.test
tkt-26ff0c2d1e.test tkt2767.test tkt2817.test tkt2820.test tkt2822.test
tkt2832.test tkt2854.test tkt2920.test tkt2927.test tkt2942.test
tkt-2a5629202f.test tkt-2d1a5c67d.test tkt-2ea2425d34.test tkt3080.test
tkt3093.test tkt3121.test tkt-31338dca7e.test tkt-313723c356.test
tkt3201.test tkt3292.test tkt3298.test tkt3334.test tkt3346.test
tkt3357.test tkt3419.test tkt3424.test tkt3442.test tkt3457.test
tkt3461.test tkt3493.test tkt3508.test tkt3522.test tkt3527.test
tkt3541.test tkt3554.test tkt3581.test tkt35xx.test tkt3630.test
tkt3718.test tkt3731.test tkt3757.test tkt3761.test tkt3762.test
tkt3773.test tkt3791.test tkt3793.test tkt3810.test tkt3824.test
tkt3832.test tkt3838.test tkt3841.test tkt-385a5b56b9.test tkt3871.test
tkt3879.test tkt-38cb5df375.test tkt3911.test tkt3918.test tkt3922.test
tkt3929.test tkt3935.test tkt3992.test tkt3997.test tkt-3998683a16.test
tkt-3a77c9714e.test tkt-3fe897352e.test tkt4018.test tkt-4a03edc4c8.test
tkt-4dd95f6943.test tkt-54844eea3f.test tkt-5d863f876e.test
tkt-5e10420e8d.test tkt-5ee23731f.test tkt-6bfb98dfc0.test
tkt-752e1646fc.test tkt-78e04e52ea.test tkt-7a31705a7e6.test
tkt-7bbfb7d442.test tkt-80ba201079.test tkt-80e031a00f.test
tkt-8454a207b9.test tkt-91e2e8ba6f.test tkt-94c04eaadb.test
tkt-9d68c883.test tkt-a7b7803e.test tkt-b1d3a2e531.test
tkt-b351d95f9.test tkt-b72787b1.test tkt-bd484a090c.test
tkt-bdc6bbbb38.test tkt-c48d99d690.test tkt-cbd054fa6b.test
tkt-d11f09d36e.test tkt-d635236375.test tkt-d82e3f3721.test
tkt-f3e5abed55.test tkt-f777251dc7a.test tkt-f7b4edec.test
tkt-f973c7ac31.test tkt-fa7bf5ec.test tkt-fc62af4523.test
tkt-fc7bd6358f.test trigger1.test trigger2.test trigger3.test
trigger4.test trigger5.test trigger6.test trigger7.test trigger8.test
trigger9.test triggerA.test triggerB.test triggerC.test triggerD.test
types2.test types3.test types.test unique.test unordered.test
update.test view.test vtab1.test vtab2.test vtab3.test vtab4.test
vtab5.test vtab6.test vtab7.test vtab8.test vtab9.test vtab_alter.test
vtabA.test vtabB.test vtabC.test vtabD.test vtabE.test
vtabF.test where2.test where3.test where4.test where5.test where6.test
where7.test where8m.test where8.test where9.test whereA.test whereB.test
whereC.test whereD.test whereE.test whereF.test wherelimit.test
where.test
}
lappend ::testsuitelist xxx
#-------------------------------------------------------------------------
# Define the coverage related test suites:
-1
View File
@@ -92,4 +92,3 @@ do_test 1.6.2 {
} {0}
finish_test
-1
View File
@@ -110,4 +110,3 @@ do_test 1.8 {
foreach db {db1 db2 db3 db4} { catch { $db close } }
sqlite3_enable_shared_cache $::enable_shared_cache
finish_test
-1
View File
@@ -52,4 +52,3 @@ db2 close
sqlite3_enable_shared_cache $::enable_shared_cache
finish_test
+5 -2
View File
@@ -241,8 +241,11 @@ do_test subquery-2.5.3.1 {
} {10.0}
do_test subquery-2.5.3.2 {
# Verify that the t4i index was not used in the previous query
set ::sqlite_query_plan
} {t4 {}}
execsql {
EXPLAIN QUERY PLAN
SELECT * FROM t4 WHERE x IN (SELECT a FROM t3);
}
} {/SCAN TABLE t4 /}
do_test subquery-2.5.4 {
execsql {
DROP TABLE t3;
+35 -3
View File
@@ -551,6 +551,9 @@ proc do_test {name cmd expected} {
fail_test $name
} else {
if {[regexp {^~?/.*/$} $expected]} {
# "expected" is of the form "/PATTERN/" then the result if correct if
# regular expression PATTERN matches the result. "~/PATTERN/" means
# the regular expression must not match.
if {[string index $expected 0]=="~"} {
set re [string map {# {[-0-9.]+}} [string range $expected 2 end-1]]
set ok [expr {![regexp $re $result]}]
@@ -558,6 +561,16 @@ proc do_test {name cmd expected} {
set re [string map {# {[-0-9.]+}} [string range $expected 1 end-1]]
set ok [regexp $re $result]
}
} elseif {[regexp {^~?\*.*\*$} $expected]} {
# "expected" is of the form "*GLOB*" then the result if correct if
# glob pattern GLOB matches the result. "~/GLOB/" means
# the glob must not match.
if {[string index $expected 0]=="~"} {
set e [string range $expected 1 end]
set ok [expr {![string match $e $result]}]
} else {
set ok [string match $expected $result]
}
} else {
set ok [expr {[string compare $result $expected]==0}]
}
@@ -799,9 +812,28 @@ proc finalize_testing {} {
set nTest [incr_ntest]
set nErr [set_test_counter errors]
puts "$nErr errors out of $nTest tests"
if {$nErr>0} {
puts "Failures on these tests: [set_test_counter fail_list]"
set nKnown 0
if {[file readable known-problems.txt]} {
set fd [open known-problems.txt]
set content [read $fd]
close $fd
foreach x $content {set known_error($x) 1}
foreach x [set_test_counter fail_list] {
if {[info exists known_error($x)]} {incr nKnown}
}
}
if {$nKnown>0} {
puts "[expr {$nErr-$nKnown}] new errors and $nKnown known errors\
out of $nTest tests"
} else {
puts "$nErr errors out of $nTest tests"
}
if {$nErr>$nKnown} {
puts -nonewline "Failures on these tests:"
foreach x [set_test_counter fail_list] {
if {![info exists known_error($x)]} {puts -nonewline " $x"}
}
puts ""
}
foreach warning [set_test_counter warn_list] {
puts "Warning: $warning"
+6 -1
View File
@@ -46,6 +46,12 @@ do_execsql_test 1.3 {
SELECT coalesce(b, 'null') || '/' || c FROM t8 x ORDER BY x.b, x.c
} {null/four null/three a/one b/two}
do_execsql_test 1.4 {
DROP INDEX i1;
CREATE UNIQUE INDEX i1 ON t8(b, c);
SELECT coalesce(b, 'null') || '/' || c FROM t8 x ORDER BY x.b, x.c
} {null/four null/three a/one b/two}
#-------------------------------------------------------------------------
#
@@ -68,4 +74,3 @@ do_test 2.4 {
} {sort}
finish_test
+4 -4
View File
@@ -35,19 +35,19 @@ do_execsql_test 2.0 {
}
do_eqp_test 2.1 { SELECT DISTINCT x FROM t2 } {
0 0 0 {SCAN TABLE t2 USING COVERING INDEX t2x (~1000000 rows)}
0 0 0 {SCAN TABLE t2 USING COVERING INDEX t2x}
}
do_eqp_test 2.2 { SELECT DISTINCT y FROM t2 } {
0 0 0 {SCAN TABLE t2 USING COVERING INDEX t2y (~1000000 rows)}
0 0 0 {SCAN TABLE t2 USING COVERING INDEX t2y}
}
do_eqp_test 2.3 { SELECT DISTINCT x, y FROM t2 WHERE y=10 } {
0 0 0 {SEARCH TABLE t2 USING INDEX t2y (y=?) (~1 rows)}
0 0 0 {SEARCH TABLE t2 USING INDEX t2y (y=?)}
}
do_eqp_test 2.4 { SELECT DISTINCT x, y FROM t2 WHERE x=10 } {
0 0 0 {SEARCH TABLE t2 USING INDEX t2x (x=?) (~1 rows)}
0 0 0 {SEARCH TABLE t2 USING INDEX t2x (x=?)}
}
finish_test
-1
View File
@@ -70,4 +70,3 @@ do_execsql_test 2.2 {
finish_test
+3 -3
View File
@@ -16,9 +16,9 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# The following tests use hex_to_utf16be() and hex_to_utf16le() which
# which are only available if SQLite is built with UTF16 support.
# The following tests use hex_to_utf16be() and hex_to_utf16le() which
# which are only available if SQLite is built with UTF16 support.
ifcapable {!utf16} {
finish_test
return
+3 -3
View File
@@ -44,7 +44,7 @@ do_test tkt-78e04-1.4 {
execsql {
EXPLAIN QUERY PLAN SELECT * FROM "" WHERE "" LIKE 'abc%';
}
} {0 0 0 {SCAN TABLE USING COVERING INDEX i1 (~500000 rows)}}
} {0 0 0 {SCAN TABLE USING COVERING INDEX i1}}
do_test tkt-78e04-1.5 {
execsql {
DROP TABLE "";
@@ -57,12 +57,12 @@ do_test tkt-78e04-2.1 {
CREATE INDEX "" ON t2(x);
EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE x=5;
}
} {0 0 0 {SEARCH TABLE t2 USING COVERING INDEX (x=?) (~10 rows)}}
} {0 0 0 {SEARCH TABLE t2 USING COVERING INDEX (x=?)}}
do_test tkt-78e04-2.2 {
execsql {
DROP INDEX "";
EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE x=2;
}
} {0 0 0 {SCAN TABLE t2 (~100000 rows)}}
} {0 0 0 {SCAN TABLE t2}}
finish_test
-1
View File
@@ -23,4 +23,3 @@ do_execsql_test tkt-7a31705a7e6-1.1 {
CREATE TABLE t2x (b INTEGER PRIMARY KEY);
SELECT t1.a FROM ((t1 JOIN t2 ON t1.a=t2.a) AS x JOIN t2x ON x.b=t2x.b) as y;
} {}
-2
View File
@@ -152,5 +152,3 @@ do_execsql_test 2.3 {
finish_test
-1
View File
@@ -23,4 +23,3 @@ do_test 1.1 {
do_test 1.2 { execsql VACUUM } {}
finish_test
-1
View File
@@ -59,4 +59,3 @@ do_test tkt-d11f09d36e.5 {
} {ok}
finish_test
-1
View File
@@ -114,4 +114,3 @@ if {[permutation]!="inmemory_journal"} {
finish_test
-1
View File
@@ -84,4 +84,3 @@ foreach {tn sql} {
finish_test
+3 -3
View File
@@ -49,10 +49,10 @@ proc EQP {sql} {
ifcapable explain {
do_test tkt3442-1.2 {
EQP { SELECT node FROM listhash WHERE id='5000' LIMIT 1; }
} {0 0 0 {SEARCH TABLE listhash USING INDEX ididx (id=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE listhash USING INDEX ididx (id=?)}}
do_test tkt3442-1.3 {
EQP { SELECT node FROM listhash WHERE id="5000" LIMIT 1; }
} {0 0 0 {SEARCH TABLE listhash USING INDEX ididx (id=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE listhash USING INDEX ididx (id=?)}}
}
@@ -61,7 +61,7 @@ ifcapable explain {
ifcapable explain {
do_test tkt3442-1.4 {
EQP { SELECT node FROM listhash WHERE id=5000 LIMIT 1; }
} {0 0 0 {SEARCH TABLE listhash USING INDEX ididx (id=?) (~1 rows)}}
} {0 0 0 {SEARCH TABLE listhash USING INDEX ididx (id=?)}}
}
do_test tkt3442-1.5 {
catchsql {
-1
View File
@@ -57,4 +57,3 @@ do_test tkt3918.5 {
} {}
finish_test
-1
View File
@@ -50,4 +50,3 @@ do_test tkt3930-1.2 {
integrity_check tkt3930-1.3
finish_test
+1
View File
@@ -128,6 +128,7 @@ ifcapable fts3 {
INSERT INTO x1 VALUES('North northwest wind between 8 and 14 mph');
} {
"INSERT INTO x1 VALUES('North northwest wind between 8 and 14 mph');"
"-- DELETE FROM 'main'.'x1_segdir' WHERE level = ?"
"-- INSERT INTO 'main'.'x1_content' VALUES(?,(?))"
"-- REPLACE INTO 'main'.'x1_docsize' VALUES(?,?)"
"-- SELECT value FROM 'main'.'x1_stat' WHERE id=?"
+14 -14
View File
@@ -40,28 +40,28 @@ foreach idxmode {ordered unordered} {
sqlite3 db test.db
foreach {tn sql r(ordered) r(unordered)} {
1 "SELECT * FROM t1 ORDER BY a"
{0 0 0 {SCAN TABLE t1 USING INDEX i1 (~128 rows)}}
{0 0 0 {SCAN TABLE t1 (~128 rows)} 0 0 0 {USE TEMP B-TREE FOR ORDER BY}}
{0 0 0 {SCAN TABLE t1 USING INDEX i1}}
{0 0 0 {SCAN TABLE t1} 0 0 0 {USE TEMP B-TREE FOR ORDER BY}}
2 "SELECT * FROM t1 WHERE a >?"
{0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a>?) (~32 rows)}}
{0 0 0 {SCAN TABLE t1 (~42 rows)}}
{0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a>?)}}
{0 0 0 {SCAN TABLE t1}}
3 "SELECT * FROM t1 WHERE a = ? ORDER BY rowid"
{0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~1 rows)}}
{0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~1 rows)}
{0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}}
{0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}
0 0 0 {USE TEMP B-TREE FOR ORDER BY}}
4 "SELECT max(a) FROM t1"
{0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (~1 rows)}}
{0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (~1 rows)}}
{0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1}}
{0 0 0 {SEARCH TABLE t1}}
5 "SELECT group_concat(b) FROM t1 GROUP BY a"
{0 0 0 {SCAN TABLE t1 USING INDEX i1 (~128 rows)}}
{0 0 0 {SCAN TABLE t1 (~128 rows)} 0 0 0 {USE TEMP B-TREE FOR GROUP BY}}
{0 0 0 {SCAN TABLE t1 USING INDEX i1}}
{0 0 0 {SCAN TABLE t1} 0 0 0 {USE TEMP B-TREE FOR GROUP BY}}
6 "SELECT * FROM t1 WHERE a = ?"
{0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~1 rows)}}
{0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?) (~1 rows)}}
{0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}}
{0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}}
7 "SELECT count(*) FROM t1"
{0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1(~128 rows)}}
{0 0 0 {SCAN TABLE t1 (~128 rows)}}
{0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1}}
{0 0 0 {SCAN TABLE t1}}
} {
do_eqp_test 1.$idxmode.$tn $sql $r($idxmode)
}
-1
View File
@@ -16,4 +16,3 @@ source $testdir/permutations.test
run_test_suite veryquick
finish_test
+13 -12
View File
@@ -618,8 +618,9 @@ do_test vtab1-5-6 {
do_test vtab1-5-7 {
filter $::echo_module
} [list \
xFilter {SELECT rowid, * FROM 't2' WHERE d = ?} \
xFilter {SELECT rowid, * FROM 't1'} \
xFilter {SELECT rowid, * FROM 't2' WHERE d = ?} \
xFilter {SELECT rowid, * FROM 't2' WHERE d = ?} \
]
execsql {
@@ -1133,12 +1134,12 @@ do_test vtab1-14.015 {
do_test vtab1-14.1 {
execsql { DELETE FROM c }
set echo_module ""
execsql { SELECT * FROM echo_c WHERE rowid IN (1, 2, 3) }
set echo_module
} {/xBestIndex {SELECT rowid, . FROM 'c' WHERE rowid = .} xFilter {SELECT rowid, . FROM 'c' WHERE rowid = .} 1/}
#do_test vtab1-14.1 {
# execsql { DELETE FROM c }
# set echo_module ""
# execsql { SELECT * FROM echo_c WHERE rowid IN (1, 2, 3) }
# set echo_module
#} {/.*xBestIndex {SELECT rowid, . FROM 'c' WHERE rowid = .} xFilter {SELECT rowid, . FROM 'c'} 1/}
do_test vtab1-14.2 {
set echo_module ""
@@ -1152,11 +1153,11 @@ do_test vtab1-14.3 {
set echo_module
} [list xBestIndex {SELECT rowid, * FROM 'c' WHERE a = ?} xFilter {SELECT rowid, * FROM 'c' WHERE a = ?} 1]
do_test vtab1-14.4 {
set echo_module ""
execsql { SELECT * FROM echo_c WHERE a IN (1, 2) }
set echo_module
} {/xBestIndex {SELECT rowid, . FROM 'c' WHERE a = .} xFilter {SELECT rowid, . FROM 'c' WHERE a = .} 1/}
#do_test vtab1-14.4 {
# set echo_module ""
# execsql { SELECT * FROM echo_c WHERE a IN (1, 2) }
# set echo_module
#} {/xBestIndex {SELECT rowid, . FROM 'c' WHERE a = .} xFilter {SELECT rowid, . FROM 'c' WHERE a = .} 1/}
do_test vtab1-15.1 {
execsql {
+2 -2
View File
@@ -561,12 +561,12 @@ do_test vtab6-11.4.1 {
catchsql {
SELECT a, b, c FROM ab NATURAL JOIN bc;
}
} {1 {table bc: xBestIndex returned an invalid plan}}
} {1 {table ab: xBestIndex returned an invalid plan}}
do_test vtab6-11.4.2 {
catchsql {
SELECT a, b, c FROM bc NATURAL JOIN ab;
}
} {1 {table ab: xBestIndex returned an invalid plan}}
} {1 {table bc: xBestIndex returned an invalid plan}}
unset ::echo_module_ignore_usable
-1
View File
@@ -88,4 +88,3 @@ do_execsql_test 3.1 {
} {t1}
finish_test
-1
View File
@@ -390,4 +390,3 @@ foreach incr {1 2 3 20 40 60 80 100 120 140 160 180 200 220 240 253 254 255} {
}
finish_test
-1
View File
@@ -293,4 +293,3 @@ for {set i 1} {$i < $REPEATS} {incr i} {
}
finish_test
-1
View File
@@ -96,4 +96,3 @@ do_test walcrash2-1.3 {
catch { db2 close }
finish_test
-1
View File
@@ -126,4 +126,3 @@ for {set i 2} {$i<10000 && [set_test_counter errors]==$nInitialErr} {incr i} {
}
finish_test
-2
View File
@@ -291,5 +291,3 @@ do_multiclient_test tn {
}
finish_test

Some files were not shown because too many files have changed in this diff Show More