/ Check-in [2dbdfa51]
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:Merge in the 3.8.5 release changes and the FTS integrity-check fix.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | apple-osx
Files: files | file ages | folders
SHA1: 2dbdfa51703bade30b66730191e4fb286edc500b
User & Date: drh 2014-06-05 12:53:41
Context
2015-04-06
22:05
Detect and suppress an endless loops in clearDatabasePage() that might result from a corrupt database file. This is an edited cherry-pick from [30011ad2f55c] and [395bb3e677a]. Leaf check-in: e5f5ef00 user: drh tags: apple-osx-385
2014-06-30
19:57
Merge the latest trunk changes into the apple-osx branch. check-in: f426876f user: drh tags: apple-osx
2014-06-05
12:53
Merge in the 3.8.5 release changes and the FTS integrity-check fix. check-in: 2dbdfa51 user: drh tags: apple-osx
11:15
Fix a problem that was causing the FTS4 integrity-check command to fail if the table had one or more "notindexed" columns. check-in: 7123bb26 user: dan tags: trunk
2014-05-29
20:36
Merge trunk changes into the apple-osx branch. check-in: b9fad449 user: drh tags: apple-osx
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3_write.c.

  5170   5170   
  5171   5171       while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
  5172   5172         i64 iDocid = sqlite3_column_int64(pStmt, 0);
  5173   5173         int iLang = langidFromSelect(p, pStmt);
  5174   5174         int iCol;
  5175   5175   
  5176   5176         for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){
  5177         -        const char *zText = (const char *)sqlite3_column_text(pStmt, iCol+1);
  5178         -        int nText = sqlite3_column_bytes(pStmt, iCol+1);
  5179         -        sqlite3_tokenizer_cursor *pT = 0;
  5180         -
  5181         -        rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText, &pT);
  5182         -        while( rc==SQLITE_OK ){
  5183         -          char const *zToken;       /* Buffer containing token */
  5184         -          int nToken = 0;           /* Number of bytes in token */
  5185         -          int iDum1 = 0, iDum2 = 0; /* Dummy variables */
  5186         -          int iPos = 0;             /* Position of token in zText */
  5187         -
  5188         -          rc = pModule->xNext(pT, &zToken, &nToken, &iDum1, &iDum2, &iPos);
  5189         -          if( rc==SQLITE_OK ){
  5190         -            int i;
  5191         -            cksum2 = cksum2 ^ fts3ChecksumEntry(
  5192         -                zToken, nToken, iLang, 0, iDocid, iCol, iPos
  5193         -            );
  5194         -            for(i=1; i<p->nIndex; i++){
  5195         -              if( p->aIndex[i].nPrefix<=nToken ){
  5196         -                cksum2 = cksum2 ^ fts3ChecksumEntry(
  5197         -                  zToken, p->aIndex[i].nPrefix, iLang, i, iDocid, iCol, iPos
  5198         -                );
         5177  +        if( p->abNotindexed[iCol]==0 ){
         5178  +          const char *zText = (const char *)sqlite3_column_text(pStmt, iCol+1);
         5179  +          int nText = sqlite3_column_bytes(pStmt, iCol+1);
         5180  +          sqlite3_tokenizer_cursor *pT = 0;
         5181  +
         5182  +          rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText,&pT);
         5183  +          while( rc==SQLITE_OK ){
         5184  +            char const *zToken;       /* Buffer containing token */
         5185  +            int nToken = 0;           /* Number of bytes in token */
         5186  +            int iDum1 = 0, iDum2 = 0; /* Dummy variables */
         5187  +            int iPos = 0;             /* Position of token in zText */
         5188  +
         5189  +            rc = pModule->xNext(pT, &zToken, &nToken, &iDum1, &iDum2, &iPos);
         5190  +            if( rc==SQLITE_OK ){
         5191  +              int i;
         5192  +              cksum2 = cksum2 ^ fts3ChecksumEntry(
         5193  +                  zToken, nToken, iLang, 0, iDocid, iCol, iPos
         5194  +              );
         5195  +              for(i=1; i<p->nIndex; i++){
         5196  +                if( p->aIndex[i].nPrefix<=nToken ){
         5197  +                  cksum2 = cksum2 ^ fts3ChecksumEntry(
         5198  +                      zToken, p->aIndex[i].nPrefix, iLang, i, iDocid, iCol, iPos
         5199  +                  );
         5200  +                }
  5199   5201                 }
  5200   5202               }
  5201   5203             }
         5204  +          if( pT ) pModule->xClose(pT);
         5205  +          if( rc==SQLITE_DONE ) rc = SQLITE_OK;
  5202   5206           }
  5203         -        if( pT ) pModule->xClose(pT);
  5204         -        if( rc==SQLITE_DONE ) rc = SQLITE_OK;
  5205   5207         }
  5206   5208       }
  5207   5209   
  5208   5210       sqlite3_finalize(pStmt);
  5209   5211     }
  5210   5212   
  5211   5213     *pbOk = (cksum1==cksum2);

