/ Check-in [959677b9]
Login

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

Overview
Comment:Merge recent changes from trunk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | rowvalue
Files: files | file ages | folders
SHA1:959677b97ba15f786936c762e2e68df1151d7ed0
User & Date: drh 2016-08-11 12:31:21
Context
2016-08-12
11:01
Fix a post-OOM memory leak. check-in: 14009b32 user: drh tags: rowvalue
2016-08-11
12:31
Merge recent changes from trunk. check-in: 959677b9 user: drh tags: rowvalue
12:01
Fix some problems with handling "no such collation sequence" errors. check-in: 8278be06 user: dan tags: rowvalue
09:55
Fix a 1 byte buffer overwrite in the "sqldiff --rbu" command. check-in: ab83d707 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to VERSION.

     1         -3.14.0
            1  +3.15.0

Changes to configure.

     1      1   #! /bin/sh
     2      2   # Guess values for system-dependent variables and create Makefiles.
     3         -# Generated by GNU Autoconf 2.69 for sqlite 3.14.0.
            3  +# Generated by GNU Autoconf 2.69 for sqlite 3.15.0.
     4      4   #
     5      5   #
     6      6   # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
     7      7   #
     8      8   #
     9      9   # This configure script is free software; the Free Software Foundation
    10     10   # gives unlimited permission to copy, distribute and modify it.
................................................................................
   722    722   subdirs=
   723    723   MFLAGS=
   724    724   MAKEFLAGS=
   725    725   
   726    726   # Identity of this package.
   727    727   PACKAGE_NAME='sqlite'
   728    728   PACKAGE_TARNAME='sqlite'
   729         -PACKAGE_VERSION='3.14.0'
   730         -PACKAGE_STRING='sqlite 3.14.0'
          729  +PACKAGE_VERSION='3.15.0'
          730  +PACKAGE_STRING='sqlite 3.15.0'
   731    731   PACKAGE_BUGREPORT=''
   732    732   PACKAGE_URL=''
   733    733   
   734    734   # Factoring default headers for most tests.
   735    735   ac_includes_default="\
   736    736   #include <stdio.h>
   737    737   #ifdef HAVE_SYS_TYPES_H
