/ Check-in [734fc68f]
Login

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

Overview
Comment:Merge latest trunk changes, including fixes to test script rbudiff.test, into this branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | rbu-percent-progress
Files: files | file ages | folders
SHA1:734fc68fb12f06e97026d4637138b82b37809f5b
User & Date: dan 2016-03-19 15:34:42
Context
2016-03-19
16:21
Update the sqldiff tool so that it generates an rbu_count table. check-in: 1f7afb6e user: dan tags: rbu-percent-progress
15:34
Merge latest trunk changes, including fixes to test script rbudiff.test, into this branch. check-in: 734fc68f user: dan tags: rbu-percent-progress
15:13
Fix another problem in test script rbudiff.test. check-in: 41c29c12 user: dan tags: trunk
2016-03-18
20:12
Add further tests for sqlite3rbu_bp_progress(). Fix a problem in handling WITHOUT ROWID tables in the same. check-in: 65e02368 user: dan tags: rbu-percent-progress
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts5/fts5_storage.c.

   141    141         if( rc!=SQLITE_OK && pzErrMsg ){
   142    142           *pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db));
   143    143         }
   144    144       }
   145    145     }
   146    146   
   147    147     *ppStmt = p->aStmt[eStmt];
          148  +  sqlite3_reset(*ppStmt);
   148    149     return rc;
   149    150   }
   150    151   
   151    152   
   152    153   static int fts5ExecPrintf(
   153    154     sqlite3 *db,
   154    155     char **pzErr,
................................................................................
  1117   1118       rc = sqlite3Fts5IndexSetCookie(p->pIndex, iNew);
  1118   1119       if( rc==SQLITE_OK ){
  1119   1120         p->pConfig->iCookie = iNew;
  1120   1121       }
  1121   1122     }
  1122   1123     return rc;
  1123   1124   }
  1124         -
  1125         -