Changes to src/os_win.c.

  2920   2920                                            PENDING_BYTE, 0, 1, 0))==0 ){
  2921   2921         /* Try 3 times to get the pending lock.  This is needed to work
  2922   2922         ** around problems caused by indexing and/or anti-virus software on
  2923   2923         ** Windows systems.
  2924   2924         ** If you are using this code as a model for alternative VFSes, do not
  2925   2925         ** copy this retry logic.  It is a hack intended for Windows only.
  2926   2926         */
         2927  +      lastErrno = osGetLastError();
  2927   2928         OSTRACE(("LOCK-PENDING-FAIL file=%p, count=%d, result=%d\n",
  2928   2929                  pFile->h, cnt, res));
         2930  +      if( lastErrno==ERROR_INVALID_HANDLE ){
         2931  +        pFile->lastErrno = lastErrno;
         2932  +        rc = SQLITE_IOERR_LOCK;
         2933  +        OSTRACE(("LOCK-FAIL file=%p, count=%d, rc=%s\n",
         2934  +                 pFile->h, cnt, sqlite3ErrName(rc)));
         2935  +        return rc;
         2936  +      }
  2929   2937         if( cnt ) sqlite3_win32_sleep(1);
  2930   2938       }
  2931   2939       gotPendingLock = res;
  2932   2940       if( !res ){
  2933   2941         lastErrno = osGetLastError();
  2934   2942       }
  2935   2943     }
................................................................................
  3174   3182           winIoerrRetryDelay = a[1];
  3175   3183         }else{
  3176   3184           a[1] = winIoerrRetryDelay;
  3177   3185         }
  3178   3186         OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
  3179   3187         return SQLITE_OK;
  3180   3188       }
         3189  +#ifdef SQLITE_TEST
         3190  +    case SQLITE_FCNTL_WIN32_SET_HANDLE: {
         3191  +      LPHANDLE phFile = (LPHANDLE)pArg;
         3192  +      HANDLE hOldFile = pFile->h;
         3193  +      pFile->h = *phFile;
         3194  +      *phFile = hOldFile;
         3195  +      OSTRACE(("FCNTL oldFile=%p, newFile=%p, rc=SQLITE_OK\n",
         3196  +               hOldFile, pFile->h));
         3197  +      return SQLITE_OK;
         3198  +    }
         3199  +#endif
  3181   3200       case SQLITE_FCNTL_TEMPFILENAME: {
  3182   3201         char *zTFile = 0;
  3183   3202         int rc = winGetTempname(pFile->pVfs, &zTFile);
  3184   3203         if( rc==SQLITE_OK ){
  3185   3204           *(char**)pArg = zTFile;
  3186   3205         }
  3187   3206         OSTRACE(("FCNTL file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));

Changes to src/printf.c.

   752    752       }
   753    753       if( p->useMalloc==1 ){
   754    754         zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc);
   755    755       }else{
   756    756         zNew = sqlite3_realloc(zOld, p->nAlloc);
   757    757       }
   758    758       if( zNew ){
          759  +      assert( p->zText!=0 || p->nChar==0 );
   759    760         if( zOld==0 && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar);
   760    761         p->zText = zNew;
   761    762       }else{
   762    763         sqlite3StrAccumReset(p);
   763    764         setStrAccumError(p, STRACCUM_NOMEM);
   764    765         return 0;
   765    766       }

Changes to src/select.c.

  1222   1222     if( pSort->sortFlags & SORTFLAG_UseSorter ){
  1223   1223       sqlite3VdbeAddOp2(v, OP_SorterNext, iTab, addr); VdbeCoverage(v);
  1224   1224     }else{
  1225   1225       sqlite3VdbeAddOp2(v, OP_Next, iTab, addr); VdbeCoverage(v);
  1226   1226     }
  1227   1227     if( pSort->regReturn ) sqlite3VdbeAddOp1(v, OP_Return, pSort->regReturn);
  1228   1228     sqlite3VdbeResolveLabel(v, addrBreak);
  1229         -  if( eDest==SRT_Output || eDest==SRT_Coroutine ){
  1230         -    sqlite3VdbeAddOp2(v, OP_Close, pseudoTab, 0);
  1231         -  }
  1232   1229   }
  1233   1230   
  1234   1231   /*
  1235   1232   ** Return a pointer to a string containing the 'declaration type' of the
  1236   1233   ** expression pExpr. The string may be treated as static by the caller.
  1237   1234   **
  1238   1235   ** Also try to estimate the size of the returned value and return that

Changes to src/shell.c.

  2421   2421     }else
  2422   2422   
  2423   2423     if( c=='h' && strncmp(azArg[0], "help", n)==0 ){
  2424   2424       fprintf(p->out, "%s", zHelp);
  2425   2425     }else
  2426   2426   
  2427   2427     if( c=='i' && strncmp(azArg[0], "import", n)==0 ){
  2428         -    char *zTable = azArg[2];    /* Insert data into this table */
  2429         -    char *zFile = azArg[1];     /* Name of file to extra content from */
         2428  +    char *zTable;               /* Insert data into this table */
         2429  +    char *zFile;                /* Name of file to extra content from */
  2430   2430       sqlite3_stmt *pStmt = NULL; /* A statement */
  2431   2431       int nCol;                   /* Number of columns in the table */
  2432   2432       int nByte;                  /* Number of bytes in an SQL string */
  2433   2433       int i, j;                   /* Loop counters */
  2434   2434       int needCommit;             /* True to COMMIT or ROLLBACK at end */
  2435   2435       int nSep;                   /* Number of bytes in p->separator[] */
  2436   2436       char *zSql;                 /* An SQL statement */
