diff options
author | drh <drh@noemail.net> | 2002-06-09 01:55:20 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2002-06-09 01:55:20 +0000 |
commit | 48185c15c71473ff8ab5001a6a3b5f58c330918c (patch) | |
tree | 20914698789f4a2ae507f395cc192b8c11b98a8e /src | |
parent | d9e3093038192012c885b9e6074d1d4adac9b693 (diff) | |
download | sqlite-48185c15c71473ff8ab5001a6a3b5f58c330918c.tar.gz sqlite-48185c15c71473ff8ab5001a6a3b5f58c330918c.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/where.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/where.c b/src/where.c index b89ff2411..d71121ea9 100644 --- a/src/where.c +++ b/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; |