/ Check-in [cc9c1217]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Additional comments to clarify the operation of the LIKE optimizer in where.c. (CVS 6731)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:cc9c12170c3f6f0f485977e47e7fbb75c50e82b1
User & Date: drh 2009-06-08 19:44:37
Context
2009-06-09
09:41
Do not clear the MemPage.nFree variable when insertCell() adds an overflow cell to a page. Not doing this means balance_quick() can avoid a call to sqlite3BtreeInitPage(). (CVS 6732) check-in: 8f1c1f61 user: danielk1977 tags: trunk
2009-06-08
19:44
Additional comments to clarify the operation of the LIKE optimizer in where.c. (CVS 6731) check-in: cc9c1217 user: drh tags: trunk
17:11
Clarification of the operation of the OR-term optimizer in where.c. (CVS 6730) check-in: 6b42dc3d user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

    12     12   ** This module contains C code that generates VDBE code used to process
    13     13   ** the WHERE clause of SQL statements.  This module is responsible for
    14     14   ** generating the code that loops through a table looking for applicable
    15     15   ** rows.  Indices are selected and used to speed the search when doing
    16     16   ** so is applicable.  Because this module is responsible for selecting
    17     17   ** indices, you might also think of this module as the "query optimizer".
    18     18   **
    19         -** $Id: where.c,v 1.403 2009/06/08 17:11:08 drh Exp $
           19  +** $Id: where.c,v 1.404 2009/06/08 19:44:37 drh Exp $
    20     20   */
    21     21   #include "sqliteInt.h"
    22     22   
    23     23   /*
    24     24   ** Trace output macros
    25     25   */
    26     26   #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
................................................................................
  1199   1199   
  1200   1200       pLeft = pExpr->x.pList->a[1].pExpr;
  1201   1201       pRight = pExpr->x.pList->a[0].pExpr;
  1202   1202       pStr1 = sqlite3Expr(db, TK_STRING, pRight->u.zToken);
  1203   1203       if( pStr1 ) pStr1->u.zToken[nPattern] = 0;
  1204   1204       pStr2 = sqlite3ExprDup(db, pStr1, 0);
  1205   1205       if( !db->mallocFailed ){
  1206         -      u8 c, *pC;
         1206  +      u8 c, *pC;       /* Last character before the first wildcard */
  1207   1207         pC = (u8*)&pStr2->u.zToken[nPattern-1];
  1208   1208         c = *pC;
  1209   1209         if( noCase ){
  1210         -        if( c=='@' ) isComplete = 0;
         1210  +        /* The point is to increment the last character before the first
         1211  +        ** wildcard.  But if we increment '@', that will push it into the
         1212  +        ** alphabetic range where case conversions will mess up the 
         1213  +        ** inequality.  To avoid this, make sure to also run the full
         1214  +        ** LIKE on all candidate expressions by clearing the isComplete flag
         1215  +        */
         1216  +        if( c=='A'-1 ) isComplete = 0;
         1217  +
  1211   1218           c = sqlite3UpperToLower[c];
  1212   1219         }
  1213   1220         *pC = c + 1;
  1214   1221       }
  1215   1222       pNewExpr1 = sqlite3PExpr(pParse, TK_GE, sqlite3ExprDup(db,pLeft,0),pStr1,0);
  1216   1223       idxNew1 = whereClauseInsert(pWC, pNewExpr1, TERM_VIRTUAL|TERM_DYNAMIC);
  1217   1224       testcase( idxNew1==0 );