................................................................................
  2437   2437       CSVReader sCsv;             /* Reader context */
  2438   2438       int (*xCloser)(FILE*);      /* Procedure to close th3 connection */
  2439   2439   
  2440   2440       if( nArg!=3 ){
  2441   2441         fprintf(stderr, "Usage: .import FILE TABLE\n");
  2442   2442         goto meta_command_exit;
  2443   2443       }
         2444  +    zFile = azArg[1];
         2445  +    zTable = azArg[2];
  2444   2446       seenInterrupt = 0;
  2445   2447       memset(&sCsv, 0, sizeof(sCsv));
  2446   2448       open_db(p, 0);
  2447   2449       nSep = strlen30(p->separator);
  2448   2450       if( nSep==0 ){
  2449   2451         fprintf(stderr, "Error: non-null separator required for import\n");
  2450   2452         return 1;
................................................................................
  2994   2996         goto meta_command_exit;
  2995   2997       }
  2996   2998       zCmd = sqlite3_mprintf(strchr(azArg[1],' ')==0?"%s":"\"%s\"", azArg[1]);
  2997   2999       for(i=2; i<nArg; i++){
  2998   3000         zCmd = sqlite3_mprintf(strchr(azArg[i],' ')==0?"%z %s":"%z \"%s\"",
  2999   3001                                zCmd, azArg[i]);
  3000   3002       }
  3001         -    system(zCmd);
         3003  +    (void)system(zCmd);
  3002   3004       sqlite3_free(zCmd);
  3003   3005     }else
  3004   3006   
  3005   3007     if( c=='s' && strncmp(azArg[0], "show", n)==0 ){
  3006   3008       int i;
  3007   3009       if( nArg!=1 ){
  3008   3010         fprintf(stderr, "Usage: .show\n");

Changes to src/sqlite.h.in.

   939    939   **
   940    940   ** <li>[[SQLITE_FCNTL_HAS_MOVED]]
   941    941   ** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a
   942    942   ** pointer to an integer and it writes a boolean into that integer depending
   943    943   ** on whether or not the file has been renamed, moved, or deleted since it
   944    944   ** was first opened.
   945    945   **
          946  +** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]]
          947  +** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging.  This
          948  +** opcode causes the xFileControl method to swap the file handle with the one
          949  +** pointed to by the pArg argument.  This capability is used during testing
          950  +** and only needs to be supported when SQLITE_TEST is defined.
          951  +**
   946    952   ** </ul>
   947    953   */
   948    954   #define SQLITE_FCNTL_LOCKSTATE               1
   949    955   #define SQLITE_FCNTL_GET_LOCKPROXYFILE       2
   950    956   #define SQLITE_FCNTL_SET_LOCKPROXYFILE       3
   951    957   #define SQLITE_FCNTL_LAST_ERRNO              4
   952    958   #define SQLITE_FCNTL_SIZE_HINT               5