Changes to ext/rbu/rbudiff.test.

    14     14   #
    15     15   if {![info exists testdir]} {
    16     16     set testdir [file join [file dirname [info script]] .. .. test]
    17     17   }
    18     18   source $testdir/tester.tcl
    19     19   set testprefix rbudiff
    20     20   
    21         -if {$tcl_platform(platform)=="windows"} {
    22         -  set PROG "sqldiff.exe"
    23         -} else {
    24         -  set PROG "./sqldiff"
    25         -}
    26         -if {![file exe $PROG]} {
    27         -  puts "rbudiff.test cannot run because $PROG is not available"
    28         -  finish_test
    29         -  return
    30         -}
           21  +set PROG [test_find_sqldiff]
    31     22   db close
    32     23   
    33     24   proc get_rbudiff_sql {db1 db2} {
    34     25     exec $::PROG --rbu $db1 $db2
    35     26   }
    36     27   
    37     28   proc step_rbu {target rbu} {

Changes to src/expr.c.

  1279   1279   */
  1280   1280   u32 sqlite3ExprListFlags(const ExprList *pList){
  1281   1281     int i;
  1282   1282     u32 m = 0;
  1283   1283     if( pList ){
  1284   1284       for(i=0; i<pList->nExpr; i++){
  1285   1285          Expr *pExpr = pList->a[i].pExpr;
  1286         -       if( ALWAYS(pExpr) ) m |= pExpr->flags;
         1286  +       assert( pExpr!=0 );
         1287  +       m |= pExpr->flags;
  1287   1288       }
  1288   1289     }
  1289   1290     return m;
  1290   1291   }
  1291   1292   
  1292   1293   /*
  1293   1294   ** These routines are Walker callbacks used to check expressions to
................................................................................
  3544   3545         break;
  3545   3546       }
  3546   3547       case TK_NOT: {
  3547   3548         testcase( jumpIfNull==0 );
  3548   3549         sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);
  3549   3550         break;
  3550   3551       }
         3552  +    case TK_IS:
         3553  +    case TK_ISNOT:
         3554  +      testcase( op==TK_IS );
         3555  +      testcase( op==TK_ISNOT );
         3556  +      op = (op==TK_IS) ? TK_EQ : TK_NE;
         3557  +      jumpIfNull = SQLITE_NULLEQ;
         3558  +      /* Fall thru */
  3551   3559       case TK_LT:
  3552   3560       case TK_LE:
  3553   3561       case TK_GT:
  3554   3562       case TK_GE:
  3555   3563       case TK_NE:
  3556   3564       case TK_EQ: {
  3557   3565         testcase( jumpIfNull==0 );
................................................................................
  3559   3567         r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
  3560   3568         codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
  3561   3569                     r1, r2, dest, jumpIfNull);
  3562   3570         assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
  3563   3571         assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
  3564   3572         assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
  3565   3573         assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
  3566         -      assert(TK_EQ==OP_Eq); testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);
  3567         -      assert(TK_NE==OP_Ne); testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne);
  3568         -      testcase( regFree1==0 );
  3569         -      testcase( regFree2==0 );
  3570         -      break;
  3571         -    }
  3572         -    case TK_IS:
  3573         -    case TK_ISNOT: {
  3574         -      testcase( op==TK_IS );
  3575         -      testcase( op==TK_ISNOT );
  3576         -      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
  3577         -      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
  3578         -      op = (op==TK_IS) ? TK_EQ : TK_NE;
  3579         -      codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
  3580         -                  r1, r2, dest, SQLITE_NULLEQ);
  3581         -      VdbeCoverageIf(v, op==TK_EQ);
  3582         -      VdbeCoverageIf(v, op==TK_NE);
         3574  +      assert(TK_EQ==OP_Eq); testcase(op==OP_Eq);
         3575  +      VdbeCoverageIf(v, op==OP_Eq && jumpIfNull==SQLITE_NULLEQ);
         3576  +      VdbeCoverageIf(v, op==OP_Eq && jumpIfNull!=SQLITE_NULLEQ);
         3577  +      assert(TK_NE==OP_Ne); testcase(op==OP_Ne);
         3578  +      VdbeCoverageIf(v, op==OP_Ne && jumpIfNull==SQLITE_NULLEQ);
         3579  +      VdbeCoverageIf(v, op==OP_Ne && jumpIfNull!=SQLITE_NULLEQ);
  3583   3580         testcase( regFree1==0 );
  3584   3581         testcase( regFree2==0 );
  3585   3582         break;
  3586   3583       }
  3587   3584       case TK_ISNULL:
  3588   3585       case TK_NOTNULL: {
  3589   3586         assert( TK_ISNULL==OP_IsNull );   testcase( op==TK_ISNULL );
................................................................................
  3700   3697         break;
  3701   3698       }
  3702   3699       case TK_NOT: {
  3703   3700         testcase( jumpIfNull==0 );
  3704   3701         sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);
  3705   3702         break;
  3706   3703       }
         3704  +    case TK_IS:
         3705  +    case TK_ISNOT:
         3706  +      testcase( pExpr->op==TK_IS );
         3707  +      testcase( pExpr->op==TK_ISNOT );
         3708  +      op = (pExpr->op==TK_IS) ? TK_NE : TK_EQ;
         3709  +      jumpIfNull = SQLITE_NULLEQ;
         3710  +      /* Fall thru */
  3707   3711       case TK_LT:
  3708   3712       case TK_LE:
  3709   3713       case TK_GT:
  3710   3714       case TK_GE:
  3711   3715       case TK_NE:
  3712   3716       case TK_EQ: {
  3713   3717         testcase( jumpIfNull==0 );
................................................................................
  3715   3719         r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
  3716   3720         codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
  3717   3721                     r1, r2, dest, jumpIfNull);
  3718   3722         assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
  3719   3723         assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
  3720   3724         assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
  3721   3725         assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
  3722         -      assert(TK_EQ==OP_Eq); testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);
  3723         -      assert(TK_NE==OP_Ne); testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne);
  3724         -      testcase( regFree1==0 );
  3725         -      testcase( regFree2==0 );
  3726         -      break;
  3727         -    }
  3728         -    case TK_IS:
  3729         -    case TK_ISNOT: {
  3730         -      testcase( pExpr->op==TK_IS );
  3731         -      testcase( pExpr->op==TK_ISNOT );
  3732         -      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
  3733         -      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
  3734         -      op = (pExpr->op==TK_IS) ? TK_NE : TK_EQ;
  3735         -      codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
  3736         -                  r1, r2, dest, SQLITE_NULLEQ);
  3737         -      VdbeCoverageIf(v, op==TK_EQ);
  3738         -      VdbeCoverageIf(v, op==TK_NE);
         3726  +      assert(TK_EQ==OP_Eq); testcase(op==OP_Eq);
         3727  +      VdbeCoverageIf(v, op==OP_Eq && jumpIfNull!=SQLITE_NULLEQ);
         3728  +      VdbeCoverageIf(v, op==OP_Eq && jumpIfNull==SQLITE_NULLEQ);
         3729  +      assert(TK_NE==OP_Ne); testcase(op==OP_Ne);
         3730  +      VdbeCoverageIf(v, op==OP_Ne && jumpIfNull!=SQLITE_NULLEQ);
         3731  +      VdbeCoverageIf(v, op==OP_Ne && jumpIfNull==SQLITE_NULLEQ);
  3739   3732         testcase( regFree1==0 );
  3740   3733         testcase( regFree2==0 );
  3741   3734         break;
  3742   3735       }
  3743   3736       case TK_ISNULL:
  3744   3737       case TK_NOTNULL: {
  3745   3738         r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
................................................................................
  4254   4247   /*
  4255   4248   ** Mark all temporary registers as being unavailable for reuse.
  4256   4249   */
  4257   4250   void sqlite3ClearTempRegCache(Parse *pParse){
  4258   4251     pParse->nTempReg = 0;
  4259   4252     pParse->nRangeReg = 0;
  4260   4253   }
         4254  +
         4255  +/*
         4256  +** Validate that no temporary register falls within the range of
         4257  +** iFirst..iLast, inclusive.  This routine is only call from within assert()
         4258  +** statements.
         4259  +*/
         4260  +#ifdef SQLITE_DEBUG
         4261  +int sqlite3NoTempsInRange(Parse *pParse, int iFirst, int iLast){
         4262  +  int i;
         4263  +  if( pParse->nRangeReg>0
         4264  +   && pParse->iRangeReg+pParse->nRangeReg<iLast
         4265  +   && pParse->iRangeReg>=iFirst
         4266  +  ){
         4267  +     return 0;
         4268  +  }
         4269  +  for(i=0; i<pParse->nTempReg; i++){
         4270  +    if( pParse->aTempReg[i]>=iFirst && pParse->aTempReg[i]<=iLast ){
         4271  +      return 0;
         4272  +    }
         4273  +  }
         4274  +  return 1;
         4275  +}
         4276  +#endif /* SQLITE_DEBUG */

Changes to src/pcache1.c.

   344    344     return p;
   345    345   }
   346    346   
   347    347   /*
   348    348   ** Free an allocated buffer obtained from pcache1Alloc().
   349    349   */
   350    350   static void pcache1Free(void *p){
   351         -  int nFreed = 0;
   352    351     if( p==0 ) return;
   353    352     if( SQLITE_WITHIN(p, pcache1.pStart, pcache1.pEnd) ){
   354    353       PgFreeslot *pSlot;
   355    354       sqlite3_mutex_enter(pcache1.mutex);
   356    355       sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_USED, 1);
   357    356       pSlot = (PgFreeslot*)p;
   358    357       pSlot->pNext = pcache1.pFree;
................................................................................
   361    360       pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;
   362    361       assert( pcache1.nFreeSlot<=pcache1.nSlot );
   363    362       sqlite3_mutex_leave(pcache1.mutex);
   364    363     }else{
   365    364       assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) );
   366    365       sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
   367    366   #ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
   368         -    nFreed = sqlite3MallocSize(p);
   369         -    sqlite3_mutex_enter(pcache1.mutex);
   370         -    sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_OVERFLOW, nFreed);
   371         -    sqlite3_mutex_leave(pcache1.mutex);
          367  +    {
          368  +      int nFreed = 0;
          369  +      nFreed = sqlite3MallocSize(p);
          370  +      sqlite3_mutex_enter(pcache1.mutex);
          371  +      sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_OVERFLOW, nFreed);
          372  +      sqlite3_mutex_leave(pcache1.mutex);
          373  +    }
   372    374   #endif
   373    375       sqlite3_free(p);
   374    376     }
   375    377   }
   376    378   
   377    379   #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
   378    380   /*

Changes to src/pragma.c.

  1437   1437   
  1438   1438       /* Do an integrity check on each database file */
  1439   1439       for(i=0; i<db->nDb; i++){
  1440   1440         HashElem *x;
  1441   1441         Hash *pTbls;
  1442   1442         int *aRoot;
  1443   1443         int cnt = 0;
         1444  +      int mxIdx = 0;
         1445  +      int nIdx;
  1444   1446   
  1445   1447         if( OMIT_TEMPDB && i==1 ) continue;
  1446   1448         if( iDb>=0 && i!=iDb ) continue;
  1447   1449   
  1448   1450         sqlite3CodeVerifySchema(pParse, i);
  1449   1451         addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Halt if out of errors */
  1450   1452         VdbeCoverage(v);
................................................................................
  1458   1460         */
  1459   1461         assert( sqlite3SchemaMutexHeld(db, i, 0) );
  1460   1462         pTbls = &db->aDb[i].pSchema->tblHash;
  1461   1463         for(cnt=0, x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){
  1462   1464           Table *pTab = sqliteHashData(x);
  1463   1465           Index *pIdx;
  1464   1466           if( HasRowid(pTab) ) cnt++;
  1465         -        for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ cnt++; }
         1467  +        for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){ cnt++; }
         1468  +        if( nIdx>mxIdx ) mxIdx = nIdx;
  1466   1469         }
  1467   1470         aRoot = sqlite3DbMallocRawNN(db, sizeof(int)*(cnt+1));
  1468   1471         if( aRoot==0 ) break;
  1469   1472         for(cnt=0, x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){
  1470   1473           Table *pTab = sqliteHashData(x);
  1471   1474           Index *pIdx;
  1472   1475           if( HasRowid(pTab) ) aRoot[cnt++] = pTab->tnum;
................................................................................
  1473   1476           for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
  1474   1477             aRoot[cnt++] = pIdx->tnum;
  1475   1478           }
  1476   1479         }
  1477   1480         aRoot[cnt] = 0;
  1478   1481   
  1479   1482         /* Make sure sufficient number of registers have been allocated */
  1480         -      pParse->nMem = MAX( pParse->nMem, 14 );
         1483  +      pParse->nMem = MAX( pParse->nMem, 8+mxIdx );
  1481   1484   
  1482   1485         /* Do the b-tree integrity checks */
  1483   1486         sqlite3VdbeAddOp4(v, OP_IntegrityCk, 2, cnt, 1, (char*)aRoot,P4_INTARRAY);
  1484   1487         sqlite3VdbeChangeP5(v, (u8)i);
  1485   1488         addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); VdbeCoverage(v);
  1486   1489         sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
  1487   1490            sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zName),
