/ Check-in [4cbd5024]
Login

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

Overview
Comment:Modify the permutations.test script so as to set any permutation specific configuration values before running each individual test script. Fix a mostly harmless buffer overread in the sessions module.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:4cbd50245440e714935399a5c285cf32d8bfc424
User & Date: dan 2016-04-29 11:33:58
Context
2016-04-29
15:39
Postpone I/O associated with TEMP files for as long as possible, with the hope that the I/O can ultimately be avoided completely. check-in: 9d0a5ae0 user: drh tags: trunk
11:35
Merge latest trunk changes, including test case fixes, with this branch. check-in: 99794aca user: dan tags: tempfiles-25
11:33
Modify the permutations.test script so as to set any permutation specific configuration values before running each individual test script. Fix a mostly harmless buffer overread in the sessions module. check-in: 4cbd5024 user: dan tags: trunk
11:28
Lemon bug fix: Do not merge action routines unless their destructors are also identical. Problem and suggested fix reported on the mailing list by Kelvin Sherlock. check-in: 4792d6db user: drh tags: trunk
10:13
Fix an almost entirely harmless buffer overread in the sessions module. Closed-Leaf check-in: 89b0ee33 user: dan tags: permutations-fix
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/session/sessionfault.test.

    13     13   #
    14     14   
    15     15   if {![info exists testdir]} {
    16     16     set testdir [file join [file dirname [info script]] .. .. test]
    17     17   } 
    18     18   source [file join [file dirname [info script]] session_common.tcl]
    19     19   source $testdir/tester.tcl
           20  +ifcapable !session {finish_test; return}
    20     21   
    21     22   set testprefix sessionfault
    22     23   
    23     24   forcedelete test.db2
    24     25   sqlite3 db2 test.db2
    25     26   do_common_sql {
    26     27     CREATE TABLE t1(a, b, c, PRIMARY KEY(a, b));

Changes to ext/session/sessionfault2.test.

    13     13   #
    14     14   
    15     15   if {![info exists testdir]} {
    16     16     set testdir [file join [file dirname [info script]] .. .. test]
    17     17   } 
    18     18   source [file join [file dirname [info script]] session_common.tcl]
    19     19   source $testdir/tester.tcl
           20  +ifcapable !session {finish_test; return}
    20     21   set testprefix sessionfault2
    21     22   
    22     23   do_execsql_test 1.0.0 {
    23     24     CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
    24     25     INSERT INTO t1 VALUES(1, 1);
    25     26     INSERT INTO t1 VALUES(2, 2);
    26     27     INSERT INTO t1 VALUES(3, 3);

Changes to ext/session/sqlite3session.c.

   588    588     u8 *aRight                      /* Change record */
   589    589   ){
   590    590     u8 *a1 = aLeft;                 /* Cursor to iterate through aLeft */
   591    591     u8 *a2 = aRight;                /* Cursor to iterate through aRight */
   592    592     int iCol;                       /* Used to iterate through table columns */
   593    593   
   594    594     for(iCol=0; iCol<pTab->nCol; iCol++){
   595         -    int n1 = sessionSerialLen(a1);
   596         -    int n2 = sessionSerialLen(a2);
          595  +    if( pTab->abPK[iCol] ){
          596  +      int n1 = sessionSerialLen(a1);
          597  +      int n2 = sessionSerialLen(a2);
   597    598   
   598         -    if( pTab->abPK[iCol] && (n1!=n2 || memcmp(a1, a2, n1)) ){
   599         -      return 0;
          599  +      if( pTab->abPK[iCol] && (n1!=n2 || memcmp(a1, a2, n1)) ){
          600  +        return 0;
          601  +      }
          602  +      a1 += n1;
          603  +      a2 += n2;
          604  +    }else{
          605  +      if( bLeftPkOnly==0 ) a1 += sessionSerialLen(a1);
          606  +      if( bRightPkOnly==0 ) a2 += sessionSerialLen(a2);
   600    607       }
   601         -    if( pTab->abPK[iCol] || bLeftPkOnly==0 ) a1 += n1;
   602         -    if( pTab->abPK[iCol] || bRightPkOnly==0 ) a2 += n2;
   603    608     }
   604    609   
   605    610     return 1;
   606    611   }
   607    612   
   608    613   /*
   609    614   ** Arguments aLeft and aRight both point to buffers containing change

Changes to src/test1.c.

  5209   5209     }
  5210   5210     nVfs = i;
  5211   5211     return TCL_OK;
  5212   5212   }
  5213   5213   /*
  5214   5214   ** tclcmd:   vfs_reregister_all
  5215   5215   **
  5216         -** Restore all VFSes that were removed using vfs_unregister_all
         5216  +** Restore all VFSes that were removed using vfs_unregister_all. Taking
         5217  +** care to put the linked list back together in the same order as it was
         5218  +** in before vfs_unregister_all was invoked.
  5217   5219   */
  5218   5220   static int vfs_reregister_all(
  5219   5221     ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
  5220   5222     Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
  5221   5223     int objc,              /* Number of arguments */
  5222   5224     Tcl_Obj *CONST objv[]  /* Command arguments */
  5223   5225   ){
  5224   5226     int i;
  5225         -  for(i=0; i<nVfs; i++){
  5226         -    sqlite3_vfs_register(apVfs[i], i==0);
         5227  +  for(i=nVfs-1; i>=0; i--){
         5228  +    sqlite3_vfs_register(apVfs[i], 1);
  5227   5229     }
  5228   5230     return TCL_OK;
  5229   5231   }
  5230   5232   
  5231   5233   
  5232   5234   /*
  5233   5235   ** tclcmd:   file_control_test DB

Changes to src/test6.c.

   697    697     sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData;
   698    698     return pVfs->xSleep(pVfs, nMicro);
   699    699   }
   700    700   static int cfCurrentTime(sqlite3_vfs *pCfVfs, double *pTimeOut){
   701    701     sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData;
   702    702     return pVfs->xCurrentTime(pVfs, pTimeOut);
   703    703   }
          704  +static int cfGetLastError(sqlite3_vfs *pCfVfs, int n, char *z){
          705  +  sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData;
          706  +  return pVfs->xGetLastError(pVfs, n, z);
          707  +}
   704    708   
   705    709   static int processDevSymArgs(
   706    710     Tcl_Interp *interp,
   707    711     int objc,
   708    712     Tcl_Obj *CONST objv[],
   709    713     int *piDeviceChar,
   710    714     int *piSectorSize
................................................................................
   823    827       cfDlOpen,             /* xDlOpen */
   824    828       cfDlError,            /* xDlError */
   825    829       cfDlSym,              /* xDlSym */
   826    830       cfDlClose,            /* xDlClose */
   827    831       cfRandomness,         /* xRandomness */
   828    832       cfSleep,              /* xSleep */
   829    833       cfCurrentTime,        /* xCurrentTime */
   830         -    0,                    /* xGetlastError */
          834  +    cfGetLastError,       /* xGetLastError */
   831    835       0,                    /* xCurrentTimeInt64 */
   832    836     };
   833    837   
   834    838     if( objc!=2 ){
   835    839       Tcl_WrongNumArgs(interp, 1, objv, "ENABLE");
   836    840       return TCL_ERROR;
   837    841     }
................................................................................
   936    940   
   937    941     if( processDevSymArgs(interp, objc-1, &objv[1], &iDc, &iSectorSize) ){
   938    942       return TCL_ERROR;
   939    943     }
   940    944     devsym_register(iDc, iSectorSize);
   941    945   
   942    946     return TCL_OK;
          947  +
          948  +}
          949  +
          950  +/*
          951  +** tclcmd: unregister_devsim
          952  +*/
          953  +static int dsUnregisterObjCmd(
          954  +  void * clientData,
          955  +  Tcl_Interp *interp,
          956  +  int objc,
          957  +  Tcl_Obj *CONST objv[]
          958  +){
          959  +  void devsym_unregister(void);
          960  +
          961  +  if( objc!=1 ){
          962  +    Tcl_WrongNumArgs(interp, 1, objv, "");
          963  +    return TCL_ERROR;
          964  +  }
          965  +
          966  +  devsym_unregister();
          967  +  return TCL_OK;
   943    968   }
   944    969   
   945    970   /*
   946    971   ** tclcmd: register_jt_vfs ?-default? PARENT-VFS
   947    972   */
   948    973   static int jtObjCmd(
   949    974     void * clientData,
................................................................................
  1006   1031   ** This procedure registers the TCL procedures defined in this file.
  1007   1032   */
  1008   1033   int Sqlitetest6_Init(Tcl_Interp *interp){
  1009   1034   #ifndef SQLITE_OMIT_DISKIO
  1010   1035     Tcl_CreateObjCommand(interp, "sqlite3_crash_enable", crashEnableCmd, 0, 0);
  1011   1036     Tcl_CreateObjCommand(interp, "sqlite3_crashparams", crashParamsObjCmd, 0, 0);
  1012   1037     Tcl_CreateObjCommand(interp, "sqlite3_simulate_device", devSymObjCmd, 0, 0);
         1038  +  Tcl_CreateObjCommand(interp, "unregister_devsim", dsUnregisterObjCmd, 0, 0);
  1013   1039     Tcl_CreateObjCommand(interp, "register_jt_vfs", jtObjCmd, 0, 0);
  1014   1040     Tcl_CreateObjCommand(interp, "unregister_jt_vfs", jtUnregisterObjCmd, 0, 0);
  1015   1041   #endif
  1016   1042     return TCL_OK;
  1017   1043   }
  1018   1044   
  1019   1045   #endif /* SQLITE_TEST */

Changes to src/test_devsym.c.

   391    391     }
   392    392     if( iSectorSize>=0 ){
   393    393       g.iSectorSize = iSectorSize;
   394    394     }else{
   395    395       g.iSectorSize = 512;
   396    396     }
   397    397   }
          398  +
          399  +void devsym_unregister(){
          400  +  sqlite3_vfs_unregister(&devsym_vfs);
          401  +  g.pVfs = 0;
          402  +  g.iDeviceChar = 0;
          403  +  g.iSectorSize = 0;
          404  +}
   398    405   
   399    406   #endif