................................................................................
  1459   1459   #
  1460   1460   # Report the --help message.
  1461   1461   #
  1462   1462   if test "$ac_init_help" = "long"; then
  1463   1463     # Omit some internal or obsolete options to make the list less imposing.
  1464   1464     # This message is too long to be a string in the A/UX 3.1 sh.
  1465   1465     cat <<_ACEOF
  1466         -\`configure' configures sqlite 3.14.0 to adapt to many kinds of systems.
         1466  +\`configure' configures sqlite 3.15.0 to adapt to many kinds of systems.
  1467   1467   
  1468   1468   Usage: $0 [OPTION]... [VAR=VALUE]...
  1469   1469   
  1470   1470   To assign environment variables (e.g., CC, CFLAGS...), specify them as
  1471   1471   VAR=VALUE.  See below for descriptions of some of the useful variables.
  1472   1472   
  1473   1473   Defaults for the options are specified in brackets.
................................................................................
  1524   1524     --build=BUILD     configure for building on BUILD [guessed]
  1525   1525     --host=HOST       cross-compile to build programs to run on HOST [BUILD]
  1526   1526   _ACEOF
  1527   1527   fi
  1528   1528   
  1529   1529   if test -n "$ac_init_help"; then
  1530   1530     case $ac_init_help in
  1531         -     short | recursive ) echo "Configuration of sqlite 3.14.0:";;
         1531  +     short | recursive ) echo "Configuration of sqlite 3.15.0:";;
  1532   1532      esac
  1533   1533     cat <<\_ACEOF
  1534   1534   
  1535   1535   Optional Features:
  1536   1536     --disable-option-checking  ignore unrecognized --enable/--with options
  1537   1537     --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  1538   1538     --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
................................................................................
  1648   1648       cd "$ac_pwd" || { ac_status=$?; break; }
  1649   1649     done
  1650   1650   fi
  1651   1651   
  1652   1652   test -n "$ac_init_help" && exit $ac_status
  1653   1653   if $ac_init_version; then
  1654   1654     cat <<\_ACEOF
  1655         -sqlite configure 3.14.0
         1655  +sqlite configure 3.15.0
  1656   1656   generated by GNU Autoconf 2.69
  1657   1657   
  1658   1658   Copyright (C) 2012 Free Software Foundation, Inc.
  1659   1659   This configure script is free software; the Free Software Foundation
  1660   1660   gives unlimited permission to copy, distribute and modify it.
  1661   1661   _ACEOF
  1662   1662     exit
................................................................................
  2067   2067     eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
  2068   2068   
  2069   2069   } # ac_fn_c_check_header_mongrel
  2070   2070   cat >config.log <<_ACEOF
  2071   2071   This file contains any messages produced by compilers while
  2072   2072   running configure, to aid debugging if configure makes a mistake.
  2073   2073   
  2074         -It was created by sqlite $as_me 3.14.0, which was
         2074  +It was created by sqlite $as_me 3.15.0, which was
  2075   2075   generated by GNU Autoconf 2.69.  Invocation command line was
  2076   2076   
  2077   2077     $ $0 $@
  2078   2078   
  2079   2079   _ACEOF
  2080   2080   exec 5>>config.log
  2081   2081   {
................................................................................
 12147  12147   test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
 12148  12148   
 12149  12149   cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 12150  12150   # Save the log message, to keep $0 and so on meaningful, and to
 12151  12151   # report actual input values of CONFIG_FILES etc. instead of their
 12152  12152   # values after options handling.
 12153  12153   ac_log="
 12154         -This file was extended by sqlite $as_me 3.14.0, which was
        12154  +This file was extended by sqlite $as_me 3.15.0, which was
 12155  12155   generated by GNU Autoconf 2.69.  Invocation command line was
 12156  12156   
 12157  12157     CONFIG_FILES    = $CONFIG_FILES
 12158  12158     CONFIG_HEADERS  = $CONFIG_HEADERS
 12159  12159     CONFIG_LINKS    = $CONFIG_LINKS
 12160  12160     CONFIG_COMMANDS = $CONFIG_COMMANDS
 12161  12161     $ $0 $@
................................................................................
 12213  12213   
 12214  12214   Report bugs to the package provider."
 12215  12215   
 12216  12216   _ACEOF
 12217  12217   cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 12218  12218   ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 12219  12219   ac_cs_version="\\
 12220         -sqlite config.status 3.14.0
        12220  +sqlite config.status 3.15.0
 12221  12221   configured by $0, generated by GNU Autoconf 2.69,
 12222  12222     with options \\"\$ac_cs_config\\"
 12223  12223   
 12224  12224   Copyright (C) 2012 Free Software Foundation, Inc.
 12225  12225   This config.status script is free software; the Free Software Foundation
 12226  12226   gives unlimited permission to copy, distribute and modify it."
 12227  12227   

Changes to ext/fts5/fts5Int.h.

   733    733   
   734    734   void sqlite3Fts5ParsePhraseFree(Fts5ExprPhrase*);
   735    735   void sqlite3Fts5ParseNearsetFree(Fts5ExprNearset*);
   736    736   void sqlite3Fts5ParseNodeFree(Fts5ExprNode*);
   737    737   
   738    738   void sqlite3Fts5ParseSetDistance(Fts5Parse*, Fts5ExprNearset*, Fts5Token*);
   739    739   void sqlite3Fts5ParseSetColset(Fts5Parse*, Fts5ExprNearset*, Fts5Colset*);
          740  +Fts5Colset *sqlite3Fts5ParseColsetInvert(Fts5Parse*, Fts5Colset*);
   740    741   void sqlite3Fts5ParseFinished(Fts5Parse *pParse, Fts5ExprNode *p);
   741    742   void sqlite3Fts5ParseNear(Fts5Parse *pParse, Fts5Token*);
   742    743   
   743    744   /*
   744    745   ** End of interface to code in fts5_expr.c.
   745    746   **************************************************************************/
   746    747   

Changes to ext/fts5/fts5_expr.c.

   163    163       case ')':  tok = FTS5_RP;    break;
   164    164       case '{':  tok = FTS5_LCP;   break;
   165    165       case '}':  tok = FTS5_RCP;   break;
   166    166       case ':':  tok = FTS5_COLON; break;
   167    167       case ',':  tok = FTS5_COMMA; break;
   168    168       case '+':  tok = FTS5_PLUS;  break;
   169    169       case '*':  tok = FTS5_STAR;  break;
          170  +    case '-':  tok = FTS5_MINUS; break;
   170    171       case '\0': tok = FTS5_EOF;   break;
   171    172   
   172    173       case '"': {
   173    174         const char *z2;
   174    175         tok = FTS5_STRING;
   175    176   
   176    177         for(z2=&z[1]; 1; z2++){
................................................................................
  1788   1789       /* Check that the array is in order and contains no duplicate entries. */
  1789   1790       for(i=1; i<pNew->nCol; i++) assert( pNew->aiCol[i]>pNew->aiCol[i-1] );
  1790   1791   #endif
  1791   1792     }
  1792   1793   
  1793   1794     return pNew;
  1794   1795   }
         1796  +
         1797  +/*
         1798  +** Allocate and return an Fts5Colset object specifying the inverse of
         1799  +** the colset passed as the second argument. Free the colset passed
         1800  +** as the second argument before returning.
         1801  +*/
         1802  +Fts5Colset *sqlite3Fts5ParseColsetInvert(Fts5Parse *pParse, Fts5Colset *p){
         1803  +  Fts5Colset *pRet;
         1804  +  int nCol = pParse->pConfig->nCol;
         1805  +
         1806  +  pRet = (Fts5Colset*)sqlite3Fts5MallocZero(&pParse->rc, 
         1807  +      sizeof(Fts5Colset) + sizeof(int)*nCol
         1808  +  );
         1809  +  if( pRet ){
         1810  +    int i;
         1811  +    int iOld = 0;
         1812  +    for(i=0; i<nCol; i++){
         1813  +      if( iOld>=p->nCol || p->aiCol[iOld]!=i ){
         1814  +        pRet->aiCol[pRet->nCol++] = i;
         1815  +      }else{
         1816  +        iOld++;
         1817  +      }
         1818  +    }
         1819  +  }
         1820  +
         1821  +  sqlite3_free(p);
         1822  +  return pRet;
         1823  +}
  1795   1824   
  1796   1825   Fts5Colset *sqlite3Fts5ParseColset(
  1797   1826     Fts5Parse *pParse,              /* Store SQLITE_NOMEM here if required */
  1798   1827     Fts5Colset *pColset,            /* Existing colset object */
  1799   1828     Fts5Token *p
  1800   1829   ){
  1801   1830     Fts5Colset *pRet = 0;

Changes to ext/fts5/fts5_index.c.

  3190   3190       ** Fts5Iter.poslist buffer and then set the output pointer to point
  3191   3191       ** to this buffer.  */
  3192   3192       fts5BufferZero(&pIter->poslist);
  3193   3193       fts5SegiterPoslist(pIter->pIndex, pSeg, 0, &pIter->poslist);
  3194   3194       pIter->base.pData = pIter->poslist.p;
  3195   3195     }
  3196   3196   }
         3197  +
         3198  +/*
         3199  +** xSetOutputs callback used when the Fts5Colset object has nCol==0 (match
         3200  +** against no columns at all).
         3201  +*/
         3202  +static void fts5IterSetOutputs_ZeroColset(Fts5Iter *pIter, Fts5SegIter *pSeg){
         3203  +  UNUSED_PARAM(pSeg);
         3204  +  pIter->base.nData = 0;
         3205  +}
  3197   3206   
  3198   3207   /*
  3199   3208   ** xSetOutputs callback used by detail=col when there is a column filter
  3200   3209   ** and there are 100 or more columns. Also called as a fallback from
  3201   3210   ** fts5IterSetOutputs_Col100 if the column-list spans more than one page.
  3202   3211   */
  3203   3212   static void fts5IterSetOutputs_Col(Fts5Iter *pIter, Fts5SegIter *pSeg){
................................................................................
  3295   3304       if( pConfig->eDetail==FTS5_DETAIL_NONE ){
  3296   3305         pIter->xSetOutputs = fts5IterSetOutputs_None;
  3297   3306       }
  3298   3307   
  3299   3308       else if( pIter->pColset==0 ){
  3300   3309         pIter->xSetOutputs = fts5IterSetOutputs_Nocolset;
  3301   3310       }
         3311  +
         3312  +    else if( pIter->pColset->nCol==0 ){
         3313  +      pIter->xSetOutputs = fts5IterSetOutputs_ZeroColset;
         3314  +    }
  3302   3315   
  3303   3316       else if( pConfig->eDetail==FTS5_DETAIL_FULL ){
  3304   3317         pIter->xSetOutputs = fts5IterSetOutputs_Full;
  3305   3318       }
  3306   3319   
  3307   3320       else{
  3308   3321         assert( pConfig->eDetail==FTS5_DETAIL_COLUMNS );

Changes to ext/fts5/fts5parse.y.

   116    116   }
   117    117   
   118    118   %type colset {Fts5Colset*}
   119    119   %destructor colset { sqlite3_free($$); }
   120    120   %type colsetlist {Fts5Colset*}
   121    121   %destructor colsetlist { sqlite3_free($$); }
   122    122   
          123  +colset(A) ::= MINUS LCP colsetlist(X) RCP. { 
          124  +    A = sqlite3Fts5ParseColsetInvert(pParse, X);
          125  +}
   123    126   colset(A) ::= LCP colsetlist(X) RCP. { A = X; }
   124    127   colset(A) ::= STRING(X). {
   125    128     A = sqlite3Fts5ParseColset(pParse, 0, &X);
   126    129   }
          130  +colset(A) ::= MINUS STRING(X). {
          131  +  A = sqlite3Fts5ParseColset(pParse, 0, &X);
          132  +  A = sqlite3Fts5ParseColsetInvert(pParse, A);
          133  +}
   127    134   
   128    135   colsetlist(A) ::= colsetlist(Y) STRING(X). { 
   129    136     A = sqlite3Fts5ParseColset(pParse, Y, &X); }
   130    137   colsetlist(A) ::= STRING(X). { 
   131    138     A = sqlite3Fts5ParseColset(pParse, 0, &X); 
   132    139   }
   133         -
   134    140   
   135    141   %type nearset     {Fts5ExprNearset*}
   136    142   %type nearphrases {Fts5ExprNearset*}
   137    143   %destructor nearset { sqlite3Fts5ParseNearsetFree($$); }
   138    144   %destructor nearphrases { sqlite3Fts5ParseNearsetFree($$); }
   139    145   
   140    146   nearset(A) ::= phrase(X). { A = sqlite3Fts5ParseNearset(pParse, 0, X); }

Added ext/fts5/test/fts5colset.test.

            1  +# 2016 August 10
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#*************************************************************************
           11  +# This file implements regression tests for SQLite library.  The
           12  +# focus of this script is testing the FTS5 module.
           13  +#
           14  +
           15  +source [file join [file dirname [info script]] fts5_common.tcl]
           16  +set testprefix fts5colset
           17  +
           18  +# If SQLITE_ENABLE_FTS5 is not defined, omit this file.
           19  +ifcapable !fts5 {
           20  +  finish_test
           21  +  return
           22  +}
           23  +
           24  +foreach_detail_mode $::testprefix {
           25  +  if {[detail_is_none]} continue
           26  +
           27  +  do_execsql_test 1.0 {
           28  +    CREATE VIRTUAL TABLE t1 USING fts5(a, b, c, d, detail=%DETAIL%);
           29  +    INSERT INTO t1 VALUES('a', 'b', 'c', 'd');  -- 1
           30  +    INSERT INTO t1 VALUES('d', 'a', 'b', 'c');  -- 2
           31  +    INSERT INTO t1 VALUES('c', 'd', 'a', 'b');  -- 3
           32  +    INSERT INTO t1 VALUES('b', 'c', 'd', 'a');  -- 4
           33  +  }
           34  +
           35  +  foreach {tn q res} {
           36  +    1 "a"          {1 2 3 4}
           37  +    2 "{a}   : a"  {1}
           38  +    3 "-{a}   : a" {2 3 4}
           39  +    4 "- {a c} : a" {2 4}
           40  +    5 " - {d d c} : a" {1 2}
           41  +    6 "- {d c b a} : a" {}
           42  +    7 "-{\"a\"} : b" {1 2 3}
           43  +    8 "- c : a" {1 2 4}
           44  +    9 "-c : a"  {1 2 4}
           45  +    10 "-\"c\" : a"  {1 2 4}
           46  +  } {
           47  +  breakpoint
           48  +    do_execsql_test 1.$tn {
           49  +      SELECT rowid FROM t1($q)
           50  +    } $res
           51  +  }
           52  +
           53  +
           54  +}
           55  +
           56  +
           57  +finish_test
           58  +
           59  +

Changes to src/pcache1.c.

   628    628   **
   629    629   ** The PCache mutex must be held when this function is called.
   630    630   */
   631    631   static void pcache1TruncateUnsafe(
   632    632     PCache1 *pCache,             /* The cache to truncate */
   633    633     unsigned int iLimit          /* Drop pages with this pgno or larger */
   634    634   ){
   635         -  TESTONLY( unsigned int nPage = 0; )  /* To assert pCache->nPage is correct */
   636         -  unsigned int h;
          635  +  TESTONLY( int nPage = 0; )  /* To assert pCache->nPage is correct */
          636  +  unsigned int h, iStop;
   637    637     assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
   638         -  for(h=0; h<pCache->nHash; h++){
   639         -    PgHdr1 **pp = &pCache->apHash[h]; 
          638  +  assert( pCache->iMaxKey >= iLimit );
          639  +  assert( pCache->nHash > 0 );
          640  +  if( pCache->iMaxKey - iLimit < pCache->nHash ){
          641  +    /* If we are just shaving the last few pages off the end of the
          642  +    ** cache, then there is no point in scanning the entire hash table.
          643  +    ** Only scan those hash slots that might contain pages that need to
          644  +    ** be removed. */
          645  +    h = iLimit % pCache->nHash;
          646  +    iStop = pCache->iMaxKey % pCache->nHash;
          647  +    TESTONLY( nPage = -10; )  /* Disable the pCache->nPage validity check */
          648  +  }else{
          649  +    /* This is the general case where many pages are being removed.
          650  +    ** It is necessary to scan the entire hash table */
          651  +    h = pCache->nHash/2;
          652  +    iStop = h - 1;
          653  +  }
          654  +  for(;;){
          655  +    PgHdr1 **pp;
   640    656       PgHdr1 *pPage;
          657  +    assert( h<pCache->nHash );
          658  +    pp = &pCache->apHash[h]; 
   641    659       while( (pPage = *pp)!=0 ){
   642    660         if( pPage->iKey>=iLimit ){
   643    661           pCache->nPage--;
   644    662           *pp = pPage->pNext;
   645    663           if( !pPage->isPinned ) pcache1PinPage(pPage);
   646    664           pcache1FreePage(pPage);
   647    665         }else{
   648    666           pp = &pPage->pNext;
   649         -        TESTONLY( nPage++; )
          667  +        TESTONLY( if( nPage>=0 ) nPage++; )
   650    668         }
   651    669       }
          670  +    if( h==iStop ) break;
          671  +    h = (h+1) % pCache->nHash;
   652    672     }
   653         -  assert( pCache->nPage==nPage );
          673  +  assert( nPage<0 || pCache->nPage==(unsigned)nPage );
   654    674   }
   655    675   
   656    676   /******************************************************************************/
   657    677   /******** sqlite3_pcache Methods **********************************************/
   658    678   
   659    679   /*
   660    680   ** Implementation of the sqlite3_pcache.xInit method.
................................................................................
  1123   1143   ** Destroy a cache allocated using pcache1Create().
  1124   1144   */
  1125   1145   static void pcache1Destroy(sqlite3_pcache *p){
  1126   1146     PCache1 *pCache = (PCache1 *)p;
  1127   1147     PGroup *pGroup = pCache->pGroup;
  1128   1148     assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) );
  1129   1149     pcache1EnterMutex(pGroup);
  1130         -  pcache1TruncateUnsafe(pCache, 0);
         1150  +  if( pCache->nPage ) pcache1TruncateUnsafe(pCache, 0);
  1131   1151     assert( pGroup->nMaxPage >= pCache->nMax );
  1132   1152     pGroup->nMaxPage -= pCache->nMax;
  1133   1153     assert( pGroup->nMinPage >= pCache->nMin );
  1134   1154     pGroup->nMinPage -= pCache->nMin;
  1135   1155     pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
  1136   1156     pcache1EnforceMaxPage(pCache);
  1137   1157     pcache1LeaveMutex(pGroup);

Changes to src/tokenize.c.

   498    498       return SQLITE_NOMEM_BKPT;
   499    499     }
   500    500     assert( pParse->pNewTable==0 );
   501    501     assert( pParse->pNewTrigger==0 );
   502    502     assert( pParse->nVar==0 );
   503    503     assert( pParse->nzVar==0 );
   504    504     assert( pParse->azVar==0 );
   505         -  while( zSql[i]!=0 ){
          505  +  while( 1 ){
   506    506       assert( i>=0 );
   507         -    pParse->sLastToken.z = &zSql[i];
   508         -    pParse->sLastToken.n = sqlite3GetToken((unsigned char*)&zSql[i],&tokenType);
   509         -    i += pParse->sLastToken.n;
   510         -    if( i>mxSqlLen ){
   511         -      pParse->rc = SQLITE_TOOBIG;
   512         -      break;
          507  +    if( zSql[i]!=0 ){
          508  +      pParse->sLastToken.z = &zSql[i];
          509  +      pParse->sLastToken.n = sqlite3GetToken((u8*)&zSql[i],&tokenType);
          510  +      i += pParse->sLastToken.n;
          511  +      if( i>mxSqlLen ){
          512  +        pParse->rc = SQLITE_TOOBIG;
          513  +        break;
          514  +      }
          515  +    }else{
          516  +      /* Upon reaching the end of input, call the parser two more times
          517  +      ** with tokens TK_SEMI and 0, in that order. */
          518  +      if( lastTokenParsed==TK_SEMI ){
          519  +        tokenType = 0;
          520  +      }else if( lastTokenParsed==0 ){
          521  +        break;
          522  +      }else{
          523  +        tokenType = TK_SEMI;
          524  +      }
   513    525       }
   514    526       if( tokenType>=TK_SPACE ){
   515    527         assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL );
   516    528         if( db->u1.isInterrupted ){
   517    529           pParse->rc = SQLITE_INTERRUPT;
   518    530           break;
   519    531         }
................................................................................
   526    538         sqlite3Parser(pEngine, tokenType, pParse->sLastToken, pParse);
   527    539         lastTokenParsed = tokenType;
   528    540         if( pParse->rc!=SQLITE_OK || db->mallocFailed ) break;
   529    541       }
   530    542     }
   531    543     assert( nErr==0 );
   532    544     pParse->zTail = &zSql[i];
   533         -  if( pParse->rc==SQLITE_OK && db->mallocFailed==0 ){
   534         -    assert( zSql[i]==0 );
   535         -    if( lastTokenParsed!=TK_SEMI ){
   536         -      sqlite3Parser(pEngine, TK_SEMI, pParse->sLastToken, pParse);
   537         -    }
   538         -    if( pParse->rc==SQLITE_OK && db->mallocFailed==0 ){
   539         -      sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse);
   540         -    }
   541         -  }
   542    545   #ifdef YYTRACKMAXSTACKDEPTH
   543    546     sqlite3_mutex_enter(sqlite3MallocMutex());
   544    547     sqlite3StatusHighwater(SQLITE_STATUS_PARSER_STACK,
   545    548         sqlite3ParserStackPeak(pEngine)
   546    549     );
   547    550     sqlite3_mutex_leave(sqlite3MallocMutex());
   548    551   #endif /* YYDEBUG */

Changes to src/walker.c.

    37     37   ** and WRC_Continue to continue.
    38     38   */
    39     39   static SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){
    40     40     int rc;
    41     41     testcase( ExprHasProperty(pExpr, EP_TokenOnly) );
    42     42     testcase( ExprHasProperty(pExpr, EP_Reduced) );
    43     43     rc = pWalker->xExprCallback(pWalker, pExpr);
    44         -  if( rc==WRC_Continue
    45         -              && !ExprHasProperty(pExpr,EP_TokenOnly) ){
    46         -    if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
    47         -    if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
    48         -    if( ExprHasProperty(pExpr, EP_xIsSelect) ){
    49         -      if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
    50         -    }else{
    51         -      if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
    52         -    }
           44  +  if( rc || ExprHasProperty(pExpr,EP_TokenOnly) ) return rc & WRC_Abort;
           45  +  if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
           46  +  if( pExpr->pRight && walkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
           47  +  if( ExprHasProperty(pExpr, EP_xIsSelect) ){
           48  +    if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
           49  +  }else{
           50  +    if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
    53     51     }
    54         -  return rc & WRC_Abort;
           52  +  return WRC_Continue;
    55     53   }
    56     54   int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){
    57     55     return pExpr ? walkExpr(pWalker,pExpr) : WRC_Continue;
    58     56   }
    59     57   
    60     58   /*
    61     59   ** Call sqlite3WalkExpr() for every expression in list p or until

Changes to src/whereexpr.c.

   286    286   **
   287    287   ** If it is then return TRUE.  If not, return FALSE.
   288    288   */
   289    289   static int isMatchOfColumn(
   290    290     Expr *pExpr,                    /* Test this expression */
   291    291     unsigned char *peOp2            /* OUT: 0 for MATCH, or else an op2 value */
   292    292   ){
   293         -  struct Op2 {
          293  +  static const struct Op2 {
   294    294       const char *zOp;
   295    295       unsigned char eOp2;
   296    296     } aOp[] = {
   297    297       { "match",  SQLITE_INDEX_CONSTRAINT_MATCH },
   298    298       { "glob",   SQLITE_INDEX_CONSTRAINT_GLOB },
   299    299       { "like",   SQLITE_INDEX_CONSTRAINT_LIKE },
   300    300       { "regexp", SQLITE_INDEX_CONSTRAINT_REGEXP }
................................................................................
  1358   1358   
  1359   1359   /*
  1360   1360   ** These routines walk (recursively) an expression tree and generate
  1361   1361   ** a bitmask indicating which tables are used in that expression
  1362   1362   ** tree.
  1363   1363   */
  1364   1364   Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){
  1365         -  Bitmask mask = 0;
         1365  +  Bitmask mask;
  1366   1366     if( p==0 ) return 0;
  1367   1367     if( p->op==TK_COLUMN ){
  1368   1368       mask = sqlite3WhereGetMask(pMaskSet, p->iTable);
  1369   1369       return mask;
  1370   1370     }
  1371         -  mask = sqlite3WhereExprUsage(pMaskSet, p->pRight);
         1371  +  assert( !ExprHasProperty(p, EP_TokenOnly) );
         1372  +  mask = p->pRight ? sqlite3WhereExprUsage(pMaskSet, p->pRight) : 0;
  1372   1373     if( p->pLeft ) mask |= sqlite3WhereExprUsage(pMaskSet, p->pLeft);
  1373   1374     if( ExprHasProperty(p, EP_xIsSelect) ){
  1374   1375       mask |= exprSelectUsage(pMaskSet, p->x.pSelect);
  1375   1376     }else if( p->x.pList ){
  1376   1377       mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList);
  1377   1378     }
  1378   1379     return mask;

Changes to tool/lemon.c.

  4227   4227       }else{
  4228   4228         j++;
  4229   4229       }
  4230   4230     }
  4231   4231     fprintf(out, "};\n"); lineno++;
  4232   4232   
  4233   4233     /* Output the yy_shift_ofst[] table */
  4234         -  fprintf(out, "#define YY_SHIFT_USE_DFLT (%d)\n", mnTknOfst-1); lineno++;
  4235   4234     n = lemp->nxstate;
  4236   4235     while( n>0 && lemp->sorted[n-1]->iTknOfst==NO_OFFSET ) n--;
  4237         -  fprintf(out, "#define YY_SHIFT_COUNT (%d)\n", n-1); lineno++;
  4238         -  fprintf(out, "#define YY_SHIFT_MIN   (%d)\n", mnTknOfst); lineno++;
  4239         -  fprintf(out, "#define YY_SHIFT_MAX   (%d)\n", mxTknOfst); lineno++;
         4236  +  fprintf(out, "#define YY_SHIFT_USE_DFLT (%d)\n", lemp->nactiontab); lineno++;
         4237  +  fprintf(out, "#define YY_SHIFT_COUNT    (%d)\n", n-1); lineno++;
         4238  +  fprintf(out, "#define YY_SHIFT_MIN      (%d)\n", mnTknOfst); lineno++;
         4239  +  fprintf(out, "#define YY_SHIFT_MAX      (%d)\n", mxTknOfst); lineno++;
  4240   4240     fprintf(out, "static const %s yy_shift_ofst[] = {\n", 
  4241         -          minimum_size_type(mnTknOfst-1, mxTknOfst, &sz)); lineno++;
         4241  +       minimum_size_type(mnTknOfst, lemp->nterminal+lemp->nactiontab, &sz));
         4242  +       lineno++;
  4242   4243     lemp->tablesize += n*sz;
  4243   4244     for(i=j=0; i<n; i++){
  4244   4245       int ofst;
  4245   4246       stp = lemp->sorted[i];
  4246   4247       ofst = stp->iTknOfst;
  4247         -    if( ofst==NO_OFFSET ) ofst = mnTknOfst - 1;
         4248  +    if( ofst==NO_OFFSET ) ofst = lemp->nactiontab;
  4248   4249       if( j==0 ) fprintf(out," /* %5d */ ", i);
  4249   4250       fprintf(out, " %4d,", ofst);
  4250   4251       if( j==9 || i==n-1 ){
  4251   4252         fprintf(out, "\n"); lineno++;
  4252   4253         j = 0;
  4253   4254       }else{
  4254   4255         j++;

Changes to tool/lempar.c.

   112    112   **                                      token onto the stack and goto state N.
   113    113   **
   114    114   **   N between YY_MIN_SHIFTREDUCE       Shift to an arbitrary state then
   115    115   **     and YY_MAX_SHIFTREDUCE           reduce by rule N-YY_MIN_SHIFTREDUCE.
   116    116   **
   117    117   **   N between YY_MIN_REDUCE            Reduce by rule N-YY_MIN_REDUCE
   118    118   **     and YY_MAX_REDUCE
   119         -
          119  +**
   120    120   **   N == YY_ERROR_ACTION               A syntax error has occurred.
   121    121   **
   122    122   **   N == YY_ACCEPT_ACTION              The parser accepts its input.
   123    123   **
   124    124   **   N == YY_NO_ACTION                  No such action.  Denotes unused
   125    125   **                                      slots in the yy_action[] table.
   126    126   **
   127    127   ** The action table is constructed as a single large table named yy_action[].
   128         -** Given state S and lookahead X, the action is computed as
          128  +** Given state S and lookahead X, the action is computed as either:
   129    129   **
   130         -**      yy_action[ yy_shift_ofst[S] + X ]
          130  +**    (A)   N = yy_action[ yy_shift_ofst[S] + X ]
          131  +**    (B)   N = yy_default[S]
   131    132   **
   132         -** If the index value yy_shift_ofst[S]+X is out of range or if the value
   133         -** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
   134         -** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
   135         -** and that yy_default[S] should be used instead.  
          133  +** The (A) formula is preferred.  The B formula is used instead if:
          134  +**    (1)  The yy_shift_ofst[S]+X value is out of range, or
          135  +**    (2)  yy_lookahead[yy_shift_ofst[S]+X] is not equal to X, or
          136  +**    (3)  yy_shift_ofst[S] equal YY_SHIFT_USE_DFLT.
          137  +** (Implementation note: YY_SHIFT_USE_DFLT is chosen so that
          138  +** YY_SHIFT_USE_DFLT+X will be out of range for all possible lookaheads X.
          139  +** Hence only tests (1) and (2) need to be evaluated.)
   136    140   **
   137         -** The formula above is for computing the action when the lookahead is
          141  +** The formulas above are for computing the action when the lookahead is
   138    142   ** a terminal symbol.  If the lookahead is a non-terminal (as occurs after
   139    143   ** a reduce action) then the yy_reduce_ofst[] array is used in place of
   140    144   ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
   141    145   ** YY_SHIFT_USE_DFLT.
   142    146   **
   143    147   ** The following are the tables generated in this section:
   144    148   **
................................................................................
   446    450     int i;
   447    451     int stateno = pParser->yytos->stateno;
   448    452    
   449    453     if( stateno>=YY_MIN_REDUCE ) return stateno;
   450    454     assert( stateno <= YY_SHIFT_COUNT );
   451    455     do{
   452    456       i = yy_shift_ofst[stateno];
   453         -    if( i==YY_SHIFT_USE_DFLT ) return yy_default[stateno];
   454    457       assert( iLookAhead!=YYNOCODE );
   455    458       i += iLookAhead;
   456    459       if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
   457         -      if( iLookAhead>0 ){
   458    460   #ifdef YYFALLBACK
   459         -        YYCODETYPE iFallback;            /* Fallback token */
   460         -        if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
   461         -               && (iFallback = yyFallback[iLookAhead])!=0 ){
          461  +      YYCODETYPE iFallback;            /* Fallback token */
          462  +      if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
          463  +             && (iFallback = yyFallback[iLookAhead])!=0 ){
   462    464   #ifndef NDEBUG
   463         -          if( yyTraceFILE ){
   464         -            fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
   465         -               yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
   466         -          }
   467         -#endif
   468         -          assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */
   469         -          iLookAhead = iFallback;
   470         -          continue;
          465  +        if( yyTraceFILE ){
          466  +          fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
          467  +             yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
   471    468           }
          469  +#endif
          470  +        assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */
          471  +        iLookAhead = iFallback;
          472  +        continue;
          473  +      }
   472    474   #endif
   473    475   #ifdef YYWILDCARD
   474         -        {
   475         -          int j = i - iLookAhead + YYWILDCARD;
   476         -          if( 
          476  +      {
          477  +        int j = i - iLookAhead + YYWILDCARD;
          478  +        if( 
   477    479   #if YY_SHIFT_MIN+YYWILDCARD<0
   478         -            j>=0 &&
          480  +          j>=0 &&
   479    481   #endif
   480    482   #if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
   481         -            j<YY_ACTTAB_COUNT &&
          483  +          j<YY_ACTTAB_COUNT &&
   482    484   #endif
   483         -            yy_lookahead[j]==YYWILDCARD
   484         -          ){
          485  +          yy_lookahead[j]==YYWILDCARD && iLookAhead>0
          486  +        ){
   485    487   #ifndef NDEBUG
   486         -            if( yyTraceFILE ){
   487         -              fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
   488         -                 yyTracePrompt, yyTokenName[iLookAhead],
   489         -                 yyTokenName[YYWILDCARD]);
   490         -            }
          488  +          if( yyTraceFILE ){
          489  +            fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
          490  +               yyTracePrompt, yyTokenName[iLookAhead],
          491  +               yyTokenName[YYWILDCARD]);
          492  +          }
   491    493   #endif /* NDEBUG */
   492         -            return yy_action[j];
   493         -          }
          494  +          return yy_action[j];
   494    495           }
   495         -#endif /* YYWILDCARD */
   496    496         }
          497  +#endif /* YYWILDCARD */
   497    498         return yy_default[stateno];
   498    499       }else{
   499    500         return yy_action[i];
   500    501       }
   501    502     }while(1);
   502    503   }
   503    504   

Changes to tool/sqldiff.c.

  1298   1298           if( i>0 ) fprintf(out, ", ");
  1299   1299           printQuoted(out, sqlite3_column_value(pStmt, i));
  1300   1300         }
  1301   1301       }else{
  1302   1302         char *zOtaControl;
  1303   1303         int nOtaControl = sqlite3_column_bytes(pStmt, nCol);
  1304   1304   
  1305         -      zOtaControl = (char*)sqlite3_malloc(nOtaControl);
         1305  +      zOtaControl = (char*)sqlite3_malloc(nOtaControl+1);
  1306   1306         memcpy(zOtaControl, sqlite3_column_text(pStmt, nCol), nOtaControl+1);
  1307   1307   
  1308   1308         for(i=0; i<nCol; i++){
  1309   1309           int bDone = 0;
  1310   1310           if( i>=nPK 
  1311   1311               && sqlite3_column_type(pStmt, i)==SQLITE_BLOB
  1312   1312               && sqlite3_column_type(pStmt, nCol+1+i)==SQLITE_BLOB