mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Increased test coverage in where.c. (CVS 6146)
FossilOrigin-Name: 1e5725c5179660277c2e8c321877d7ee3ca21808
This commit is contained in:
18
manifest
18
manifest
@ -1,5 +1,5 @@
|
|||||||
C Fix\sa\scomment\sin\spager.c.\sNo\sactual\scode\schanges.\s(CVS\s6145)
|
C Increased\stest\scoverage\sin\swhere.c.\s(CVS\s6146)
|
||||||
D 2009-01-08T18:04:14
|
D 2009-01-08T21:00:03
|
||||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||||
F Makefile.in 05461a9b5803d5ad10c79f989801e9fd2cc3e592
|
F Makefile.in 05461a9b5803d5ad10c79f989801e9fd2cc3e592
|
||||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||||
@ -207,7 +207,7 @@ F src/vdbeblob.c b0dcebfafedcf9c0addc7901ad98f6f986c08935
|
|||||||
F src/vdbemem.c 19f94b504d3da44b31aef200fa6c8e07862de2e8
|
F src/vdbemem.c 19f94b504d3da44b31aef200fa6c8e07862de2e8
|
||||||
F src/vtab.c e39e011d7443a8d574b1b9cde207a35522e6df43
|
F src/vtab.c e39e011d7443a8d574b1b9cde207a35522e6df43
|
||||||
F src/walker.c 488c2660e13224ff70c0c82761118efb547f8f0d
|
F src/walker.c 488c2660e13224ff70c0c82761118efb547f8f0d
|
||||||
F src/where.c c67797ea657ed2ff68f46ba5da393812d7ad72e3
|
F src/where.c 86cd4009ae0b19d9223d526edfd6ed12dceeffc0
|
||||||
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
|
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
|
||||||
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
||||||
F test/alias.test 597662c5d777a122f9a3df0047ea5c5bd383a911
|
F test/alias.test 597662c5d777a122f9a3df0047ea5c5bd383a911
|
||||||
@ -449,7 +449,7 @@ F test/mallocG.test 4584d0d8ddb8009f16ca0c8bab1fa37f6358efa2
|
|||||||
F test/mallocH.test 79b65aed612c9b3ed2dcdaa727c85895fd1bfbdb
|
F test/mallocH.test 79b65aed612c9b3ed2dcdaa727c85895fd1bfbdb
|
||||||
F test/mallocI.test 6e24fe6444bd2999ccc81f984977b44c0d6e5591
|
F test/mallocI.test 6e24fe6444bd2999ccc81f984977b44c0d6e5591
|
||||||
F test/mallocJ.test 44dfbbaca731cb933818ad300b4566265d652609
|
F test/mallocJ.test 44dfbbaca731cb933818ad300b4566265d652609
|
||||||
F test/mallocK.test d3587f6215d34968d88ac8d145ff3d3ea20d9fe5
|
F test/mallocK.test d79968641d1b70d88f6c01bdb9a7eb4a55582cc9
|
||||||
F test/malloc_common.tcl 984baeb6c6b185e798827d1187d426acc2bc4962
|
F test/malloc_common.tcl 984baeb6c6b185e798827d1187d426acc2bc4962
|
||||||
F test/manydb.test b3d3bc4c25657e7f68d157f031eb4db7b3df0d3c
|
F test/manydb.test b3d3bc4c25657e7f68d157f031eb4db7b3df0d3c
|
||||||
F test/memdb.test a67c85a29d3187ac81d3628fcf9417d8a1be9ecb
|
F test/memdb.test a67c85a29d3187ac81d3628fcf9417d8a1be9ecb
|
||||||
@ -665,7 +665,7 @@ F test/where6.test 42c4373595f4409d9c6a9987b4a60000ad664faf
|
|||||||
F test/where7.test 88eb7c53bdbd900cfd130e8f40bb3036bfab031d
|
F test/where7.test 88eb7c53bdbd900cfd130e8f40bb3036bfab031d
|
||||||
F test/where8.test 1b9152a086408ee789166d0a954abc597372f868
|
F test/where8.test 1b9152a086408ee789166d0a954abc597372f868
|
||||||
F test/where8m.test c1010d61826412ff66abd29bfb32e5d6b37d965c
|
F test/where8m.test c1010d61826412ff66abd29bfb32e5d6b37d965c
|
||||||
F test/where9.test 45c2984ccb3022f09892c420806d827431c284c3
|
F test/where9.test a46d394037a40b56e7855d29cce951f91108c353
|
||||||
F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31
|
F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31
|
||||||
F test/zeroblob.test 792124852ec61458a2eb527b5091791215e0be95
|
F test/zeroblob.test 792124852ec61458a2eb527b5091791215e0be95
|
||||||
F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
|
F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
|
||||||
@ -696,7 +696,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
|||||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
P 931f3a21bd4b6c5760ed64c23e8210cf2c3e3ab5
|
P 44d3bfddf44b10b3744db6b41bc3f53c3903df5e
|
||||||
R c8725ae312af088a259f78aa014f9f98
|
R a3a710f488fb777e4d1b19573518f0a9
|
||||||
U danielk1977
|
U drh
|
||||||
Z 1626db2f414f98e49e072e67ca692185
|
Z 97bbef0b1a294a8bf574a868d2fbe20c
|
||||||
|
@ -1 +1 @@
|
|||||||
44d3bfddf44b10b3744db6b41bc3f53c3903df5e
|
1e5725c5179660277c2e8c321877d7ee3ca21808
|
@ -16,7 +16,7 @@
|
|||||||
** so is applicable. Because this module is responsible for selecting
|
** so is applicable. Because this module is responsible for selecting
|
||||||
** indices, you might also think of this module as the "query optimizer".
|
** indices, you might also think of this module as the "query optimizer".
|
||||||
**
|
**
|
||||||
** $Id: where.c,v 1.360 2009/01/08 03:11:19 drh Exp $
|
** $Id: where.c,v 1.361 2009/01/08 21:00:03 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@ -1859,12 +1859,9 @@ static void bestIndex(
|
|||||||
}else{
|
}else{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if( sTermCost.plan.wsFlags==0 ){
|
|
||||||
rTotal = pCost->rCost;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
rTotal += sTermCost.rCost;
|
rTotal += sTermCost.rCost;
|
||||||
nRow += sTermCost.nRow;
|
nRow += sTermCost.nRow;
|
||||||
|
if( rTotal>=pCost->rCost ) break;
|
||||||
}
|
}
|
||||||
WHERETRACE(("... multi-index OR cost=%.9g nrow=%.9g\n",
|
WHERETRACE(("... multi-index OR cost=%.9g nrow=%.9g\n",
|
||||||
rTotal, nRow));
|
rTotal, nRow));
|
||||||
|
@ -11,13 +11,12 @@
|
|||||||
#
|
#
|
||||||
# This test script checks malloc failures in WHERE clause analysis.
|
# This test script checks malloc failures in WHERE clause analysis.
|
||||||
#
|
#
|
||||||
# $Id: mallocK.test,v 1.2 2009/01/08 03:11:19 drh Exp $
|
# $Id: mallocK.test,v 1.3 2009/01/08 21:00:03 drh Exp $
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
source $testdir/malloc_common.tcl
|
source $testdir/malloc_common.tcl
|
||||||
|
|
||||||
|
|
||||||
set sql {SELECT * FROM t1, t2 WHERE (a=1 OR a=2)}
|
set sql {SELECT * FROM t1, t2 WHERE (a=1 OR a=2)}
|
||||||
for {set x 1} {$x<5} {incr x} {
|
for {set x 1} {$x<5} {incr x} {
|
||||||
append sql " AND b=y"
|
append sql " AND b=y"
|
||||||
@ -27,7 +26,7 @@ for {set x 1} {$x<5} {incr x} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set sql {SELECT * FROM t1 WHERE a GLOB 'xyz*'}
|
set sql {SELECT * FROM t1 WHERE a GLOB 'xyz*' AND (a=1 OR a=2)}
|
||||||
for {set x 1} {$x<5} {incr x} {
|
for {set x 1} {$x<5} {incr x} {
|
||||||
append sql " AND b!=$x"
|
append sql " AND b!=$x"
|
||||||
do_malloc_test mallocK-2.$x -sqlbody $sql -sqlprep {
|
do_malloc_test mallocK-2.$x -sqlbody $sql -sqlprep {
|
||||||
@ -37,17 +36,29 @@ for {set x 1} {$x<5} {incr x} {
|
|||||||
|
|
||||||
set sql {SELECT * FROM t1 WHERE a BETWEEN 5 AND 10}
|
set sql {SELECT * FROM t1 WHERE a BETWEEN 5 AND 10}
|
||||||
for {set x 1} {$x<5} {incr x} {
|
for {set x 1} {$x<5} {incr x} {
|
||||||
append sql " AND b!=$x"
|
append sql " AND b=$x"
|
||||||
do_malloc_test mallocK-3.$x -sqlbody $sql -sqlprep {
|
do_malloc_test mallocK-3.$x -sqlbody $sql -sqlprep {
|
||||||
CREATE TABLE t1(a,b);
|
CREATE TABLE t1(a,b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set sql {SELECT * FROM t1 WHERE b=0}
|
||||||
|
for {set x 1} {$x<5} {incr x} {
|
||||||
|
set term "(b=$x"
|
||||||
|
for {set y 0} {$y<$x} {incr y} {
|
||||||
|
append term " AND a!=$y"
|
||||||
|
}
|
||||||
|
append sql " OR $term)"
|
||||||
|
do_malloc_test mallocK-4.$x -sqlbody $sql -sqlprep {
|
||||||
|
CREATE TABLE t1(a,b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ifcapable vtab {
|
ifcapable vtab {
|
||||||
set sql {SELECT * FROM t2 WHERE a MATCH 'xyz'}
|
set sql {SELECT * FROM t2 WHERE a MATCH 'xyz'}
|
||||||
for {set x 1} {$x<5} {incr x} {
|
for {set x 1} {$x<5} {incr x} {
|
||||||
append sql " AND b!=$x"
|
append sql " AND b!=$x"
|
||||||
do_malloc_test mallocK-4.$x -sqlbody $sql -tclprep {
|
do_malloc_test mallocK-5.$x -sqlbody $sql -tclprep {
|
||||||
register_echo_module [sqlite3_connection_pointer db]
|
register_echo_module [sqlite3_connection_pointer db]
|
||||||
db eval {
|
db eval {
|
||||||
CREATE TABLE t1(a,b);
|
CREATE TABLE t1(a,b);
|
||||||
|
131
test/where9.test
131
test/where9.test
@ -11,7 +11,7 @@
|
|||||||
# This file implements regression tests for SQLite library. The
|
# This file implements regression tests for SQLite library. The
|
||||||
# focus of this file is testing the multi-index OR clause optimizer.
|
# focus of this file is testing the multi-index OR clause optimizer.
|
||||||
#
|
#
|
||||||
# $Id: where9.test,v 1.4 2009/01/08 03:11:19 drh Exp $
|
# $Id: where9.test,v 1.5 2009/01/08 21:00:03 drh Exp $
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
@ -151,6 +151,10 @@ do_test where9-1.1 {
|
|||||||
CREATE TABLE t3(x,y);
|
CREATE TABLE t3(x,y);
|
||||||
INSERT INTO t3 VALUES(1,80);
|
INSERT INTO t3 VALUES(1,80);
|
||||||
INSERT INTO t3 VALUES(2,80);
|
INSERT INTO t3 VALUES(2,80);
|
||||||
|
CREATE TABLE t4(a INTEGER PRIMARY KEY,b,c,d,e,f,g);
|
||||||
|
INSERT INTO t4 SELECT * FROM t1;
|
||||||
|
CREATE INDEX t4b ON t4(b);
|
||||||
|
CREATE INDEX t4c ON t4(c);
|
||||||
}
|
}
|
||||||
} {}
|
} {}
|
||||||
|
|
||||||
@ -190,7 +194,18 @@ do_test where9-1.2.4 {
|
|||||||
ORDER BY a
|
ORDER BY a
|
||||||
}
|
}
|
||||||
} {90 91 92 96 97 99 scan 98 sort 0}
|
} {90 91 92 96 97 99 scan 98 sort 0}
|
||||||
do_test where9-1.3 {
|
do_test where9-1.2.5 {
|
||||||
|
breakpoint
|
||||||
|
count_steps {
|
||||||
|
SELECT a FROM t4
|
||||||
|
WHERE b IS NULL
|
||||||
|
OR c IS NULL
|
||||||
|
OR d IS NULL
|
||||||
|
ORDER BY a
|
||||||
|
}
|
||||||
|
} {90 91 92 96 97 99 scan 98 sort 0}
|
||||||
|
|
||||||
|
do_test where9-1.3.1 {
|
||||||
count_steps {
|
count_steps {
|
||||||
SELECT a FROM t1
|
SELECT a FROM t1
|
||||||
WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
|
WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
|
||||||
@ -199,6 +214,34 @@ do_test where9-1.3 {
|
|||||||
ORDER BY a
|
ORDER BY a
|
||||||
}
|
}
|
||||||
} {90 91 92 97 scan 0 sort 0}
|
} {90 91 92 97 scan 0 sort 0}
|
||||||
|
do_test where9-1.3.2 {
|
||||||
|
count_steps {
|
||||||
|
SELECT a FROM t4
|
||||||
|
WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
|
||||||
|
OR (b NOT NULL AND c IS NULL AND d NOT NULL)
|
||||||
|
OR (b NOT NULL AND c NOT NULL AND d IS NULL)
|
||||||
|
ORDER BY a
|
||||||
|
}
|
||||||
|
} {90 91 92 97 scan 98 sort 0}
|
||||||
|
do_test where9-1.3.3 {
|
||||||
|
count_steps {
|
||||||
|
SELECT a FROM t4
|
||||||
|
WHERE (b NOT NULL AND c NOT NULL AND d IS NULL)
|
||||||
|
OR (b IS NULL AND c NOT NULL AND d NOT NULL)
|
||||||
|
OR (b NOT NULL AND c IS NULL AND d NOT NULL)
|
||||||
|
ORDER BY a
|
||||||
|
}
|
||||||
|
} {90 91 92 97 scan 98 sort 0}
|
||||||
|
do_test where9-1.3.4 {
|
||||||
|
count_steps {
|
||||||
|
SELECT a FROM t4
|
||||||
|
WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
|
||||||
|
OR (b NOT NULL AND c NOT NULL AND d IS NULL)
|
||||||
|
OR (b NOT NULL AND c IS NULL AND d NOT NULL)
|
||||||
|
ORDER BY a
|
||||||
|
}
|
||||||
|
} {90 91 92 97 scan 98 sort 0}
|
||||||
|
|
||||||
do_test where9-1.4 {
|
do_test where9-1.4 {
|
||||||
count_steps {
|
count_steps {
|
||||||
SELECT a FROM t1
|
SELECT a FROM t1
|
||||||
@ -674,5 +717,89 @@ do_test where9-6.5.4 {
|
|||||||
}
|
}
|
||||||
} {99 105 131 157 182 183 184 185 186 187}
|
} {99 105 131 157 182 183 184 185 186 187}
|
||||||
|
|
||||||
|
do_test where9-6.6.1 {
|
||||||
|
count_steps {
|
||||||
|
BEGIN;
|
||||||
|
DELETE FROM t1
|
||||||
|
WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
|
||||||
|
OR (b NOT NULL AND +c IS NULL AND d NOT NULL)
|
||||||
|
OR (b NOT NULL AND c NOT NULL AND d IS NULL)
|
||||||
|
}
|
||||||
|
} {scan 98 sort 0} ;# DELETEs rows 90 91 92 97
|
||||||
|
do_test where9-6.6.2 {
|
||||||
|
db eval {
|
||||||
|
SELECT count(*) FROM t1 UNION ALL
|
||||||
|
SELECT a FROM t1 WHERE a BETWEEN 85 AND 100;
|
||||||
|
ROLLBACK;
|
||||||
|
}
|
||||||
|
} {95 85 86 87 88 89 93 94 95 96 98 99}
|
||||||
|
|
||||||
|
do_test where9-6.6.3 {
|
||||||
|
count_steps {
|
||||||
|
BEGIN;
|
||||||
|
UPDATE t1 SET a=a+100
|
||||||
|
WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
|
||||||
|
OR (b NOT NULL AND +c IS NULL AND d NOT NULL)
|
||||||
|
OR (b NOT NULL AND c NOT NULL AND d IS NULL)
|
||||||
|
}
|
||||||
|
} {scan 98 sort 0} ;# Add 100 to rowids 90 91 92 97
|
||||||
|
do_test where9-6.6.4 {
|
||||||
|
db eval {
|
||||||
|
SELECT count(*) FROM t1 UNION ALL
|
||||||
|
SELECT a FROM t1 WHERE a BETWEEN 85 AND 200;
|
||||||
|
ROLLBACK;
|
||||||
|
}
|
||||||
|
} {99 85 86 87 88 89 93 94 95 96 98 99 190 191 192 197}
|
||||||
|
|
||||||
|
do_test where9-6.7.1 {
|
||||||
|
count_steps {
|
||||||
|
BEGIN;
|
||||||
|
DELETE FROM t1 NOT INDEXED
|
||||||
|
WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
|
||||||
|
OR (b NOT NULL AND c IS NULL AND d NOT NULL)
|
||||||
|
OR (b NOT NULL AND c NOT NULL AND d IS NULL)
|
||||||
|
}
|
||||||
|
} {scan 98 sort 0} ;# DELETEs rows 90 91 92 97
|
||||||
|
do_test where9-6.7.2 {
|
||||||
|
db eval {
|
||||||
|
SELECT count(*) FROM t1 UNION ALL
|
||||||
|
SELECT a FROM t1 WHERE a BETWEEN 85 AND 100;
|
||||||
|
ROLLBACK;
|
||||||
|
}
|
||||||
|
} {95 85 86 87 88 89 93 94 95 96 98 99}
|
||||||
|
|
||||||
|
do_test where9-6.7.3 {
|
||||||
|
count_steps {
|
||||||
|
BEGIN;
|
||||||
|
UPDATE t1 NOT INDEXED SET a=a+100
|
||||||
|
WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
|
||||||
|
OR (b NOT NULL AND c IS NULL AND d NOT NULL)
|
||||||
|
OR (b NOT NULL AND c NOT NULL AND d IS NULL)
|
||||||
|
}
|
||||||
|
} {scan 98 sort 0} ;# Add 100 to rowids 90 91 92 97
|
||||||
|
do_test where9-6.7.4 {
|
||||||
|
db eval {
|
||||||
|
SELECT count(*) FROM t1 UNION ALL
|
||||||
|
SELECT a FROM t1 WHERE a BETWEEN 85 AND 200;
|
||||||
|
ROLLBACK;
|
||||||
|
}
|
||||||
|
} {99 85 86 87 88 89 93 94 95 96 98 99 190 191 192 197}
|
||||||
|
|
||||||
|
do_test where9-6.8.1 {
|
||||||
|
catchsql {
|
||||||
|
DELETE FROM t1 INDEXED BY t1b
|
||||||
|
WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
|
||||||
|
OR (b NOT NULL AND c IS NULL AND d NOT NULL)
|
||||||
|
OR (b NOT NULL AND c NOT NULL AND d IS NULL)
|
||||||
|
}
|
||||||
|
} {1 {cannot use index: t1b}}
|
||||||
|
do_test where9-6.8.2 {
|
||||||
|
catchsql {
|
||||||
|
UPDATE t1 INDEXED BY t1b SET a=a+100
|
||||||
|
WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)
|
||||||
|
OR (b NOT NULL AND c IS NULL AND d NOT NULL)
|
||||||
|
OR (b NOT NULL AND c NOT NULL AND d IS NULL)
|
||||||
|
}
|
||||||
|
} {1 {cannot use index: t1b}}
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
Reference in New Issue
Block a user