diff options
author | danielk1977 <danielk1977@noemail.net> | 2007-05-29 12:11:29 +0000 |
---|---|---|
committer | danielk1977 <danielk1977@noemail.net> | 2007-05-29 12:11:29 +0000 |
commit | bcbb04e5010d1b40563d06633a4ad2cdc71c8677 (patch) | |
tree | 0d251d8956aca08e4657e5f89f66707818ba58a3 /src/expr.c | |
parent | 331bf02e0e7faad5a6a1351870064f65415793ae (diff) | |
download | sqlite-bcbb04e5010d1b40563d06633a4ad2cdc71c8677.tar.gz sqlite-bcbb04e5010d1b40563d06633a4ad2cdc71c8677.zip |
Consider explicit collate clauses when matching WHERE constraints to indices. Fix for #2391. (CVS 4040)
FossilOrigin-Name: f9a95e92dfaaa61ec0a44b9b7017b07929c94d26
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/expr.c b/src/expr.c index 921cca343..c4f395bf8 100644 --- a/src/expr.c +++ b/src/expr.c @@ -12,7 +12,7 @@ ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** -** $Id: expr.c,v 1.294 2007/05/15 07:00:34 danielk1977 Exp $ +** $Id: expr.c,v 1.295 2007/05/29 12:11:30 danielk1977 Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -171,15 +171,21 @@ static int binaryCompareP1(Expr *pExpr1, Expr *pExpr2, int jumpIfNull){ ** used. Otherwise the collation sequence for the right hand expression ** is used, or the default (BINARY) if neither expression has a collating ** type. +** +** Argument pRight (but not pLeft) may be a null pointer. In this case, +** it is not considered. */ -static CollSeq* binaryCompareCollSeq(Parse *pParse, Expr *pLeft, Expr *pRight){ +CollSeq* sqlite3BinaryCompareCollSeq( + Parse *pParse, + Expr *pLeft, + Expr *pRight +){ CollSeq *pColl; assert( pLeft ); - assert( pRight ); if( pLeft->flags & EP_ExpCollate ){ assert( pLeft->pColl ); pColl = pLeft->pColl; - }else if( pRight->flags & EP_ExpCollate ){ + }else if( pRight && pRight->flags & EP_ExpCollate ){ assert( pRight->pColl ); pColl = pRight->pColl; }else{ @@ -203,7 +209,7 @@ static int codeCompare( int jumpIfNull /* If true, jump if either operand is NULL */ ){ int p1 = binaryCompareP1(pLeft, pRight, jumpIfNull); - CollSeq *p3 = binaryCompareCollSeq(pParse, pLeft, pRight); + CollSeq *p3 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight); return sqlite3VdbeOp3(pParse->pVdbe, opcode, p1, dest, (void*)p3, P3_COLLSEQ); } @@ -1533,7 +1539,7 @@ void sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){ } pEList = pExpr->pSelect->pEList; if( pEList && pEList->nExpr>0 ){ - keyInfo.aColl[0] = binaryCompareCollSeq(pParse, pExpr->pLeft, + keyInfo.aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pEList->a[0].pExpr); } }else if( pExpr->pList ){ |