mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-16 23:02:26 +03:00
The LIKE optimization does the right thing when collating sequences are
present. LIKE expressions where the left-hand side has COLLATE NOCASE are optimized in the default case. (CVS 2637) FossilOrigin-Name: ef84ff795c85e9d28f1cac84ff42d8d4ef84cfc4
This commit is contained in:
15
src/where.c
15
src/where.c
@@ -16,7 +16,7 @@
|
||||
** so is applicable. Because this module is responsible for selecting
|
||||
** indices, you might also think of this module as the "query optimizer".
|
||||
**
|
||||
** $Id: where.c,v 1.165 2005/08/24 03:52:19 drh Exp $
|
||||
** $Id: where.c,v 1.166 2005/08/28 17:00:25 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@@ -479,8 +479,11 @@ static int isLikeOrGlob(
|
||||
Expr *pRight, *pLeft;
|
||||
ExprList *pList;
|
||||
int c, cnt;
|
||||
int noCase;
|
||||
char wc[3];
|
||||
if( !sqlite3IsLikeFunction(db, pExpr, wc) ){
|
||||
CollSeq *pColl;
|
||||
|
||||
if( !sqlite3IsLikeFunction(db, pExpr, &noCase, wc) ){
|
||||
return 0;
|
||||
}
|
||||
pList = pExpr->pList;
|
||||
@@ -492,6 +495,14 @@ static int isLikeOrGlob(
|
||||
if( pLeft->op!=TK_COLUMN ){
|
||||
return 0;
|
||||
}
|
||||
pColl = pLeft->pColl;
|
||||
if( pColl==0 ){
|
||||
pColl = db->pDfltColl;
|
||||
}
|
||||
if( (pColl->type!=SQLITE_COLL_BINARY || noCase) &&
|
||||
(pColl->type!=SQLITE_COLL_NOCASE || !noCase) ){
|
||||
return 0;
|
||||
}
|
||||
sqlite3DequoteExpr(pRight);
|
||||
z = pRight->token.z;
|
||||
for(cnt=0; (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2]; cnt++){}
|
||||
|
||||
Reference in New Issue
Block a user