................................................................................
  1510   1513           sqlite3ExprCacheClear(pParse);
  1511   1514           sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenRead, 0,
  1512   1515                                      1, 0, &iDataCur, &iIdxCur);
  1513   1516           sqlite3VdbeAddOp2(v, OP_Integer, 0, 7);
  1514   1517           for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
  1515   1518             sqlite3VdbeAddOp2(v, OP_Integer, 0, 8+j); /* index entries counter */
  1516   1519           }
  1517         -        pParse->nMem = MAX(pParse->nMem, 8+j);
         1520  +        assert( pParse->nMem>=8+j );
         1521  +        assert( sqlite3NoTempsInRange(pParse,1,7+j) );
  1518   1522           sqlite3VdbeAddOp2(v, OP_Rewind, iDataCur, 0); VdbeCoverage(v);
  1519   1523           loopTop = sqlite3VdbeAddOp2(v, OP_AddImm, 7, 1);
  1520   1524           /* Verify that all NOT NULL columns really are NOT NULL */
  1521   1525           for(j=0; j<pTab->nCol; j++){
  1522   1526             char *zErr;
  1523   1527             int jmp2, jmp3;
  1524   1528             if( j==pTab->iPKey ) continue;

Changes to src/sqliteInt.h.

  3415   3415   int sqlite3RunParser(Parse*, const char*, char **);
  3416   3416   void sqlite3FinishCoding(Parse*);
  3417   3417   int sqlite3GetTempReg(Parse*);
  3418   3418   void sqlite3ReleaseTempReg(Parse*,int);
  3419   3419   int sqlite3GetTempRange(Parse*,int);
  3420   3420   void sqlite3ReleaseTempRange(Parse*,int,int);
  3421   3421   void sqlite3ClearTempRegCache(Parse*);
         3422  +#ifdef SQLITE_DEBUG
         3423  +int sqlite3NoTempsInRange(Parse*,int,int);
         3424  +#endif
  3422   3425   Expr *sqlite3ExprAlloc(sqlite3*,int,const Token*,int);
  3423   3426   Expr *sqlite3Expr(sqlite3*,int,const char*);
  3424   3427   void sqlite3ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr*);
  3425   3428   Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*, const Token*);
  3426   3429   Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*);
  3427   3430   Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*);
  3428   3431   void sqlite3ExprAssignVarNumber(Parse*, Expr*);