................................................................................
   962    968   #define SQLITE_FCNTL_BUSYHANDLER            15
   963    969   #define SQLITE_FCNTL_TEMPFILENAME           16
   964    970   #define SQLITE_FCNTL_MMAP_SIZE              18
   965    971   #define SQLITE_FCNTL_TRACE                  19
   966    972   #define SQLITE_FCNTL_HAS_MOVED              20
   967    973   #define SQLITE_FCNTL_SYNC                   21
   968    974   #define SQLITE_FCNTL_COMMIT_PHASETWO        22
          975  +#define SQLITE_FCNTL_WIN32_SET_HANDLE       23
   969    976   /* deprecated names */
   970    977   #define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE
   971    978   #define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE
   972    979   #define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO
   973    980   
   974    981   /*
   975    982   ** CAPI3REF: Mutex Handle

Changes to src/test1.c.

   112    112       p = (struct SqliteDb*)cmdInfo.objClientData;
   113    113       *ppDb = p->db;
   114    114     }else{
   115    115       *ppDb = (sqlite3*)sqlite3TestTextToPtr(zA);
   116    116     }
   117    117     return TCL_OK;
   118    118   }
          119  +
          120  +#if SQLITE_OS_WIN
          121  +/*
          122  +** Decode a Win32 HANDLE object.
          123  +*/
          124  +int getWin32Handle(Tcl_Interp *interp, const char *zA, LPHANDLE phFile){
          125  +  *phFile = (HANDLE)sqlite3TestTextToPtr(zA);
          126  +  return TCL_OK;
          127  +}
          128  +#endif
   119    129   
   120    130   extern const char *sqlite3ErrName(int);
   121    131   #define t1ErrorName sqlite3ErrName
   122    132   
   123    133   /*
   124    134   ** Convert an sqlite3_stmt* into an sqlite3*.  This depends on the
   125    135   ** fact that the sqlite3* is the first field in the Vdbe structure.
................................................................................
  5399   5409   #else
  5400   5410     Tcl_SetObjResult(interp, Tcl_NewIntObj(0)); 
  5401   5411   #endif
  5402   5412     
  5403   5413     return TCL_OK;  
  5404   5414   }
  5405   5415   
         5416  +#if SQLITE_OS_WIN
  5406   5417   /*
  5407   5418   ** tclcmd:   file_control_win32_av_retry DB  NRETRY  DELAY
  5408   5419   **
  5409   5420   ** This TCL command runs the sqlite3_file_control interface with
  5410   5421   ** the SQLITE_FCNTL_WIN32_AV_RETRY opcode.
  5411   5422   */
  5412   5423   static int file_control_win32_av_retry(
................................................................................
  5432   5443     if( Tcl_GetIntFromObj(interp, objv[3], &a[1]) ) return TCL_ERROR;
  5433   5444     rc = sqlite3_file_control(db, NULL, SQLITE_FCNTL_WIN32_AV_RETRY, (void*)a);
  5434   5445     sqlite3_snprintf(sizeof(z), z, "%d %d %d", rc, a[0], a[1]);
  5435   5446     Tcl_AppendResult(interp, z, (char*)0);
  5436   5447     return TCL_OK;  
  5437   5448   }
  5438   5449   
         5450  +/*
         5451  +** tclcmd:   file_control_win32_set_handle DB HANDLE
         5452  +**
         5453  +** This TCL command runs the sqlite3_file_control interface with
         5454  +** the SQLITE_FCNTL_WIN32_SET_HANDLE opcode.
         5455  +*/
         5456  +static int file_control_win32_set_handle(
         5457  +  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
         5458  +  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
         5459  +  int objc,              /* Number of arguments */
         5460  +  Tcl_Obj *CONST objv[]  /* Command arguments */
         5461  +){
         5462  +  sqlite3 *db;
         5463  +  int rc;
         5464  +  HANDLE hFile = NULL;
         5465  +  char z[100];
         5466  +
         5467  +  if( objc!=3 ){
         5468  +    Tcl_AppendResult(interp, "wrong # args: should be \"",
         5469  +        Tcl_GetStringFromObj(objv[0], 0), " DB HANDLE", 0);
         5470  +    return TCL_ERROR;
         5471  +  }
         5472  +  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){
         5473  +    return TCL_ERROR;
         5474  +  }
         5475  +  if( getWin32Handle(interp, Tcl_GetString(objv[2]), &hFile) ){
         5476  +    return TCL_ERROR;
         5477  +  }
         5478  +  rc = sqlite3_file_control(db, NULL, SQLITE_FCNTL_WIN32_SET_HANDLE,
         5479  +                            (void*)&hFile);
         5480  +  sqlite3_snprintf(sizeof(z), z, "%d %p", rc, (void*)hFile);
         5481  +  Tcl_AppendResult(interp, z, (char*)0);
         5482  +  return TCL_OK;  
         5483  +}
         5484  +#endif
         5485  +
  5439   5486   /*
  5440   5487   ** tclcmd:   file_control_persist_wal DB PERSIST-FLAG
  5441   5488   **
  5442   5489   ** This TCL command runs the sqlite3_file_control interface with
  5443   5490   ** the SQLITE_FCNTL_PERSIST_WAL opcode.
  5444   5491   */
  5445   5492   static int file_control_persist_wal(
................................................................................
  6665   6712        { "file_control_lockproxy_test", file_control_lockproxy_test,  0   },
  6666   6713   #ifdef __APPLE__
  6667   6714        { "file_control_truncate_test", file_control_truncate_test,  0   },
  6668   6715        { "file_control_replace_test", file_control_replace_test,  0   },
  6669   6716   #endif 
  6670   6717        { "file_control_chunksize_test", file_control_chunksize_test,  0   },
  6671   6718        { "file_control_sizehint_test",  file_control_sizehint_test,   0   },
         6719  +#if SQLITE_OS_WIN
  6672   6720        { "file_control_win32_av_retry", file_control_win32_av_retry,  0   },
         6721  +     { "file_control_win32_set_handle", file_control_win32_set_handle, 0  },
         6722  +#endif
  6673   6723        { "file_control_persist_wal",    file_control_persist_wal,     0   },
  6674   6724        { "file_control_powersafe_overwrite",file_control_powersafe_overwrite,0},
  6675   6725        { "file_control_vfsname",        file_control_vfsname,         0   },
  6676   6726        { "file_control_tempfilename",   file_control_tempfilename,    0   },
  6677   6727        { "sqlite3_vfs_list",           vfs_list,     0   },
  6678   6728        { "sqlite3_create_function_v2", test_create_function_v2, 0 },
  6679   6729        { "path_is_local",              path_is_local,  0   },

Changes to src/where.c.

  4282   4282   
  4283   4283         assert( pNew->nOut==saved_nOut );
  4284   4284         if( pTerm->truthProb<=0 && iCol>=0 ){
  4285   4285           assert( (eOp & WO_IN) || nIn==0 );
  4286   4286           testcase( eOp & WO_IN );
  4287   4287           pNew->nOut += pTerm->truthProb;
  4288   4288           pNew->nOut -= nIn;
  4289         -        pNew->wsFlags |= WHERE_LIKELIHOOD;
  4290   4289         }else{
  4291   4290   #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
  4292   4291           tRowcnt nOut = 0;
  4293   4292           if( nInMul==0 
  4294   4293            && pProbe->nSample 
  4295   4294            && pNew->u.btree.nEq<=pProbe->nSampleCol
  4296   4295            && OptimizationEnabled(db, SQLITE_Stat3) 
  4297   4296            && ((eOp & WO_IN)==0 || !ExprHasProperty(pTerm->pExpr, EP_xIsSelect))
  4298         -         && (pNew->wsFlags & WHERE_LIKELIHOOD)==0
  4299   4297           ){
  4300   4298             Expr *pExpr = pTerm->pExpr;
  4301   4299             if( (eOp & (WO_EQ|WO_ISNULL))!=0 ){
  4302   4300               testcase( eOp & WO_EQ );
  4303   4301               testcase( eOp & WO_ISNULL );
  4304   4302               rc = whereEqualScanEst(pParse, pBuilder, pExpr->pRight, &nOut);
  4305   4303             }else{
................................................................................
  5293   5291   
  5294   5292     pParse = pWInfo->pParse;
  5295   5293     db = pParse->db;
  5296   5294     nLoop = pWInfo->nLevel;
  5297   5295     /* TUNING: For simple queries, only the best path is tracked.
  5298   5296     ** For 2-way joins, the 5 best paths are followed.
  5299   5297     ** For joins of 3 or more tables, track the 10 best paths */
  5300         -  mxChoice = (nLoop==1) ? 1 : (nLoop==2 ? 5 : 10);
         5298  +  mxChoice = (nLoop<=1) ? 1 : (nLoop==2 ? 5 : 10);
  5301   5299     assert( nLoop<=pWInfo->pTabList->nSrc );
  5302   5300     WHERETRACE(0x002, ("---- begin solver\n"));
  5303   5301   
  5304   5302     /* Allocate and initialize space for aTo and aFrom */
  5305   5303     ii = (sizeof(WherePath)+sizeof(WhereLoop*)*nLoop)*mxChoice*2;
  5306   5304     pSpace = sqlite3DbMallocRaw(db, ii);
  5307   5305     if( pSpace==0 ) return SQLITE_NOMEM;
................................................................................
  5323   5321   
  5324   5322     /* Precompute the cost of sorting the final result set, if the caller
  5325   5323     ** to sqlite3WhereBegin() was concerned about sorting */
  5326   5324     if( pWInfo->pOrderBy==0 || nRowEst==0 ){
  5327   5325       aFrom[0].isOrdered = 0;
  5328   5326       nOrderBy = 0;
  5329   5327     }else{
  5330         -    aFrom[0].isOrdered = -1;
         5328  +    aFrom[0].isOrdered = nLoop>0 ? -1 : 1;
  5331   5329       nOrderBy = pWInfo->pOrderBy->nExpr;
  5332   5330     }
  5333   5331   
  5334   5332     /* Compute successively longer WherePaths using the previous generation
  5335   5333     ** of WherePaths as the basis for the next.  Keep track of the mxChoice
  5336   5334     ** best paths at each generation */
  5337   5335     for(iLoop=0; iLoop<nLoop; iLoop++){

Changes to src/whereInt.h.

   454    454   #define WHERE_VIRTUALTABLE 0x00000400  /* WhereLoop.u.vtab is valid */
   455    455   #define WHERE_IN_ABLE      0x00000800  /* Able to support an IN operator */
   456    456   #define WHERE_ONEROW       0x00001000  /* Selects no more than one row */
   457    457   #define WHERE_MULTI_OR     0x00002000  /* OR using multiple indices */
   458    458   #define WHERE_AUTO_INDEX   0x00004000  /* Uses an ephemeral index */
   459    459   #define WHERE_SKIPSCAN     0x00008000  /* Uses the skip-scan algorithm */
   460    460   #define WHERE_UNQ_WANTED   0x00010000  /* WHERE_ONEROW would have been helpful*/
   461         -#define WHERE_LIKELIHOOD   0x00020000  /* A likelihood() is affecting nOut */

Changes to test/cost.test.

   240    240     set sql2 "SELECT * FROM t1 WHERE likelihood(k=?, $p2) AND $w"
   241    241   
   242    242     do_eqp_test 9.3.$tn.1 $sql1 {/INDEX i1/}
   243    243     do_eqp_test 9.3.$tn.2 $sql2 {/INDEX i2/}
   244    244   }
   245    245   
   246    246   
          247  +#-------------------------------------------------------------------------
          248  +#
          249  +
          250  +ifcapable stat4 {
          251  +  do_execsql_test 10.1 {
          252  +    CREATE TABLE t6(a, b, c);
          253  +    CREATE INDEX t6i1 ON t6(a, b);
          254  +    CREATE INDEX t6i2 ON t6(c);
          255  +  }
          256  +  
          257  +  do_test 10.2 {
          258  +    for {set i 0} {$i < 16} {incr i} {
          259  +      execsql { INSERT INTO t6 VALUES($i%4, 'xyz', $i%8) }
          260  +    }
          261  +    execsql ANALYZE
          262  +  } {}
          263  +
          264  +  do_eqp_test 10.3 {
          265  +    SELECT rowid FROM t6 WHERE a=0 AND c=0
          266  +  } {
          267  +    0 0 0 {SEARCH TABLE t6 USING INDEX t6i2 (c=?)}
          268  +  }
          269  +
          270  +  do_eqp_test 10.4 {
          271  +    SELECT rowid FROM t6 WHERE a=0 AND b='xyz' AND c=0
          272  +  } {
          273  +    0 0 0 {SEARCH TABLE t6 USING INDEX t6i2 (c=?)}
          274  +  }
          275  +
          276  +  do_eqp_test 10.5 {
          277  +    SELECT rowid FROM t6 WHERE likelihood(a=0, 0.1) AND c=0
          278  +  } {
          279  +    0 0 0 {SEARCH TABLE t6 USING INDEX t6i1 (a=?)}
          280  +  }
          281  +
          282  +  do_eqp_test 10.6 {
          283  +    SELECT rowid FROM t6 WHERE likelihood(a=0, 0.1) AND b='xyz' AND c=0
          284  +  } {
          285  +    0 0 0 {SEARCH TABLE t6 USING INDEX t6i1 (a=? AND b=?)}
          286  +  }
          287  +}
   247    288   
   248    289   finish_test
   249    290   
   250    291   
   251    292   

Changes to test/e_insert.test.

   170    170   } {
   171    171       1    "INSERT INTO a2 VALUES(1)"         {a2 3 1}
   172    172       2    "INSERT INTO a2 VALUES(1,2)"       {a2 3 2}
   173    173       3    "INSERT INTO a2 VALUES(1,2,3,4)"   {a2 3 4}
   174    174       4    "INSERT INTO a2 VALUES(1,2,3,4,5)" {a2 3 5}
   175    175   }
   176    176   
   177         -# EVIDENCE-OF: R-34231-22576 In this case the result of evaluating the
   178         -# left-most expression in each term of the VALUES list is inserted into
   179         -# the left-most column of the each new row, and forth for each
          177  +# EVIDENCE-OF: R-29730-42609 In this case the result of evaluating the
          178  +# left-most expression from each term of the VALUES list is inserted
          179  +# into the left-most column of each new row, and so forth for each
   180    180   # subsequent expression.
   181    181   #
   182    182   delete_all_data
   183    183   do_insert_tests e_insert-1.3 {
   184    184       1a   "INSERT INTO a2 VALUES(1, 2, 3)"    {}
   185    185       1b   "SELECT * FROM a2 WHERE oid=last_insert_rowid()" {1 2 3}
   186    186   

Changes to test/fts4check.test.

   147    147   } {
   148    148     do_execsql_test  3.2.1.$tn "BEGIN; $disruption"
   149    149     do_catchsql_test 3.2.2.$tn {
   150    150       INSERT INTO t3 (t3) VALUES('integrity-check')
   151    151     } {1 {database disk image is malformed}}
   152    152     do_execsql_test  3.2.3.$tn "ROLLBACK"
   153    153   }
          154  +
          155  +#--------------------------------------------------------------------------
          156  +# Test case 4.*
          157  +#
          158  +# Test that the integrity-check works if there are "notindexed" columns.
          159  +#
          160  +do_execsql_test 4.0 {
          161  +  CREATE VIRTUAL TABLE t4 USING fts4(a, b, c, notindexed=b);
          162  +  INSERT INTO t4 VALUES('text one', 'text two', 'text three');
          163  +  INSERT INTO t4(t4) VALUES('integrity-check');
          164  +}
          165  +
          166  +do_execsql_test 4.1 {
          167  +  PRAGMA writable_schema = 1;
          168  +  UPDATE sqlite_master 
          169  +    SET sql = 'CREATE VIRTUAL TABLE t4 USING fts4(a, b, c)' 
          170  +    WHERE name = 't4';
          171  +}
          172  +
          173  +do_test 4.2 {
          174  +  db close
          175  +  sqlite3 db test.db
          176  +  catchsql {
          177  +    INSERT INTO t4(t4) VALUES('integrity-check');
          178  +  }
          179  +} {1 {database disk image is malformed}}
          180  +reset_db
   154    181   
   155    182   finish_test
          183  +

Changes to test/orderby1.test.

   448    448       INSERT INTO t41 VALUES(1,1),(3,1);
   449    449       INSERT INTO t42 VALUES(1,13),(1,15),(3,14),(3,16);
   450    450       
   451    451       SELECT b, y FROM t41 CROSS JOIN t42 ON x=a ORDER BY b, y;
   452    452     }
   453    453   } {1 13 1 14 1 15 1 16}
   454    454   
          455  +# No sorting of queries that omit the FROM clause.
          456  +#
          457  +do_execsql_test 5.0 {
          458  +  EXPLAIN QUERY PLAN SELECT 5 ORDER BY 1
          459  +} {}
          460  +do_execsql_test 5.1 {
          461  +  EXPLAIN QUERY PLAN SELECT 5 UNION ALL SELECT 3 ORDER BY 1
          462  +} {~/B-TREE/}
          463  +do_execsql_test 5.2 {
          464  +  SELECT 5 UNION ALL SELECT 3 ORDER BY 1
          465  +} {3 5}
          466  +
          467  +# The following test (originally derived from a single test within fuzz.test)
          468  +# verifies that a PseudoTable cursor is not closed prematurely in a deeply
          469  +# nested query.  This test caused a segfault on 3.8.5 beta.
          470  +#
          471  +do_execsql_test 6.0 {
          472  +  CREATE TABLE abc(a, b, c);
          473  +  INSERT INTO abc VALUES(1, 2, 3);
          474  +  INSERT INTO abc VALUES(4, 5, 6);
          475  +  INSERT INTO abc VALUES(7, 8, 9);
          476  +  SELECT (
          477  +    SELECT 'hardware' FROM ( 
          478  +      SELECT 'software' ORDER BY 'firmware' ASC, 'sportswear' DESC 
          479  +    ) GROUP BY 1 HAVING length(b)
          480  +  )
          481  +  FROM abc;
          482  +} {hardware hardware hardware}
   455    483   
   456    484   
   457    485   finish_test

Changes to test/permutations.test.

   153    153   } -files [
   154    154     test_set $allquicktests -exclude *malloc* *ioerr* *fault* wal.test atof1.test
   155    155   ] -initialize {
   156    156     set ::G(valgrind) 1
   157    157   } -shutdown {
   158    158     unset -nocomplain ::G(valgrind)
   159    159   }
          160  +
          161  +test_suite "valgrind-nolookaside" -prefix "" -description {
          162  +  Run the "veryquick" test suite with a couple of multi-process tests (that
          163  +  fail under valgrind) omitted.
          164  +} -files [
          165  +  test_set $allquicktests -exclude *malloc* *ioerr* *fault* wal.test atof1.test
          166  +] -initialize {
          167  +  set ::G(valgrind) 1
          168  +  catch {db close}
          169  +  sqlite3_shutdown
          170  +  sqlite3_config_lookaside 0 0
          171  +  sqlite3_initialize
          172  +  autoinstall_test_functions
          173  +} -shutdown {
          174  +  catch {db close}
          175  +  sqlite3_shutdown
          176  +  sqlite3_config_lookaside 100 500
          177  +  sqlite3_initialize
          178  +  autoinstall_test_functions
          179  +  unset -nocomplain ::G(valgrind)
          180  +}
          181  +
   160    182   
   161    183   test_suite "quick" -prefix "" -description {
   162    184     Quick test suite. Runs in around 10 minutes on a workstation.
   163    185   } -files [
   164    186     test_set $allquicktests
   165    187   ]
   166    188   

