/ Check-in [abf64d1d]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Fix a bug in the LIKE optimization that was causing the pattern string to be dequoted twice. Ticket #2407. (CVS 4056)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: abf64d1d0ae3e84c4482b38198eeb44b62cc5d9e
User & Date: drh 2007-06-11 12:56:15
Context
2007-06-11
23:23
Fix typo in the limits.html document. Ticket #2410. (CVS 4057) check-in: d3fe186c user: drh tags: trunk
12:56
Fix a bug in the LIKE optimization that was causing the pattern string to be dequoted twice. Ticket #2407. (CVS 4056) check-in: abf64d1d user: drh tags: trunk
08:00
Add a README.txt file for the ICU extension. (CVS 4055) check-in: 7b692782 user: danielk1977 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 reponsible 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.252 2007/06/08 08:39:02 drh Exp $
           19  +** $Id: where.c,v 1.253 2007/06/11 12:56:15 drh Exp $
    20     20   */
    21     21   #include "sqliteInt.h"
    22     22   
    23     23   /*
    24     24   ** The number of bits in a Bitmask.  "BMS" means "BitMask Size".
    25     25   */
    26     26   #define BMS  (sizeof(Bitmask)*8)
................................................................................
   874    874   
   875    875       pLeft = pExpr->pList->a[1].pExpr;
   876    876       pRight = pExpr->pList->a[0].pExpr;
   877    877       pStr1 = sqlite3Expr(TK_STRING, 0, 0, 0);
   878    878       if( pStr1 ){
   879    879         sqlite3TokenCopy(&pStr1->token, &pRight->token);
   880    880         pStr1->token.n = nPattern;
          881  +      pStr1->flags = EP_Dequoted;
   881    882       }
   882    883       pStr2 = sqlite3ExprDup(pStr1);
   883    884       if( pStr2 ){
   884    885         assert( pStr2->token.dyn );
   885    886         ++*(u8*)&pStr2->token.z[nPattern-1];
   886    887       }
   887    888       pNewExpr1 = sqlite3Expr(TK_GE, sqlite3ExprDup(pLeft), pStr1, 0);

Changes to test/like.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the LIKE and GLOB operators and
    13     13   # in particular the optimizations that occur to help those operators
    14     14   # run faster.
    15     15   #
    16         -# $Id: like.test,v 1.5 2006/06/14 08:48:26 danielk1977 Exp $
           16  +# $Id: like.test,v 1.6 2007/06/11 12:56:15 drh Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   # Create some sample data to work with.
    22     22   #
    23     23   do_test like-1.0 {
................................................................................
   378    378       SELECT x FROM t2 WHERE x GLOB 'abc*' ORDER BY 1
   379    379     }
   380    380   } {abc abcd nosort {} i2}
   381    381   do_test like-5.8 {
   382    382     set sqlite_like_count
   383    383   } 12
   384    384   
          385  +# ticket #2407
          386  +#
          387  +# Make sure the LIKE prefix optimization does not strip off leading
          388  +# characters of the like pattern that happen to be quote characters.
          389  +#
          390  +do_test like-6.1 {
          391  +  foreach x { 'abc 'bcd 'def 'ax } {
          392  +    db eval {INSERT INTO t2 VALUES($x)}
          393  +  }
          394  +  execsql {
          395  +    SELECT * FROM t2 WHERE x LIKE '''a%'
          396  +  }
          397  +} {'abc 'ax}
   385    398   
   386    399   finish_test