Changes to src/test1.c.

  1927   1927     /* Call the underlying C function. If an error occurs, set rc to 
  1928   1928     ** TCL_ERROR and load any error string into the interpreter. If no 
  1929   1929     ** error occurs, set rc to TCL_OK.
  1930   1930     */
  1931   1931   #ifdef SQLITE_OMIT_LOAD_EXTENSION
  1932   1932     rc = SQLITE_ERROR;
  1933   1933     zErr = sqlite3_mprintf("this build omits sqlite3_load_extension()");
         1934  +  (void)zProc;
         1935  +  (void)zFile;
  1934   1936   #else
  1935   1937     rc = sqlite3_load_extension(db, zFile, zProc, &zErr);
  1936   1938   #endif
  1937   1939     if( rc!=SQLITE_OK ){
  1938   1940       Tcl_SetResult(interp, zErr ? zErr : "", TCL_VOLATILE);
  1939   1941       rc = TCL_ERROR;
  1940   1942     }else{

Changes to src/test_config.c.

    74     74   #endif
    75     75   
    76     76   #ifdef SQLITE_DEBUG
    77     77     Tcl_SetVar2(interp, "sqlite_options", "debug", "1", TCL_GLOBAL_ONLY);
    78     78   #else
    79     79     Tcl_SetVar2(interp, "sqlite_options", "debug", "0", TCL_GLOBAL_ONLY);
    80     80   #endif
           81  +
           82  +#ifdef SQLITE_DEFAULT_CKPTFULLFSYNC
           83  +  Tcl_SetVar2(interp, "sqlite_options", "default_ckptfullfsync", 
           84  +              SQLITE_DEFAULT_CKPTFULLFSYNC ? "1" : "0", TCL_GLOBAL_ONLY);
           85  +#else
           86  +  Tcl_SetVar2(interp, "sqlite_options", "default_ckptfullfsync", "0", TCL_GLOBAL_ONLY);
           87  +#endif
    81     88   
    82     89   #ifdef SQLITE_DIRECT_OVERFLOW_READ
    83     90     Tcl_SetVar2(interp, "sqlite_options", "direct_read", "1", TCL_GLOBAL_ONLY);
    84     91   #else
    85     92     Tcl_SetVar2(interp, "sqlite_options", "direct_read", "0", TCL_GLOBAL_ONLY);
    86     93   #endif
    87     94   
................................................................................
    92     99   #endif
    93    100   
    94    101   #ifdef SQLITE_DISABLE_LFS
    95    102     Tcl_SetVar2(interp, "sqlite_options", "lfs", "0", TCL_GLOBAL_ONLY);
    96    103   #else
    97    104     Tcl_SetVar2(interp, "sqlite_options", "lfs", "1", TCL_GLOBAL_ONLY);
    98    105   #endif
          106  +
          107  +#ifdef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
          108  +  Tcl_SetVar2(interp, "sqlite_options", "pagecache_overflow_stats","0",TCL_GLOBAL_ONLY);
          109  +#else
          110  +  Tcl_SetVar2(interp, "sqlite_options", "pagecache_overflow_stats","1",TCL_GLOBAL_ONLY);
          111  +#endif
    99    112   
   100    113   #if SQLITE_MAX_MMAP_SIZE>0
   101    114     Tcl_SetVar2(interp, "sqlite_options", "mmap", "1", TCL_GLOBAL_ONLY);
   102    115   #else
   103    116     Tcl_SetVar2(interp, "sqlite_options", "mmap", "0", TCL_GLOBAL_ONLY);
   104    117   #endif
   105    118   
................................................................................
   572    585   #ifdef SQLITE_OMIT_TCL_VARIABLE
   573    586     Tcl_SetVar2(interp, "sqlite_options", "tclvar", "0", TCL_GLOBAL_ONLY);
   574    587   #else
   575    588     Tcl_SetVar2(interp, "sqlite_options", "tclvar", "1", TCL_GLOBAL_ONLY);
   576    589   #endif
   577    590   
   578    591     Tcl_SetVar2(interp, "sqlite_options", "threadsafe", 
   579         -      STRINGVALUE(SQLITE_THREADSAFE), TCL_GLOBAL_ONLY);
          592  +      SQLITE_THREADSAFE ? "1" : "0", TCL_GLOBAL_ONLY);
          593  +  Tcl_SetVar2(interp, "sqlite_options", "threadsafe1", 
          594  +      SQLITE_THREADSAFE==1 ? "1" : "0", TCL_GLOBAL_ONLY);
          595  +  Tcl_SetVar2(interp, "sqlite_options", "threadsafe2", 
          596  +      SQLITE_THREADSAFE==2 ? "1" : "0", TCL_GLOBAL_ONLY);
   580    597     assert( sqlite3_threadsafe()==SQLITE_THREADSAFE );
   581    598   
   582    599   #ifdef SQLITE_OMIT_TEMPDB
   583    600     Tcl_SetVar2(interp, "sqlite_options", "tempdb", "0", TCL_GLOBAL_ONLY);
   584    601   #else
   585    602     Tcl_SetVar2(interp, "sqlite_options", "tempdb", "1", TCL_GLOBAL_ONLY);
   586    603   #endif