Changes to test/win32lock.test.

    20     20   
    21     21   set testprefix win32lock
    22     22   
    23     23   db close
    24     24   sqlite3_shutdown
    25     25   test_sqlite3_log xLog
    26     26   proc xLog {error_code msg} {
    27         -  lappend ::log $msg 
           27  +  lappend ::log $msg
    28     28   }
    29     29   sqlite3 db test.db
    30     30   db eval {PRAGMA mmap_size=0}
    31     31   
    32     32   do_test win32lock-1.1 {
    33     33     db eval {
    34     34       PRAGMA cache_size=10;
................................................................................
   123    123       break
   124    124     }
   125    125     sqlite3_sleep 10
   126    126   }
   127    127   
   128    128   file_control_win32_av_retry db 10 25
   129    129   sqlite3_test_control_pending_byte $old_pending_byte
          130  +db close
          131  +forcedelete test.db
          132  +
          133  +sqlite3 db test.db
          134  +sqlite3 db2 test.db
          135  +
          136  +do_test win32lock-3.0 {
          137  +  db eval {
          138  +    CREATE TABLE t1(x);
          139  +    INSERT INTO t1 VALUES(1);
          140  +    INSERT INTO t1 VALUES(2);
          141  +    INSERT INTO t1 VALUES(3);
          142  +  }
          143  +} {}
          144  +
          145  +do_test win32lock-3.1 {
          146  +  db eval {
          147  +    BEGIN EXCLUSIVE;
          148  +    INSERT INTO t1 VALUES(4);
          149  +  }
          150  +} {}
          151  +
          152  +do_test win32lock-3.2 {
          153  +  catchsql {
          154  +    BEGIN EXCLUSIVE;
          155  +    INSERT INTO t1 VALUES(5);
          156  +    COMMIT;
          157  +  } db2
          158  +} {1 {database is locked}}
          159  +
          160  +do_test win32lock-3.3 {
          161  +  db eval {
          162  +    COMMIT;
          163  +  }
          164  +} {}
          165  +
          166  +do_test win32lock-3.4 {
          167  +  set handle [lindex [file_control_win32_set_handle db 0] end]
          168  +  list [catchsql {
          169  +    BEGIN EXCLUSIVE;
          170  +    INSERT INTO t1 VALUES(6);
          171  +    COMMIT;
          172  +  }] [file_control_win32_set_handle db $handle] [sqlite3_extended_errcode db]
          173  +} {{1 {disk I/O error}} {0 0} SQLITE_IOERR_LOCK}
          174  +
          175  +db2 close
   130    176   db close
   131    177   sqlite3_shutdown
   132         -test_sqlite3_log 
          178  +test_sqlite3_log
   133    179   sqlite3_initialize
   134    180   finish_test

Changes to tool/mkkeywordhash.c.

   366    366     nKeyword = j;
   367    367   
   368    368     /* Fill in the lengths of strings and hashes for all entries. */
   369    369     for(i=0; i<nKeyword; i++){
   370    370       Keyword *p = &aKeywordTable[i];
   371    371       p->len = (int)strlen(p->zName);
   372    372       assert( p->len<sizeof(p->zOrigName) );
   373         -    strcpy(p->zOrigName, p->zName);
          373  +    memcpy(p->zOrigName, p->zName, p->len+1);
   374    374       totalLen += p->len;
   375    375       p->hash = (UpperToLower[(int)p->zName[0]]*4) ^
   376    376                 (UpperToLower[(int)p->zName[p->len-1]]*3) ^ p->len;
   377    377       p->id = i+1;
   378    378     }
   379    379   
   380    380     /* Sort the table from shortest to longest keyword */