Changes to src/test_journal.c.

   156    156   static void jtDlError(sqlite3_vfs*, int nByte, char *zErrMsg);
   157    157   static void (*jtDlSym(sqlite3_vfs*,void*, const char *zSymbol))(void);
   158    158   static void jtDlClose(sqlite3_vfs*, void*);
   159    159   static int jtRandomness(sqlite3_vfs*, int nByte, char *zOut);
   160    160   static int jtSleep(sqlite3_vfs*, int microseconds);
   161    161   static int jtCurrentTime(sqlite3_vfs*, double*);
   162    162   static int jtCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*);
          163  +static int jtGetLastError(sqlite3_vfs*, int, char*);
   163    164   
   164    165   static sqlite3_vfs jt_vfs = {
   165    166     2,                             /* iVersion */
   166    167     sizeof(jt_file),               /* szOsFile */
   167    168     JT_MAX_PATHNAME,               /* mxPathname */
   168    169     0,                             /* pNext */
   169    170     JT_VFS_NAME,                   /* zName */
................................................................................
   175    176     jtDlOpen,                      /* xDlOpen */
   176    177     jtDlError,                     /* xDlError */
   177    178     jtDlSym,                       /* xDlSym */
   178    179     jtDlClose,                     /* xDlClose */
   179    180     jtRandomness,                  /* xRandomness */
   180    181     jtSleep,                       /* xSleep */
   181    182     jtCurrentTime,                 /* xCurrentTime */
   182         -  0,                             /* xGetLastError */
          183  +  jtGetLastError,                /* xGetLastError */
   183    184     jtCurrentTimeInt64             /* xCurrentTimeInt64 */
   184    185   };
   185    186   
   186    187   static sqlite3_io_methods jt_io_methods = {
   187    188     1,                             /* iVersion */
   188    189     jtClose,                       /* xClose */
   189    190     jtRead,                        /* xRead */
................................................................................
   281    282   ** following properties:
   282    283   **
   283    284   **   a) SQLITE_OPEN_MAIN_DB was specified when the file was opened.
   284    285   **
   285    286   **   b) The file-name specified when the file was opened matches
   286    287   **      all but the final 8 characters of the journal file name.
   287    288   **
   288         -**   c) There is currently a reserved lock on the file.
          289  +**   c) There is currently a reserved lock on the file. This 
          290  +**      condition is waived if the noLock argument is non-zero.
   289    291   **/
   290         -static jt_file *locateDatabaseHandle(const char *zJournal){
          292  +static jt_file *locateDatabaseHandle(const char *zJournal, int noLock){
   291    293     jt_file *pMain = 0;
   292    294     enterJtMutex();
   293    295     for(pMain=g.pList; pMain; pMain=pMain->pNext){
   294    296       int nName = (int)(strlen(zJournal) - strlen("-journal"));
   295    297       if( (pMain->flags&SQLITE_OPEN_MAIN_DB)
   296    298        && ((int)strlen(pMain->zName)==nName)
   297    299        && 0==memcmp(pMain->zName, zJournal, nName)
   298         -     && (pMain->eLock>=SQLITE_LOCK_RESERVED)
          300  +     && ((pMain->eLock>=SQLITE_LOCK_RESERVED) || noLock)
   299    301       ){
   300    302         break;
   301    303       }
   302    304     }
   303    305     leaveJtMutex();
   304    306     return pMain;
   305    307   }
................................................................................
   513    515     int iAmt, 
   514    516     sqlite_int64 iOfst
   515    517   ){
   516    518     int rc;
   517    519     jt_file *p = (jt_file *)pFile;
   518    520     if( p->flags&SQLITE_OPEN_MAIN_JOURNAL ){
   519    521       if( iOfst==0 ){
   520         -      jt_file *pMain = locateDatabaseHandle(p->zName);
          522  +      jt_file *pMain = locateDatabaseHandle(p->zName, 0);
   521    523         assert( pMain );
   522    524     
   523    525         if( iAmt==28 ){
   524    526           /* Zeroing the first journal-file header. This is the end of a
   525    527           ** transaction. */
   526    528           closeTransaction(pMain);
   527    529         }else if( iAmt!=12 ){
................................................................................
   558    560         assert( pgno<=p->nPage || p->nSync>0 );
   559    561         assert( pgno>p->nPage || sqlite3BitvecTest(p->pWritable, pgno) );
   560    562       }
   561    563     }
   562    564   
   563    565     rc = sqlite3OsWrite(p->pReal, zBuf, iAmt, iOfst);
   564    566     if( (p->flags&SQLITE_OPEN_MAIN_JOURNAL) && iAmt==12 ){
   565         -    jt_file *pMain = locateDatabaseHandle(p->zName);
          567  +    jt_file *pMain = locateDatabaseHandle(p->zName, 0);
   566    568       int rc2 = readJournalFile(p, pMain);
   567    569       if( rc==SQLITE_OK ) rc = rc2;
   568    570     }
   569    571     return rc;
   570    572   }
   571    573   
   572    574   /*
   573    575   ** Truncate an jt-file.
   574    576   */
   575    577   static int jtTruncate(sqlite3_file *pFile, sqlite_int64 size){
   576    578     jt_file *p = (jt_file *)pFile;
   577    579     if( p->flags&SQLITE_OPEN_MAIN_JOURNAL && size==0 ){
   578    580       /* Truncating a journal file. This is the end of a transaction. */
   579         -    jt_file *pMain = locateDatabaseHandle(p->zName);
          581  +    jt_file *pMain = locateDatabaseHandle(p->zName, 0);
   580    582       closeTransaction(pMain);
   581    583     }
   582    584     if( p->flags&SQLITE_OPEN_MAIN_DB && p->pWritable ){
   583    585       u32 pgno;
   584    586       u32 locking_page = (u32)(PENDING_BYTE/p->nPagesize+1);
   585    587       for(pgno=(u32)(size/p->nPagesize+1); pgno<=p->nPage; pgno++){
   586    588         assert( pgno==locking_page || sqlite3BitvecTest(p->pWritable, pgno) );
................................................................................
   600    602       jt_file *pMain;                   /* The associated database file */
   601    603   
   602    604       /* The journal file is being synced. At this point, we inspect the 
   603    605       ** contents of the file up to this point and set each bit in the 
   604    606       ** jt_file.pWritable bitvec of the main database file associated with
   605    607       ** this journal file.
   606    608       */
   607         -    pMain = locateDatabaseHandle(p->zName);
   608         -    assert(pMain);
          609  +    pMain = locateDatabaseHandle(p->zName, 0);
   609    610   
   610    611       /* Set the bitvec values */
   611         -    if( pMain->pWritable ){
          612  +    if( pMain && pMain->pWritable ){
   612    613         pMain->nSync++;
   613    614         rc = readJournalFile(p, pMain);
   614    615         if( rc!=SQLITE_OK ){
   615    616           return rc;
   616    617         }
   617    618       }
   618    619     }
................................................................................
   726    727   ** ensure the file-system modifications are synced to disk before
   727    728   ** returning.
   728    729   */
   729    730   static int jtDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
   730    731     int nPath = (int)strlen(zPath);
   731    732     if( nPath>8 && 0==strcmp("-journal", &zPath[nPath-8]) ){
   732    733       /* Deleting a journal file. The end of a transaction. */
   733         -    jt_file *pMain = locateDatabaseHandle(zPath);
          734  +    jt_file *pMain = locateDatabaseHandle(zPath, 0);
   734    735       if( pMain ){
   735    736         closeTransaction(pMain);
   736    737       }
   737    738     }
   738    739   
   739    740     return sqlite3OsDelete(g.pVfs, zPath, dirSync);
   740    741   }
................................................................................
   820    821   }
   821    822   /*
   822    823   ** Return the current time as a Julian Day number in *pTimeOut.
   823    824   */
   824    825   static int jtCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *pTimeOut){
   825    826     return g.pVfs->xCurrentTimeInt64(g.pVfs, pTimeOut);
   826    827   }
          828  +
          829  +static int jtGetLastError(sqlite3_vfs *pVfs, int n, char *z){
          830  +  return g.pVfs->xGetLastError(g.pVfs, n, z);
          831  +}
   827    832   
   828    833   /**************************************************************************
   829    834   ** Start of public API.
   830    835   */
   831    836   
   832    837   /*
   833    838   ** Configure the jt VFS as a wrapper around the VFS named by parameter 

Changes to src/test_syscall.c.

   718    718       { "list",       test_syscall_list },
   719    719       { "defaultvfs", test_syscall_defaultvfs },
   720    720       { "pagesize",   test_syscall_pagesize },
   721    721       { 0, 0 }
   722    722     };
   723    723     int iCmd;
   724    724     int rc;
          725  +  sqlite3_vfs *pVfs = sqlite3_vfs_find(0);
   725    726   
   726    727     if( objc<2 ){
   727    728       Tcl_WrongNumArgs(interp, 1, objv, "SUB-COMMAND ...");
   728    729       return TCL_ERROR;
   729    730     }
   730         -  rc = Tcl_GetIndexFromObjStruct(interp, 
   731         -      objv[1], aCmd, sizeof(aCmd[0]), "sub-command", 0, &iCmd
   732         -  );
          731  +  if( pVfs->iVersion<3 || pVfs->xSetSystemCall==0 ){
          732  +    Tcl_AppendResult(interp, "VFS does not support xSetSystemCall", 0);
          733  +    rc = TCL_ERROR;
          734  +  }else{
          735  +    rc = Tcl_GetIndexFromObjStruct(interp, 
          736  +        objv[1], aCmd, sizeof(aCmd[0]), "sub-command", 0, &iCmd
          737  +    );
          738  +  }
   733    739     if( rc!=TCL_OK ) return rc;
   734    740     return aCmd[iCmd].xCmd(clientData, interp, objc, objv);
   735    741   }
   736    742   
   737    743   int SqlitetestSyscall_Init(Tcl_Interp *interp){
   738    744     struct SyscallCmd {
   739    745       const char *zName;

Changes to test/dbstatus2.test.

    82     82     execsql { INSERT INTO t1 VALUES(4, randomblob(600)) }
    83     83     db_write db
    84     84   } {0 4 0}
    85     85   do_test 2.3 { db_write db 1 } {0 4 0}
    86     86   do_test 2.4 { db_write db 0 } {0 0 0}
    87     87   do_test 2.5 { db_write db 1 } {0 0 0}
    88     88   
    89         -ifcapable wal {
           89  +if {[wal_is_capable]} {
    90     90     do_test 2.6 { 
    91     91       execsql { PRAGMA journal_mode = WAL }
    92     92       db_write db 1
    93     93     } {0 1 0}
    94     94   }
    95     95   do_test 2.7 { 
    96     96     execsql { INSERT INTO t1 VALUES(5, randomblob(600)) }
    97     97     db_write db
    98     98   } {0 4 0}
    99     99   do_test 2.8 { db_write db 1 } {0 4 0}
   100    100   do_test 2.9 { db_write db 0 } {0 0 0}
   101    101    
   102    102   finish_test

Changes to test/e_vacuum.test.

   172    172       execsql VACUUM
   173    173       execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
   174    174     } {2048 0}
   175    175     
   176    176     # EVIDENCE-OF: R-48521-51450 When in write-ahead log mode, only the
   177    177     # auto_vacuum support property can be changed using VACUUM.
   178    178     #
   179         -  ifcapable wal {
          179  +  if {[wal_is_capable]} {
   180    180       do_test e_vacuum-1.3.3.1 {
   181    181         execsql { PRAGMA journal_mode = wal }
   182    182         execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
   183    183       } {2048 0}
   184    184       do_test e_vacuum-1.3.3.2 {
   185    185         execsql { PRAGMA page_size = 1024 }
   186    186         execsql { PRAGMA auto_vacuum = FULL }

Changes to test/exists.test.

    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   source $testdir/lock_common.tcl
    19     19   
    20     20   
    21     21   foreach jm {rollback wal} {
           22  +  if {![wal_is_capable] && $jm=="wal"} continue
    22     23   
    23     24     set testprefix exists-$jm
    24     25   
    25     26     # This block of tests is targeted at CREATE XXX IF NOT EXISTS statements.
    26     27     #
    27     28     do_multiclient_test tn {
    28     29   

Changes to test/hook.test.

   700    700   do_execsql_test 7.5.2.0 {
   701    701     CREATE TABLE t8(a, b);
   702    702     INSERT INTO t8 VALUES('one', 'two');
   703    703     INSERT INTO t8 VALUES('three', 'four');
   704    704     ALTER TABLE t8 ADD COLUMN c DEFAULT 'xxx';
   705    705   }
   706    706   
   707         -ifcapable !session {
          707  +if 0 {
   708    708     # At time of writing, these two are broken. They demonstrate that the
   709    709     # sqlite3_preupdate_old() method does not handle the case where ALTER TABLE
   710    710     # has been used to add a column with a default value other than NULL.
   711    711     #
   712    712     do_preupdate_test 7.5.2.1 {
   713    713       DELETE FROM t8 WHERE a = 'one'
   714    714     } {

Changes to test/incrvacuum2.test.

   130    130       PRAGMA incremental_vacuum;
   131    131       COMMIT;
   132    132     }
   133    133   } {}
   134    134   
   135    135   integrity_check incrvacuum2-3.3
   136    136   
   137         -ifcapable wal {
          137  +if {[wal_is_capable]} {
   138    138     # At one point, when a specific page was being extracted from the b-tree
   139    139     # free-list (e.g. during an incremental-vacuum), all trunk pages that
   140    140     # occurred before the specific page in the free-list trunk were being
   141    141     # written to the journal or wal file. This is not necessary. Only the 
   142    142     # extracted page and the page that contains the pointer to it need to
   143    143     # be journalled.
   144    144     #

Changes to test/journal2.test.

   200    200   
   201    201   #-------------------------------------------------------------------------
   202    202   # Test that it is possible to switch from journal_mode=truncate to
   203    203   # journal_mode=WAL on a SAFE_DELETE file-system. SQLite should close and
   204    204   # delete the journal file when committing the transaction that switches
   205    205   # the system to WAL mode.
   206    206   #
   207         -ifcapable wal {
          207  +if {[wal_is_capable]} {
   208    208     do_test journal2-2.1 {
   209    209       faultsim_delete_and_reopen
   210    210       set ::oplog [list]
   211    211       execsql { PRAGMA journal_mode = persist }
   212    212       set ::oplog
   213    213     } {}
   214    214     do_test journal2-2.2 {

Changes to test/permutations.test.

   724    724     pragma journal_mode = 'memory'
   725    725   } -files [test_set $::allquicktests -exclude {
   726    726     # Exclude all tests that simulate IO errors.
   727    727     autovacuum_ioerr2.test cffault.test incrvacuum_ioerr.test ioerr.test
   728    728     ioerr.test ioerr2.test ioerr3.test ioerr4.test ioerr5.test
   729    729     vacuum3.test incrblob_err.test diskfull.test backup_ioerr.test
   730    730     e_fts3.test fts3cov.test fts3malloc.test fts3rnd.test
   731         -  fts3snippet.test mmapfault.test
          731  +  fts3snippet.test mmapfault.test sessionfault.test sessionfault2.test
   732    732   
   733    733     # Exclude test scripts that use tcl IO to access journal files or count
   734    734     # the number of fsync() calls.
   735    735     pager.test exclusive.test jrnlmode.test sync.test misc1.test 
   736    736     journal1.test conflict.test crash8.test tkt3457.test io.test
   737    737     journal3.test 8_3_names.test
   738    738   
................................................................................
   938    938   } -initialize {
   939    939     catch {db close}
   940    940     register_jt_vfs -default ""
   941    941   } -shutdown {
   942    942     unregister_jt_vfs
   943    943   } -files [test_set $::allquicktests -exclude {
   944    944     wal* incrvacuum.test ioerr.test corrupt4.test io.test crash8.test 
   945         -  async4.test bigfile.test backcompat.test
          945  +  async4.test bigfile.test backcompat.test e_wal* fstat.test mmap2.test
          946  +  pager1.test syscall.test tkt3457.test *malloc* mmap* multiplex* nolock*
          947  +  pager2.test *fault* rowal* snapshot* superlock* symlink.test
   946    948   }]
   947    949   
   948    950   if {[info commands register_demovfs] != ""} {
   949    951     test_suite "demovfs" -description {
   950    952       Check that the demovfs (code in test_demovfs.c) more or less works.
   951    953     } -initialize {
   952    954       register_demovfs
................................................................................
  1046   1048   
  1047   1049     set ::G(perm:name)         $name
  1048   1050     set ::G(perm:prefix)       $options(-prefix)
  1049   1051     set ::G(perm:presql)       $options(-presql)
  1050   1052     set ::G(isquick)           1
  1051   1053     set ::G(perm:dbconfig)     $options(-dbconfig)
  1052   1054   
  1053         -  uplevel $options(-initialize)
  1054         -
  1055   1055     foreach file [lsort $options(-files)] {
         1056  +    uplevel $options(-initialize)
  1056   1057       if {[file tail $file] == $file} { set file [file join $::testdir $file] }
  1057   1058       slave_test_file $file
         1059  +    uplevel $options(-shutdown)
  1058   1060     }
  1059   1061   
  1060         -  uplevel $options(-shutdown)
  1061         -
  1062   1062     unset ::G(perm:name)
  1063   1063     unset ::G(perm:prefix)
  1064   1064     unset ::G(perm:presql)
  1065   1065     unset ::G(perm:dbconfig)
  1066   1066   }
  1067   1067   
  1068   1068   proc run_test_suite {name} {

Changes to test/pragma3.test.

   217    217   }
   218    218   
   219    219   # Make sure this also works in WAL mode
   220    220   #
   221    221   # This will not work with the in-memory journal permutation, as opening
   222    222   # [db2] switches the journal mode back to "memory"
   223    223   #
   224         -ifcapable wal {
          224  +if {[wal_is_capable]} {
   225    225   if {[permutation]!="inmemory_journal"} {
   226    226   
   227    227     sqlite3 db test.db
   228    228     db eval {PRAGMA journal_mode=WAL}
   229    229     sqlite3 db2 test.db
   230    230     do_test pragma3-400 {
   231    231       db eval {

Changes to test/quota.test.

   523    523     catch { sqlite3_quota_shutdown }
   524    524     sqlite3_quota_initialize "" 1
   525    525   } -body {
   526    526     sqlite3_quota_set * 4096 {}
   527    527   }
   528    528   
   529    529   catch { sqlite3_quota_shutdown }
          530  +catch { db close }
          531  +forcedelete test.db
   530    532   finish_test

Changes to test/stat.test.

    33     33   register_dbstat_vtab db
    34     34   do_execsql_test stat-0.0 {
    35     35     PRAGMA auto_vacuum = OFF;
    36     36     CREATE VIRTUAL TABLE temp.stat USING dbstat;
    37     37     SELECT * FROM stat;
    38     38   } {}
    39     39   
    40         -ifcapable wal {
           40  +if {[wal_is_capable]} {
    41     41     do_execsql_test stat-0.1 {
    42     42       PRAGMA journal_mode = WAL;
    43     43       PRAGMA journal_mode = delete;
    44     44       SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload
    45     45         FROM stat;
    46     46     } {wal delete sqlite_master / 1 leaf 0 0 916 0}
    47     47   }

Changes to test/sync.test.

    77     77       INSERT INTO t2 VALUES(5,6);
    78     78       COMMIT;
    79     79     }
    80     80     cond_incr_sync_count 4
    81     81     set sqlite_sync_count
    82     82   } 11
    83     83   ifcapable pager_pragmas {
           84  +if {[permutation]!="journaltest"} {
    84     85     do_test sync-1.4 {
    85     86       set sqlite_sync_count 0
    86     87       execsql {
    87     88         PRAGMA main.synchronous=off;
    88     89         PRAGMA db2.synchronous=off;
    89     90         BEGIN;
    90     91         INSERT INTO t1 VALUES(5,6);
    91     92         INSERT INTO t2 VALUES(7,8);
    92     93         COMMIT;
    93     94       }
    94     95       set sqlite_sync_count
    95     96     } 0
           97  +}
    96     98   }
    97     99   
    98    100   
    99    101   finish_test

Changes to test/tester.tcl.

  1939   1939   }
  1940   1940   proc wal_check_journal_mode {testname {db db}} {
  1941   1941     if { [wal_is_wal_mode] } {
  1942   1942       $db eval { SELECT * FROM sqlite_master }
  1943   1943       do_test $testname [list $db eval "PRAGMA main.journal_mode"] {wal}
  1944   1944     }
  1945   1945   }
         1946  +
         1947  +proc wal_is_capable {} {
         1948  +  ifcapable !wal { return 0 }
         1949  +  if {[permutation]=="journaltest"} { return 0 }
         1950  +  return 1
         1951  +}
  1946   1952   
  1947   1953   proc permutation {} {
  1948   1954     set perm ""
  1949   1955     catch {set perm $::G(perm:name)}
  1950   1956     set perm
  1951   1957   }
  1952   1958   proc presql {} {

Changes to test/tkt-2d1a5c67d.test.

    15     15   # 
    16     16   #
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   set testprefix tkt-2d1a5c67d
    21     21   
    22         -ifcapable {!wal || !vtab} {finish_test; return}
           22  +ifcapable {!vtab} {finish_test; return}
           23  +if {[wal_is_capable]==0} {finish_test; return}
    23     24   
    24     25   for {set ii 1} {$ii<=10} {incr ii} {
    25     26     do_test tkt-2d1a5c67d.1.$ii {
    26     27       db close
    27     28       forcedelete test.db test.db-wal
    28     29       sqlite3 db test.db
    29     30       db eval "PRAGMA cache_size=$::ii"

Changes to test/tkt-313723c356.test.

    14     14   # fixed.  
    15     15   #
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   source $testdir/malloc_common.tcl
    20     20   
    21         -ifcapable !wal { finish_test ; return }
           21  +if {![wal_is_capable]} { finish_test ; return }
    22     22   
    23     23   do_execsql_test tkt-313723c356.1 {
    24     24     PRAGMA page_size = 1024;
    25     25     PRAGMA journal_mode = WAL;
    26     26     CREATE TABLE t1(a, b);
    27     27     CREATE INDEX i1 ON t1(a, b);
    28     28     INSERT INTO t1 VALUES(randomblob(400), randomblob(400));

Changes to test/tkt-5d863f876e.test.

    14     14   # fixed.  
    15     15   #
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   source $testdir/lock_common.tcl
    20     20   set ::testprefix tkt-5d863f876e
    21         -ifcapable !wal {finish_test ; return }
           21  +if {![wal_is_capable]} {finish_test ; return }
    22     22   
    23     23   do_multiclient_test tn {
    24     24     do_test $tn.1 {
    25     25       sql1 {
    26     26         CREATE TABLE t1(a, b);
    27     27         CREATE INDEX i1 ON t1(a, b);
    28     28         INSERT INTO t1 VALUES(1, 2);

Changes to test/tkt-9d68c883.test.

    46     46       sqlite3_memdebug_fail -1
    47     47   
    48     48       catchsql { ROLLBACK }
    49     49       execsql { PRAGMA integrity_check }
    50     50     } {ok}
    51     51   }
    52     52   
           53  +catch { db close } 
           54  +unregister_devsim
    53     55   finish_test

Changes to test/zerodamage.test.

    85     85     sqlite3 db file:test.db?psow=FALSE -uri 1
    86     86     db eval {
    87     87       UPDATE t1 SET y=randomblob(50) WHERE x=124;
    88     88     }
    89     89     concat [file_control_powersafe_overwrite db -1] [set ::max_journal_size]
    90     90   } {0 0 24704}
    91     91   
    92         -ifcapable wal {
           92  +if {[wal_is_capable]} {
    93     93     # Run a WAL-mode transaction with POWERSAFE_OVERWRITE on to verify that the
    94     94     # WAL file does not get too big.
    95     95     #
    96     96     do_test zerodamage-3.0 {
    97     97       db eval {
    98     98          PRAGMA journal_mode=WAL;
    99     99       }