Changes to test/capi3.test.

   921    921   } {0 {}}
   922    922   do_test capi3-11.9.3 {
   923    923     sqlite3_get_autocommit $DB
   924    924   } 1
   925    925   do_test capi3-11.10 {
   926    926     sqlite3_step $STMT
   927    927   } {SQLITE_ROW}
   928         -ifcapable !autoreset {
   929         -  # If SQLITE_OMIT_AUTORESET is defined, then the statement must be
   930         -  # reset() before it can be passed to step() again.
   931         -  do_test capi3-11.11a { sqlite3_step $STMT } {SQLITE_MISUSE}
   932         -  do_test capi3-11.11b { sqlite3_reset $STMT } {SQLITE_ABORT}
   933         -}
   934    928   do_test capi3-11.11 {
   935    929     sqlite3_step $STMT
   936    930   } {SQLITE_DONE}
   937         -do_test capi3-11.12 {
   938         -  sqlite3_step $STMT
   939         -  sqlite3_step $STMT
   940         -} {SQLITE_ROW}
          931  +ifcapable api_armor {
          932  +  do_test capi3-11.12armor {
          933  +    sqlite3_step $STMT
          934  +    sqlite3_step $STMT
          935  +  } {SQLITE_MISUSE}
          936  +} else {
          937  +  do_test capi3-11.12 {
          938  +    sqlite3_step $STMT
          939  +    sqlite3_step $STMT
          940  +  } {SQLITE_ROW}
          941  +}
   941    942   do_test capi3-11.13 {
   942    943     sqlite3_finalize $STMT
   943    944   } {SQLITE_OK}
   944    945   do_test capi3-11.14 {
   945    946     execsql {
   946    947       SELECT a FROM t2;
   947    948     }

Changes to test/capi3c.test.

   861    861   } {0 {}}
   862    862   do_test capi3c-11.9.3 {
   863    863     sqlite3_get_autocommit $DB
   864    864   } 1
   865    865   do_test capi3c-11.10 {
   866    866     sqlite3_step $STMT
   867    867   } {SQLITE_ROW}
   868         -ifcapable !autoreset {
   869         -  # If SQLITE_OMIT_AUTORESET is defined, then the statement must be
   870         -  # reset() before it can be passed to step() again.
   871         -  do_test capi3-11.11a { sqlite3_step $STMT } {SQLITE_MISUSE}
   872         -  do_test capi3-11.11b { sqlite3_reset $STMT } {SQLITE_ABORT}
   873         -}
   874    868   do_test capi3c-11.11 {
   875    869     sqlite3_step $STMT
   876    870   } {SQLITE_DONE}
   877         -do_test capi3c-11.12 {
   878         -  sqlite3_step $STMT
   879         -  sqlite3_step $STMT
   880         -} {SQLITE_ROW}
          871  +ifcapable api_armor {
          872  +  do_test capi3c-11.12armor {
          873  +    sqlite3_step $STMT
          874  +    sqlite3_step $STMT
          875  +  } {SQLITE_MISUSE}
          876  +} else {
          877  +  do_test capi3c-11.12 {
          878  +    sqlite3_step $STMT
          879  +    sqlite3_step $STMT
          880  +  } {SQLITE_ROW}
          881  +}
   881    882   do_test capi3c-11.13 {
   882    883     sqlite3_finalize $STMT
   883    884   } {SQLITE_OK}
   884    885   do_test capi3c-11.14 {
   885    886     execsql {
   886    887       SELECT a FROM t2;
   887    888     }

Changes to test/memsubsys1.test.

    96     96   sqlite3_shutdown
    97     97   sqlite3_config_pagecache [expr 1024+$xtra_size] 20
    98     98   sqlite3_initialize
    99     99   reset_highwater_marks
   100    100   build_test_db memsubsys1-2 {PRAGMA page_size=1024; PRAGMA mmap_size=0}
   101    101   #show_memstats
   102    102   set MEMORY_MANAGEMENT $sqlite_options(memorymanage)
   103         -ifcapable !malloc_usable_size {
   104         - do_test memsubsys1-2.3 {
   105         -    set pg_ovfl [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2]
   106         -  } [expr ($TEMP_STORE>1 || $MEMORY_MANAGEMENT==0)*1024]
          103  +ifcapable pagecache_overflow_stats {
          104  +  ifcapable !malloc_usable_size {
          105  +    do_test memsubsys1-2.3 {
          106  +      set pg_ovfl [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2]
          107  +    } [expr ($TEMP_STORE>1 || $MEMORY_MANAGEMENT==0)*1024]
          108  +  }
   107    109   }
   108    110   do_test memsubsys1-2.4 {
   109    111     set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]
   110    112   } 20
   111    113   do_test memsubsys1-2.5 {
   112    114     set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
   113    115   } 0

Changes to test/mutex1.test.

    93     93   # Tests mutex1-2.* test the three thread-safety related modes that
    94     94   # can be selected using sqlite3_config:
    95     95   #
    96     96   #   * Serialized mode,
    97     97   #   * Multi-threaded mode,
    98     98   #   * Single-threaded mode.
    99     99   #
   100         -ifcapable threadsafe&&shared_cache {
          100  +ifcapable threadsafe1&&shared_cache {
   101    101     set enable_shared_cache [sqlite3_enable_shared_cache 1]
   102    102     foreach {mode mutexes} {
   103    103       singlethread {}
   104    104       multithread  {
   105    105         fast static_app1 static_app2 static_app3
   106    106         static_lru static_master static_mem static_open
   107    107         static_prng static_pmem static_vfs1 static_vfs2

Changes to test/releasetest.tcl.

   170    170       -DSQLITE_THREADSAFE=2
   171    171       --enable-json1 --enable-fts5
   172    172     }
   173    173     "Locking-Style" {
   174    174       -O2
   175    175       -DSQLITE_ENABLE_LOCKING_STYLE=1
   176    176     }
   177         -  "OS-X" {
          177  +  "Apple" {
   178    178       -O1   # Avoid a compiler bug in gcc 4.2.1 build 5658
   179         -    -DSQLITE_OMIT_LOAD_EXTENSION=1
   180         -    -DSQLITE_DEFAULT_MEMSTATUS=0
   181         -    -DSQLITE_THREADSAFE=2
   182         -    -DSQLITE_OS_UNIX=1
   183         -    -DSQLITE_ENABLE_JSON1=1
   184         -    -DSQLITE_ENABLE_LOCKING_STYLE=1
   185         -    -DUSE_PREAD=1
   186         -    -DSQLITE_ENABLE_RTREE=1
          179  +    -DHAVE_GMTIME_R=1
          180  +    -DHAVE_ISNAN=1
          181  +    -DHAVE_LOCALTIME_R=1
          182  +    -DHAVE_PREAD=1
          183  +    -DHAVE_PWRITE=1
          184  +    -DHAVE_USLEEP=1
          185  +    -DHAVE_USLEEP=1
          186  +    -DHAVE_UTIME=1
          187  +    -DSQLITE_DEFAULT_CACHE_SIZE=1000
          188  +    -DSQLITE_DEFAULT_CKPTFULLFSYNC=1
          189  +    -DSQLITE_DEFAULT_MEMSTATUS=1
          190  +    -DSQLITE_DEFAULT_PAGE_SIZE=1024
          191  +    -DSQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS=1
          192  +    -DSQLITE_ENABLE_API_ARMOR=1
          193  +    -DSQLITE_ENABLE_AUTO_PROFILE=1
          194  +    -DSQLITE_ENABLE_FLOCKTIMEOUT=1
   187    195       -DSQLITE_ENABLE_FTS3=1
   188    196       -DSQLITE_ENABLE_FTS3_PARENTHESIS=1
   189         -    -DSQLITE_DEFAULT_CACHE_SIZE=1000
          197  +    -DSQLITE_ENABLE_FTS3_TOKENIZER=1
          198  +    if:os=="Darwin" -DSQLITE_ENABLE_LOCKING_STYLE=1
          199  +    -DSQLITE_ENABLE_PERSIST_WAL=1
          200  +    -DSQLITE_ENABLE_PURGEABLE_PCACHE=1
          201  +    -DSQLITE_ENABLE_RTREE=1
          202  +    -DSQLITE_ENABLE_SNAPSHOT=1
          203  +    # -DSQLITE_ENABLE_SQLLOG=1
          204  +    -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1
   190    205       -DSQLITE_MAX_LENGTH=2147483645
   191    206       -DSQLITE_MAX_VARIABLE_NUMBER=500000
   192         -    -DSQLITE_DEBUG=1
          207  +    # -DSQLITE_MEMDEBUG=1
          208  +    -DSQLITE_NO_SYNC=1
          209  +    -DSQLITE_OMIT_AUTORESET=1
          210  +    -DSQLITE_OMIT_LOAD_EXTENSION=1
   193    211       -DSQLITE_PREFER_PROXY_LOCKING=1
   194         -    -DSQLITE_ENABLE_API_ARMOR=1
          212  +    -DSQLITE_SERIES_CONSTRAINT_VERIFY=1
          213  +    -DSQLITE_THREADSAFE=2
          214  +    -DSQLITE_USE_URI=1
          215  +    -DSQLITE_WRITE_WALFRAME_PREBUFFERED=1
          216  +    -DUSE_GUARDED_FD=1
          217  +    -DUSE_PREAD=1
   195    218       --enable-json1 --enable-fts5
   196    219     }
   197    220     "Extra-Robustness" {
   198    221       -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1
   199    222       -DSQLITE_MAX_ATTACHED=62
   200    223     }
   201    224     "Devkit" {
................................................................................
   244    267       "Secure-Delete"           test
   245    268       "Unlock-Notify"           "QUICKTEST_INCLUDE=notify2.test test"
   246    269       "Update-Delete-Limit"     test
   247    270       "Extra-Robustness"        test
   248    271       "Device-Two"              test
   249    272       "No-lookaside"            test
   250    273       "Devkit"                  test
          274  +    "Apple"                   test
   251    275       "Sanitize"                {QUICKTEST_OMIT=func4.test,nan.test test}
   252    276       "Device-One"              fulltest
   253    277       "Default"                 "threadtest fulltest"
   254    278       "Valgrind"                valgrindtest
   255    279     }
   256    280     Linux-i686 {
   257    281       "Devkit"                  test
................................................................................
   260    284       "Device-One"              test
   261    285       "Device-Two"              test
   262    286       "Default"                 "threadtest fulltest"
   263    287     }
   264    288     Darwin-i386 {
   265    289       "Locking-Style"           "mptest test"
   266    290       "Have-Not"                test
   267         -    "OS-X"                    "threadtest fulltest"
          291  +    "Apple"                   "threadtest fulltest"
   268    292     }
   269    293     Darwin-x86_64 {
   270    294       "Locking-Style"           "mptest test"
   271    295       "Have-Not"                test
   272         -    "OS-X"                    "threadtest fulltest"
          296  +    "Apple"                   "threadtest fulltest"
   273    297     }
   274    298     "Windows NT-intel" {
   275    299       "Have-Not"                test
   276    300       "Default"                 "mptest fulltestonly"
   277    301     }
   278    302     "Windows NT-amd64" {
   279    303       "Have-Not"                test
................................................................................
   584    608     # CFLAGS is only passed to gcc.
   585    609     #
   586    610     set makeOpts ""
   587    611     set cflags [expr {$::MSVC ? "-Zi" : "-g"}]
   588    612     set opts ""
   589    613     set title ${name}($testtarget)
   590    614     set configOpts $::WITHTCL
          615  +  set skip 0
   591    616   
   592    617     regsub -all {#[^\n]*\n} $config \n config
   593    618     foreach arg $config {
          619  +    if {$skip} {
          620  +      set skip 0
          621  +      continue
          622  +    }
   594    623       if {[regexp {^-[UD]} $arg]} {
   595    624         lappend opts $arg
   596    625       } elseif {[regexp {^[A-Z]+=} $arg]} {
   597    626         lappend testtarget $arg
          627  +    } elseif {[regexp {^if:([a-z]+)(.*)} $arg all key tail]} {
          628  +      # Arguments of the form 'if:os=="Linux"' will cause the subsequent
          629  +      # argument to be skipped if the $tcl_platform(os) is not "Linux", for
          630  +      # example...
          631  +      set skip [expr !(\$::tcl_platform($key)$tail)]
   598    632       } elseif {[regexp {^--(enable|disable)-} $arg]} {
   599    633         if {$::MSVC} {
   600    634           if {$arg eq "--disable-amalgamation"} {
   601    635             lappend makeOpts USE_AMALGAMATION=0
   602    636             continue
   603    637           }
   604    638           if {$arg eq "--disable-shared"} {

Changes to test/sqldiff1.test.

    10     10   #***********************************************************************
    11     11   #
    12     12   # Quick tests for the sqldiff tool
    13     13   #
    14     14   set testdir [file dirname $argv0]
    15     15   source $testdir/tester.tcl
    16     16   
    17         -if {$tcl_platform(platform)=="windows"} {
    18         -  set PROG "sqldiff.exe"
    19         -} else {
    20         -  set PROG "./sqldiff"
    21         -}
    22         -if {![file exe $PROG]} {
    23         -  puts "sqldiff cannot run because $PROG is not available"
    24         -  finish_test
    25         -  return
    26         -}
           17  +set PROG [test_find_sqldiff]
           18  +
    27     19   db close
    28     20   forcedelete test.db test2.db
    29     21   sqlite3 db test.db
    30     22   
    31     23   do_test sqldiff-1.0 {
    32     24     db eval {
    33     25       CREATE TABLE t1(a INTEGER PRIMARY KEY, b);

Changes to test/tester.tcl.

  2131   2131     sqlite3_shutdown
  2132   2132     eval sqlite3_config_pagecache $::old_pagecache_config
  2133   2133     unset ::old_pagecache_config 
  2134   2134     sqlite3_initialize
  2135   2135     autoinstall_test_functions
  2136   2136     sqlite3 db test.db
  2137   2137   }
         2138  +
         2139  +proc test_find_binary {nm} {
         2140  +  if {$::tcl_platform(platform)=="windows"} {
         2141  +    set ret "$nm.exe"
         2142  +  } else {
         2143  +    set ret $nm
         2144  +  }
         2145  +  set ret [file normalize [file join $::cmdlinearg(TESTFIXTURE_HOME) $ret]]
         2146  +  if {![file executable $ret]} {
         2147  +    finish_test
         2148  +    return ""
         2149  +  }
         2150  +  return $ret
         2151  +}
  2138   2152   
  2139   2153   # Find the name of the 'shell' executable (e.g. "sqlite3.exe") to use for
  2140   2154   # the tests in shell[1-5].test. If no such executable can be found, invoke
  2141   2155   # [finish_test ; return] in the callers context.
  2142   2156   #
  2143   2157   proc test_find_cli {} {
  2144         -  if {$::tcl_platform(platform)=="windows"} {
  2145         -    set ret "sqlite3.exe"
  2146         -  } else {
  2147         -    set ret "sqlite3"
  2148         -  }
  2149         -  set ret [file normalize [file join $::cmdlinearg(TESTFIXTURE_HOME) $ret]]
  2150         -  if {![file executable $ret]} {
  2151         -    finish_test
  2152         -    return -code return
  2153         -  }
  2154         -  return $ret
         2158  +  set cli [test_find_binary sqlite3]
         2159  +  if {$prog==""} { return -code return }
         2160  +  return $prog
         2161  +}
         2162  +
         2163  +# Find the name of the 'sqldiff' executable (e.g. "sqlite3.exe") to use for
         2164  +# the tests in sqldiff tests. If no such executable can be found, invoke
         2165  +# [finish_test ; return] in the callers context.
         2166  +#
         2167  +proc test_find_sqldiff {} {
         2168  +  set prog [test_find_binary sqldiff]
         2169  +  if {$prog==""} { return -code return }
         2170  +  return $prog
  2155   2171   }
         2172  +
  2156   2173   
  2157   2174   # If the library is compiled with the SQLITE_DEFAULT_AUTOVACUUM macro set
  2158   2175   # to non-zero, then set the global variable $AUTOVACUUM to 1.
  2159   2176   set AUTOVACUUM $sqlite_options(default_autovacuum)
  2160   2177   
  2161   2178   # Make sure the FTS enhanced query syntax is disabled.
  2162   2179   set sqlite_fts3_enable_parentheses 0

Changes to test/wal2.test.

  1190   1190   # Test that "PRAGMA checkpoint_fullsync" appears to be working.
  1191   1191   #
  1192   1192   foreach {tn sql reslist} {
  1193   1193     1 { }                                 {10 0 4 0 6 0}
  1194   1194     2 { PRAGMA checkpoint_fullfsync = 1 } {10 4 4 2 6 2}
  1195   1195     3 { PRAGMA checkpoint_fullfsync = 0 } {10 0 4 0 6 0}
  1196   1196   } {
         1197  +  ifcapable default_ckptfullfsync {
         1198  +    if {[string trim $sql]==""} continue
         1199  +  }
  1197   1200     faultsim_delete_and_reopen
  1198   1201   
  1199   1202     execsql {PRAGMA auto_vacuum = 0; PRAGMA synchronous = FULL;}
  1200   1203     execsql $sql
  1201   1204     do_execsql_test wal2-14.$tn.0 { PRAGMA page_size = 4096 }   {}
  1202   1205     do_execsql_test wal2-14.$tn.1 { PRAGMA journal_mode = WAL } {wal}
  1203   1206   

Changes to test/wal3.test.

   216    216     
   217    217       testvfs T
   218    218       T filter {} 
   219    219       T script sync_counter
   220    220       sqlite3 db test.db -vfs T
   221    221     
   222    222       execsql "PRAGMA synchronous = $syncmode"
          223  +    execsql "PRAGMA checkpoint_fullfsync = 0"
   223    224       execsql { PRAGMA journal_mode = WAL }
   224    225       execsql { CREATE TABLE filler(a,b,c); }
   225    226   
   226    227       set ::syncs [list]
   227    228       T filter xSync
   228    229       execsql {
   229    230         CREATE TABLE x(y);

Changes to tool/sqldiff.c.

  1753   1753     int rc;
  1754   1754     char *zErrMsg = 0;
  1755   1755     char *zSql;
  1756   1756     sqlite3_stmt *pStmt;
  1757   1757     char *zTab = 0;
  1758   1758     FILE *out = stdout;
  1759   1759     void (*xDiff)(const char*,FILE*) = diff_one_table;
         1760  +#ifndef SQLITE_OMIT_LOAD_EXTENSION
  1760   1761     int nExt = 0;
  1761   1762     char **azExt = 0;
         1763  +#endif
  1762   1764     int useTransaction = 0;
  1763   1765     int neverUseTransaction = 0;
  1764   1766   
  1765   1767     g.zArgv0 = argv[0];
  1766   1768     sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
  1767   1769     for(i=1; i<argc; i++){
  1768   1770       const char *z = argv[i];
................................................................................
  1837   1839     sqlite3_enable_load_extension(g.db, 1);
  1838   1840     for(i=0; i<nExt; i++){
  1839   1841       rc = sqlite3_load_extension(g.db, azExt[i], 0, &zErrMsg);
  1840   1842       if( rc || zErrMsg ){
  1841   1843         cmdlineError("error loading %s: %s", azExt[i], zErrMsg);
  1842   1844       }
  1843   1845     }
  1844         -#endif
  1845   1846     free(azExt);
         1847  +#endif
  1846   1848     zSql = sqlite3_mprintf("ATTACH %Q as aux;", zDb2);
  1847   1849     rc = sqlite3_exec(g.db, zSql, 0, 0, &zErrMsg);
  1848   1850     if( rc || zErrMsg ){
  1849   1851       cmdlineError("cannot attach database \"%s\"", zDb2);
  1850   1852     }
  1851   1853     rc = sqlite3_exec(g.db, "SELECT * FROM aux.sqlite_master", 0, 0, &zErrMsg);
  1852   1854     if( rc || zErrMsg ){