mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Added tests for the new IN operator optimizer and fixed a bug that the
new tests found. This completes the implementation of enhancement #63. (CVS 612) FossilOrigin-Name: 2a710e18176c486525f0abb06644a511a2cd1d7a
This commit is contained in:
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\sfor\sticket\s#65:\sIf\san\sinteger\svalue\sis\stoo\sbig\sto\sbe\srepresented\sas\sa\n32-bit\sinteger,\sthen\streat\sit\sas\sa\sstring.\s(CVS\s611)
|
||||
D 2002-06-09T01:16:01
|
||||
C Added\stests\sfor\sthe\snew\sIN\soperator\soptimizer\sand\sfixed\sa\sbug\sthat\sthe\nnew\stests\sfound.\s\sThis\scompletes\sthe\simplementation\sof\senhancement\s#63.\s(CVS\s612)
|
||||
D 2002-06-09T01:55:20
|
||||
F Makefile.in 6291a33b87d2a395aafd7646ee1ed562c6f2c28c
|
||||
F Makefile.template 4e11752e0b5c7a043ca50af4296ec562857ba495
|
||||
F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
|
||||
@ -54,7 +54,7 @@ F src/update.c f68375173bf5338cae3e97012708e10f206aedd9
|
||||
F src/util.c 7cf46b5612f5d12601c697374b9c6b38b2332ce8
|
||||
F src/vdbe.c b315d7ad5086164bb8d8aee8bc9edeafcb68b8ea
|
||||
F src/vdbe.h 1742d6f8b40f40879475b4c41cf4f9980ceb0e21
|
||||
F src/where.c d5308069f8794ec7e9f5084ffd611fe0922ae9f0
|
||||
F src/where.c b7c653054d4941d17f3112776ebcaf00d9613cb7
|
||||
F test/all.test e4d3821eeba751829b419cd47814bd20af4286d1
|
||||
F test/bigrow.test 8ab252dba108f12ad64e337b0f2ff31a807ac578
|
||||
F test/btree.test bf326f546a666617367a7033fa2c07451bd4f8e1
|
||||
@ -107,7 +107,7 @@ F test/unique.test 572aa791327c1e8d797932263e9d67f176cfdb44
|
||||
F test/update.test a0aa0bf83e6fad8407d0e4ad25ebb09b513f5bf4
|
||||
F test/vacuum.test 059871b312eb910bbe49dafde1d01490cc2c6bbe
|
||||
F test/view.test b9851e9142de5e5831fdf18f125cbe1256cb550a
|
||||
F test/where.test 1d85a7eba93e7acc0a971c6d9daead0e49cb023a
|
||||
F test/where.test fe33c2f92de1da8192abf763a2852a4ba270fefe
|
||||
F tool/lemon.c 459cb2bb3738a1ad5cb0ad8b805587a88a885d95
|
||||
F tool/lempar.c 73a991cc3017fb34804250fa901488b5147b3717
|
||||
F tool/memleak.awk 296dfbce7a9ca499b95ce04e30334e64a50052e0
|
||||
@ -136,7 +136,7 @@ F www/speed.tcl da8afcc1d3ccc5696cfb388a68982bc3d9f7f00f
|
||||
F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
|
||||
F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
|
||||
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
|
||||
P 8481e841ebdeabe07bf780246bda1aa053eb60b7
|
||||
R 6174dd4e5dfa7253bbd8e3c34a08582a
|
||||
P ad9624798edbd6d0c4652fed3d74fe87498844ff
|
||||
R 7131726bbe7f69ab24aea1be14cd5f47
|
||||
U drh
|
||||
Z 84f663882ed0b11c01ed6267485637fc
|
||||
Z 566256d2d9ffc189bf51044ba8051993
|
||||
|
@ -1 +1 @@
|
||||
ad9624798edbd6d0c4652fed3d74fe87498844ff
|
||||
2a710e18176c486525f0abb06644a511a2cd1d7a
|
11
src/where.c
11
src/where.c
@ -13,7 +13,7 @@
|
||||
** the WHERE clause of SQL statements. Also found here are subroutines
|
||||
** to generate VDBE code to evaluate expressions.
|
||||
**
|
||||
** $Id: where.c,v 1.49 2002/06/08 23:25:10 drh Exp $
|
||||
** $Id: where.c,v 1.50 2002/06/09 01:55:20 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@ -338,7 +338,8 @@ WhereInfo *sqliteWhereBegin(
|
||||
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
|
||||
int eqMask = 0; /* Index columns covered by an x=... constraint */
|
||||
int ltMask = 0; /* Index columns covered by an x<... constraint */
|
||||
int gtMask = 0; /* Index columns covered by an x>... constraing */
|
||||
int gtMask = 0; /* Index columns covered by an x>... constraint */
|
||||
int inMask = 0; /* Index columns covered by an x IN .. constraint */
|
||||
int nEq, m, score;
|
||||
|
||||
if( pIdx->isDropped ) continue; /* Ignore dropped indices */
|
||||
@ -351,7 +352,10 @@ WhereInfo *sqliteWhereBegin(
|
||||
for(k=0; k<pIdx->nColumn; k++){
|
||||
if( pIdx->aiColumn[k]==iColumn ){
|
||||
switch( aExpr[j].p->op ){
|
||||
case TK_IN:
|
||||
case TK_IN: {
|
||||
if( k==0 ) inMask |= 1;
|
||||
break;
|
||||
}
|
||||
case TK_EQ: {
|
||||
eqMask |= 1<<k;
|
||||
break;
|
||||
@ -416,6 +420,7 @@ WhereInfo *sqliteWhereBegin(
|
||||
m = 1<<nEq;
|
||||
if( m & ltMask ) score++;
|
||||
if( m & gtMask ) score+=2;
|
||||
if( score==0 && inMask ) score = 4;
|
||||
if( score>bestScore ){
|
||||
pBestIdx = pIdx;
|
||||
bestScore = score;
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the use of indices in WHERE clases.
|
||||
#
|
||||
# $Id: where.test,v 1.6 2002/04/30 19:20:29 drh Exp $
|
||||
# $Id: where.test,v 1.7 2002/06/09 01:55:20 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -261,5 +261,87 @@ do_test where-4.4 {
|
||||
}
|
||||
} {99}
|
||||
|
||||
# Verify that IN operators in a WHERE clause are handled correctly.
|
||||
#
|
||||
do_test where-5.1 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE rowid IN (1,2,3,1234) order by 1;
|
||||
}
|
||||
} {1 0 4 2 1 9 3 1 16 0}
|
||||
do_test where-5.2 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE rowid+0 IN (1,2,3,1234) order by 1;
|
||||
}
|
||||
} {1 0 4 2 1 9 3 1 16 99}
|
||||
do_test where-5.3 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE w IN (-1,1,2,3) order by 1;
|
||||
}
|
||||
} {1 0 4 2 1 9 3 1 16 10}
|
||||
do_test where-5.4 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE w+0 IN (-1,1,2,3) order by 1;
|
||||
}
|
||||
} {1 0 4 2 1 9 3 1 16 99}
|
||||
do_test where-5.5 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE rowid IN
|
||||
(select rowid from t1 where rowid IN (-1,2,4))
|
||||
ORDER BY 1;
|
||||
}
|
||||
} {2 1 9 4 2 25 1}
|
||||
do_test where-5.6 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE rowid+0 IN
|
||||
(select rowid from t1 where rowid IN (-1,2,4))
|
||||
ORDER BY 1;
|
||||
}
|
||||
} {2 1 9 4 2 25 99}
|
||||
do_test where-5.7 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE w IN
|
||||
(select rowid from t1 where rowid IN (-1,2,4))
|
||||
ORDER BY 1;
|
||||
}
|
||||
} {2 1 9 4 2 25 7}
|
||||
do_test where-5.8 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE w+0 IN
|
||||
(select rowid from t1 where rowid IN (-1,2,4))
|
||||
ORDER BY 1;
|
||||
}
|
||||
} {2 1 9 4 2 25 99}
|
||||
do_test where-5.9 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE x IN (1,7) ORDER BY 1;
|
||||
}
|
||||
} {2 1 9 3 1 16 6}
|
||||
do_test where-5.10 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE x+0 IN (1,7) ORDER BY 1;
|
||||
}
|
||||
} {2 1 9 3 1 16 99}
|
||||
do_test where-5.11 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE y IN (6400,8100) ORDER BY 1;
|
||||
}
|
||||
} {79 6 6400 89 6 8100 99}
|
||||
do_test where-5.12 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE x=6 AND y IN (6400,8100) ORDER BY 1;
|
||||
}
|
||||
} {79 6 6400 89 6 8100 74}
|
||||
do_test where-5.13 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE x IN (1,7) AND y NOT IN (6400,8100) ORDER BY 1;
|
||||
}
|
||||
} {2 1 9 3 1 16 6}
|
||||
do_test where-5.14 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE x IN (1,7) AND y IN (9,10) ORDER BY 1;
|
||||
}
|
||||
} {2 1 9 6}
|
||||
|
||||
|
||||
|
||||
finish_test
|
||||
|
Reference in New Issue
Block a user