mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Fix a bug in the multi-index OR cost estimator. Remove leftover "breakpoint"
commands from test scripts. (CVS 6086) FossilOrigin-Name: b090d5736d7eaec17a39d3133e1587b1d2a42acb
This commit is contained in:
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this script testing the callback-free C/C++ API.
|
||||
#
|
||||
# $Id: capi2.test,v 1.36 2008/09/01 15:52:11 drh Exp $
|
||||
# $Id: capi2.test,v 1.37 2008/12/30 17:55:00 drh Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@ -722,7 +722,6 @@ ifcapable view&&subquery {
|
||||
check_origins {SELECT b, a FROM (SELECT col1 AS a, col2 AS b FROM view1)}
|
||||
} [list {main tab1 col2} {main tab1 col1}]
|
||||
do_test capi2-12.5 {
|
||||
breakpoint
|
||||
check_origins {SELECT (SELECT col2 FROM view1), (SELECT col1 FROM view1)}
|
||||
} [list {main tab1 col2} {main tab1 col1}]
|
||||
do_test capi2-12.6 {
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing expressions.
|
||||
#
|
||||
# $Id: expr.test,v 1.65 2008/08/22 16:29:51 drh Exp $
|
||||
# $Id: expr.test,v 1.66 2008/12/30 17:55:00 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -606,8 +606,6 @@ test_expr2 expr-7.60 {LIKE('_4',b)} {6}
|
||||
test_expr2 expr-7.61 {GLOB('1?',a)} {10 11 12 13 14 15 16 17 18 19}
|
||||
test_expr2 expr-7.62 {GLOB('1*4',b)} {10 14}
|
||||
test_expr2 expr-7.63 {GLOB('*1[456]',b)} {4}
|
||||
|
||||
breakpoint
|
||||
test_expr2 expr-7.64 {b = abs(-2)} {1}
|
||||
test_expr2 expr-7.65 {b = abs(+-2)} {1}
|
||||
test_expr2 expr-7.66 {b = abs(++-2)} {1}
|
||||
|
@ -18,7 +18,7 @@
|
||||
# no longer the case. In version 3.6.2, sqlite3_release_memory() only
|
||||
# reclaims clean pages. This test file has been updated accordingly.
|
||||
#
|
||||
# $Id: malloc5.test,v 1.20 2008/08/27 16:38:57 danielk1977 Exp $
|
||||
# $Id: malloc5.test,v 1.21 2008/12/30 17:55:00 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -314,7 +314,6 @@ do_test malloc5-6.1.2 {
|
||||
} {10 10}
|
||||
|
||||
do_test malloc5-6.2.1 {
|
||||
breakpoint
|
||||
execsql {SELECT * FROM abc} db2
|
||||
execsql {SELECT * FROM abc} db
|
||||
expr [nPage db] + [nPage db2]
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this script is page cache subsystem.
|
||||
#
|
||||
# $Id: pager2.test,v 1.8 2008/10/17 18:51:53 danielk1977 Exp $
|
||||
# $Id: pager2.test,v 1.9 2008/12/30 17:55:00 drh Exp $
|
||||
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@ -342,7 +342,6 @@ for {set i 1} {$i<20} {incr i} {
|
||||
}
|
||||
set res
|
||||
} {}
|
||||
breakpoint
|
||||
do_test pager2-4.5.$i.5 {
|
||||
page_write $g1 "Page-1 v$i"
|
||||
lrange [pager_stats $p1] 8 9
|
||||
|
@ -12,7 +12,7 @@
|
||||
#
|
||||
# This file implements tests for the PRAGMA command.
|
||||
#
|
||||
# $Id: pragma.test,v 1.70 2008/11/21 00:10:35 aswift Exp $
|
||||
# $Id: pragma.test,v 1.71 2008/12/30 17:55:00 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -570,7 +570,6 @@ ifcapable tempdb {
|
||||
} {0 col_main {} 0 {} 0}
|
||||
}
|
||||
|
||||
breakpoint
|
||||
do_test pragma-6.7 {
|
||||
execsql {
|
||||
CREATE TABLE test_table(
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the multi-index OR clause optimizer.
|
||||
#
|
||||
# $Id: where7.test,v 1.5 2008/12/30 14:40:07 drh Exp $
|
||||
# $Id: where7.test,v 1.6 2008/12/30 17:55:00 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -106,6 +106,17 @@ do_test where7-1.13 {
|
||||
}
|
||||
} {5 4 1 scan 0 sort 1}
|
||||
|
||||
do_test where7-1.14 {
|
||||
count_steps {
|
||||
SELECT a FROM t1 WHERE (d=8 OR c=6 OR b=4) AND +a>0
|
||||
}
|
||||
} {3 scan 4 sort 0}
|
||||
do_test where7-1.15 {
|
||||
count_steps {
|
||||
SELECT a FROM t1 WHERE +a>=0 AND (d=8 OR c=6 OR b=4)
|
||||
}
|
||||
} {3 scan 4 sort 0}
|
||||
|
||||
do_test where7-1.20 {
|
||||
set sql "SELECT a FROM t1 WHERE a=11 OR b=11"
|
||||
for {set i 12} {$i<400} {incr i} {
|
||||
|
116
test/where9.test
116
test/where9.test
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the multi-index OR clause optimizer.
|
||||
#
|
||||
# $Id: where9.test,v 1.2 2008/12/30 16:35:53 drh Exp $
|
||||
# $Id: where9.test,v 1.3 2008/12/30 17:55:00 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -338,4 +338,118 @@ ifcapable explain {
|
||||
} {1 1 1}
|
||||
}
|
||||
|
||||
# Make sure that INDEXED BY and multi-index OR clauses play well with
|
||||
# one another.
|
||||
#
|
||||
do_test where9-4.1 {
|
||||
count_steps {
|
||||
SELECT a FROM t1
|
||||
WHERE b>1000
|
||||
AND (c=31031 OR d IS NULL)
|
||||
ORDER BY +a
|
||||
}
|
||||
} {92 93 97 scan 0 sort 1}
|
||||
do_test where9-4.2 {
|
||||
count_steps {
|
||||
SELECT a FROM t1
|
||||
WHERE b>1000
|
||||
AND (c=31031 OR +d IS NULL)
|
||||
ORDER BY +a
|
||||
}
|
||||
} {92 93 97 scan 0 sort 1}
|
||||
do_test where9-4.3 {
|
||||
count_steps {
|
||||
SELECT a FROM t1
|
||||
WHERE +b>1000
|
||||
AND (c=31031 OR d IS NULL)
|
||||
ORDER BY +a
|
||||
}
|
||||
} {92 93 97 scan 0 sort 1}
|
||||
do_test where9-4.4 {
|
||||
count_steps {
|
||||
SELECT a FROM t1 INDEXED BY t1b
|
||||
WHERE b>1000
|
||||
AND (c=31031 OR d IS NULL)
|
||||
ORDER BY +a
|
||||
}
|
||||
} {92 93 97 scan 0 sort 1}
|
||||
do_test where9-4.5 {
|
||||
catchsql {
|
||||
SELECT a FROM t1 INDEXED BY t1b
|
||||
WHERE +b>1000
|
||||
AND (c=31031 OR d IS NULL)
|
||||
ORDER BY +a
|
||||
}
|
||||
} {1 {cannot use index: t1b}}
|
||||
do_test where9-4.6 {
|
||||
count_steps {
|
||||
SELECT a FROM t1 NOT INDEXED
|
||||
WHERE b>1000
|
||||
AND (c=31031 OR d IS NULL)
|
||||
ORDER BY +a
|
||||
}
|
||||
} {92 93 97 scan 98 sort 1}
|
||||
do_test where9-4.7 {
|
||||
catchsql {
|
||||
SELECT a FROM t1 INDEXED BY t1c
|
||||
WHERE b>1000
|
||||
AND (c=31031 OR d IS NULL)
|
||||
ORDER BY +a
|
||||
}
|
||||
} {1 {cannot use index: t1c}}
|
||||
do_test where9-4.8 {
|
||||
catchsql {
|
||||
SELECT a FROM t1 INDEXED BY t1d
|
||||
WHERE b>1000
|
||||
AND (c=31031 OR d IS NULL)
|
||||
ORDER BY +a
|
||||
}
|
||||
} {1 {cannot use index: t1d}}
|
||||
|
||||
ifcapable explain {
|
||||
# The (c=31031 OR d IS NULL) clause is preferred over b>1000 because
|
||||
# the former is an equality test which is expected to return fewer rows.
|
||||
#
|
||||
do_test where9-5.1 {
|
||||
set r [db eval {
|
||||
EXPLAIN QUERY PLAN
|
||||
SELECT a FROM t1
|
||||
WHERE b>1000
|
||||
AND (c=31031 OR d IS NULL)
|
||||
}]
|
||||
set a [expr {[lsearch $r {TABLE t1 VIA MULTI-INDEX UNION}]>=0}]
|
||||
set b [expr {[lsearch $r {TABLE t1 WITH INDEX t1b}]>=0}]
|
||||
concat $a $b
|
||||
} {1 0}
|
||||
|
||||
# In contrast, b=1000 is preferred over any OR-clause.
|
||||
#
|
||||
do_test where9-5.2 {
|
||||
set r [db eval {
|
||||
EXPLAIN QUERY PLAN
|
||||
SELECT a FROM t1
|
||||
WHERE b=1000
|
||||
AND (c=31031 OR d IS NULL)
|
||||
}]
|
||||
set a [expr {[lsearch $r {TABLE t1 VIA MULTI-INDEX UNION}]>=0}]
|
||||
set b [expr {[lsearch $r {TABLE t1 WITH INDEX t1b}]>=0}]
|
||||
concat $a $b
|
||||
} {0 1}
|
||||
|
||||
# Likewise, inequalities in an AND are preferred over inequalities in
|
||||
# an OR.
|
||||
#
|
||||
do_test where9-5.3 {
|
||||
set r [db eval {
|
||||
EXPLAIN QUERY PLAN
|
||||
SELECT a FROM t1
|
||||
WHERE b>1000
|
||||
AND (c>=31031 OR d IS NULL)
|
||||
}]
|
||||
set a [expr {[lsearch $r {TABLE t1 VIA MULTI-INDEX UNION}]>=0}]
|
||||
set b [expr {[lsearch $r {TABLE t1 WITH INDEX t1b}]>=0}]
|
||||
concat $a $b
|
||||
} {0 1}
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
Reference in New Issue
Block a user