/ Check-in [8ef97420]
Login

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

Overview
Comment:Test case updates to account for the fact that database files are not created until they are first written.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | deferred-open
Files: files | file ages | folders
SHA1: 8ef97420b2614f50de6e6d7c758483b8b888f325
User & Date: dan 2014-02-11 19:35:42
Context
2014-02-12
14:43
Merge latest trunk changes. check-in: 4d7057c4 user: dan tags: deferred-open
2014-02-11
19:35
Test case updates to account for the fact that database files are not created until they are first written. check-in: 8ef97420 user: dan tags: deferred-open
05:26
Merge latest trunk changes. check-in: 1f2e1b0c user: dan tags: deferred-open
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

  1526   1526     if( pFile->eFileLock>=eFileLock ){
  1527   1527       OSTRACE(("LOCK    %d %s ok (already held) (unix)\n", pFile->h,
  1528   1528               azFileLock(eFileLock)));
  1529   1529       return SQLITE_OK;
  1530   1530     }
  1531   1531   
  1532   1532     if( pFile->ctrlFlags & UNIXFILE_DEFERRED ){
  1533         -    int eOrigLock = pFile->eFileLock;
  1534         -    if( eFileLock==SHARED_LOCK ){
  1535         -      int statrc;
  1536         -      struct stat sBuf;
  1537         -      memset(&sBuf, 0, sizeof(sBuf));
  1538         -      statrc = osStat(pFile->zPath, &sBuf);
  1539         -      if( statrc && errno==ENOENT ){
  1540         -        pFile->eFileLock = SHARED_LOCK;
  1541         -        return SQLITE_OK;
  1542         -      }
         1533  +    const char *zPath = pFile->zPath;       /* Full-path to database file */
         1534  +    int eOrigLock;                          /* Current lock held on pFile */
         1535  +
         1536  +    assert( pFile->eFileLock==SHARED_LOCK || pFile->eFileLock==NO_LOCK );
         1537  +
         1538  +    /* If SQLite is requesting a SHARED lock and the database file does
         1539  +    ** not exist, return early without opening the file. */ 
         1540  +    if( eFileLock==SHARED_LOCK && osAccess(zPath, F_OK) && errno==ENOENT ){
         1541  +      pFile->eFileLock = SHARED_LOCK;
         1542  +      return SQLITE_OK;
  1543   1543       }
  1544   1544   
  1545         -    rc = unixOpen(pFile->pVfs, pFile->zPath, id, pFile->openFlags, 0);
         1545  +    /* Or, if the database file has been created or a write lock is 
         1546  +    ** requested, open the database file now.  */
         1547  +    eOrigLock = pFile->eFileLock;
         1548  +    rc = unixOpen(pFile->pVfs, zPath, id, pFile->openFlags, 0);
  1546   1549       if( rc==SQLITE_OK && eOrigLock ){
  1547   1550         rc = unixLock(id, eOrigLock);
  1548   1551       }
  1549   1552       if( rc!=SQLITE_OK ) return rc;
  1550   1553     }
  1551   1554     assert( (pFile->ctrlFlags & UNIXFILE_DEFERRED)==0 );
  1552   1555   
  1553   1556     /* Make sure the locking sequence is correct.
  1554   1557     **  (1) We never move from unlocked to anything higher than shared lock.
  1555         -  **  (2) SQLite never explicitly requests a pendig lock.
         1558  +  **  (2) SQLite never explicitly requests a pending lock.
  1556   1559     **  (3) A shared lock is always held when a reserve lock is requested.
  1557   1560     */
  1558   1561     assert( pFile->eFileLock!=NO_LOCK || eFileLock==SHARED_LOCK );
  1559   1562     assert( eFileLock!=PENDING_LOCK );
  1560   1563     assert( eFileLock!=RESERVED_LOCK || pFile->eFileLock==SHARED_LOCK );
  1561   1564   
  1562   1565     /* This mutex is needed because pFile->pInode is shared across threads
................................................................................
  1956   1959   static int unixClose(sqlite3_file *id){
  1957   1960     int rc = SQLITE_OK;
  1958   1961     unixFile *pFile = (unixFile *)id;
  1959   1962     verifyDbFile(pFile);
  1960   1963     unixUnlock(id, NO_LOCK);
  1961   1964     unixEnterMutex();
  1962   1965   
  1963         -  /* unixFile.pInode is always valid here. Otherwise, a different close
  1964         -  ** routine (e.g. nolockClose()) would be called instead.  */
         1966  +  /* unixFile.pInode may be NULL here if the file was never opened.
         1967  +  */
  1965   1968     assert( pFile->pInode==0 
  1966   1969          || pFile->pInode->nLock>0 
  1967   1970          || pFile->pInode->bProcessLock==0 
  1968   1971     );
  1969   1972     if( pFile->pInode ){
  1970   1973       if( pFile->pInode->nLock ){
  1971   1974         /* If there are outstanding locks, do not actually close the file just
................................................................................
  3203   3206          || offset>=PENDING_BYTE+512
  3204   3207          || offset+amt<=PENDING_BYTE 
  3205   3208     );
  3206   3209   #endif
  3207   3210   
  3208   3211     if( pFile->ctrlFlags & UNIXFILE_DEFERRED ){
  3209   3212       int rc;
  3210         -    struct stat sBuf;
  3211         -    memset(&sBuf, 0, sizeof(sBuf));
  3212         -    rc = osStat(pFile->zPath, &sBuf);
  3213         -    if( rc!=0 ){
         3213  +    if( osAccess(pFile->zPath, F_OK) && errno==ENOENT ){
  3214   3214         memset(pBuf, 0, amt);
  3215         -      rc = (errno==ENOENT ? SQLITE_IOERR_SHORT_READ : SQLITE_IOERR_FSTAT);
         3215  +      rc = SQLITE_IOERR_SHORT_READ;
  3216   3216       }else{
  3217   3217         rc = unixOpen(pFile->pVfs, pFile->zPath, id, pFile->openFlags, 0);
  3218   3218       }
  3219   3219       if( rc!=SQLITE_OK ){
  3220   3220         return rc;
  3221   3221       }
  3222   3222     }
................................................................................
  5233   5233     pNew->h = h;
  5234   5234     pNew->pVfs = pVfs;
  5235   5235     pNew->zPath = zFilename;
  5236   5236     pNew->ctrlFlags = (unsigned short)ctrlFlags;
  5237   5237   #if SQLITE_MAX_MMAP_SIZE>0
  5238   5238     pNew->mmapSizeMax = sqlite3GlobalConfig.szMmap;
  5239   5239   #endif
  5240         -  if( sqlite3_uri_boolean(((ctrlFlags & UNIXFILE_URI) ? zFilename : 0),
  5241         -                           "psow", SQLITE_POWERSAFE_OVERWRITE) ){
  5242         -    pNew->ctrlFlags |= UNIXFILE_PSOW;
  5243         -  }
  5244   5240     if( strcmp(pVfs->zName,"unix-excl")==0 ){
  5245   5241       pNew->ctrlFlags |= UNIXFILE_EXCL;
  5246   5242     }
  5247   5243   
  5248   5244   #if OS_VXWORKS
  5249   5245     pNew->pId = vxworksFindFileId(zFilename);
  5250   5246     if( pNew->pId==0 ){
................................................................................
  5375   5371       pNew->ctrlFlags |= UNIXFILE_DELETE;
  5376   5372     }
  5377   5373   #endif
  5378   5374     if( rc!=SQLITE_OK ){
  5379   5375       if( h>=0 ) robust_close(pNew, h, __LINE__);
  5380   5376     }else{
  5381   5377       pNew->pMethod = pLockingStyle;
  5382         -    OpenCounter(+1);
  5383   5378       verifyDbFile(pNew);
  5384   5379     }
  5385   5380     return rc;
  5386   5381   }
  5387   5382   
  5388   5383   /*
  5389   5384   ** Return the name of a directory in which to put temporary files.
................................................................................
  5632   5627   ){
  5633   5628     unixFile *p = (unixFile *)pFile;
  5634   5629     int fd = -1;                   /* File descriptor returned by open() */
  5635   5630     int openFlags = 0;             /* Flags to pass to open() */
  5636   5631     int eType = flags&0xFFFFFF00;  /* Type of file to open */
  5637   5632     int noLock;                    /* True to omit locking primitives */
  5638   5633     int rc = SQLITE_OK;            /* Function Return Code */
  5639         -  int ctrlFlags = 0;             /* UNIXFILE_* flags */
         5634  +  int ctrlFlags;                 /* UNIXFILE_* flags */
  5640   5635   
  5641   5636     int isExclusive  = (flags & SQLITE_OPEN_EXCLUSIVE);
  5642   5637     int isDelete     = (flags & SQLITE_OPEN_DELETEONCLOSE);
  5643   5638     int isCreate     = (flags & SQLITE_OPEN_CREATE);
  5644   5639     int isReadonly   = (flags & SQLITE_OPEN_READONLY);
  5645   5640     int isReadWrite  = (flags & SQLITE_OPEN_READWRITE);
  5646   5641   #if SQLITE_ENABLE_LOCKING_STYLE
................................................................................
  5661   5656     ));
  5662   5657   
  5663   5658     /* If argument zPath is a NULL pointer, this function is required to open
  5664   5659     ** a temporary file. Use this buffer to store the file name in.
  5665   5660     */
  5666   5661     char zTmpname[MAX_PATHNAME+2];
  5667   5662     const char *zName = zPath;
         5663  +
         5664  +  assert( p->pInode==0 && (p->h==-1 || p->h==0) );
         5665  +  p->ctrlFlags &= ~UNIXFILE_DEFERRED;
         5666  +  p->eFileLock = NO_LOCK;
         5667  +  ctrlFlags = p->ctrlFlags;
  5668   5668   
  5669   5669     /* Check the following statements are true: 
  5670   5670     **
  5671   5671     **   (a) Exactly one of the READWRITE and READONLY flags must be set, and 
  5672   5672     **   (b) if CREATE is set, then READWRITE must also be set, and
  5673   5673     **   (c) if EXCLUSIVE is set, then CREATE must also be set.
  5674   5674     **   (d) if DELETEONCLOSE is set, then CREATE must also be set.
................................................................................
  5698   5698     ** are harmless.
  5699   5699     */
  5700   5700     if( randomnessPid!=getpid() ){
  5701   5701       randomnessPid = getpid();
  5702   5702       sqlite3_randomness(0,0);
  5703   5703     }
  5704   5704   
  5705         -  memset(p, 0, sizeof(unixFile));
  5706   5705   
  5707   5706     if( eType==SQLITE_OPEN_MAIN_DB ){
  5708   5707       UnixUnusedFd *pUnused;
  5709   5708       pUnused = findReusableFd(zName, flags);
  5710   5709       if( pUnused ){
  5711   5710         fd = pUnused->fd;
  5712   5711       }else{
................................................................................
  5869   5868       }
  5870   5869     }
  5871   5870   #endif
  5872   5871     
  5873   5872     rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);
  5874   5873   
  5875   5874   open_finished:
  5876         -  if( rc!=SQLITE_OK ){
  5877         -    sqlite3_free(p->pUnused);
  5878         -  }
  5879   5875     return rc;
  5880   5876   }
  5881   5877   
  5882   5878   static int unixOpenDeferred(
  5883   5879     sqlite3_vfs *pVfs,           /* The VFS for which this is the xOpen method */
  5884   5880     const char *zPath,           /* Pathname of file to be opened */
  5885   5881     sqlite3_file *pFile,         /* The file descriptor to be filled in */
................................................................................
  5886   5882     int flags,                   /* Input flags to control the opening */
  5887   5883     int *pOutFlags               /* Output flags returned to SQLite core */
  5888   5884   ){
  5889   5885     const int mask1 = SQLITE_OPEN_MAIN_DB | SQLITE_OPEN_READWRITE
  5890   5886                     | SQLITE_OPEN_CREATE;
  5891   5887     const int mask2 = SQLITE_OPEN_READONLY  | SQLITE_OPEN_DELETEONCLOSE
  5892   5888                     | SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_AUTOPROXY;
         5889  +
         5890  +  int rc;                         /* Return code */
         5891  +  unixFile *p = (unixFile*)pFile; /* File object to populate */
         5892  +
         5893  +  /* Zero the file object */
         5894  +  memset(p, 0, sizeof(unixFile));
         5895  +  if( (flags & UNIXFILE_URI) 
         5896  +   && sqlite3_uri_boolean(zPath, "psow", SQLITE_POWERSAFE_OVERWRITE) 
         5897  +  ){
         5898  +    p->ctrlFlags |= UNIXFILE_PSOW;
         5899  +  }
  5893   5900   
  5894   5901     /* If all the flags in mask1 are set, and all the flags in mask2 are
  5895   5902     ** clear, the file does not exist but the directory does and is
  5896   5903     ** writable, then this is a deferred open.  */
  5897         -  if( 0 && zPath && (flags & (mask1 | mask2))==mask1 ){
         5904  +  if( zPath && (flags & (mask1 | mask2))==mask1 ){
  5898   5905       int posixrc;
  5899   5906       posixrc = osAccess(zPath, F_OK);
  5900   5907       if( posixrc && errno==ENOENT ){
  5901   5908         char zDirname[MAX_PATHNAME+1];
  5902   5909         int i;
  5903   5910         for(i=(int)strlen(zPath); i>1 && zPath[i]!='/'; i--);
  5904   5911         memcpy(zDirname, zPath, i);
  5905   5912         zDirname[i] = '\0';
  5906   5913         posixrc = osAccess(zDirname, W_OK);
  5907   5914         if( posixrc==0 ){
  5908         -        unixFile *p = (unixFile*)pFile;
  5909         -        memset(p, 0, sizeof(unixFile));
  5910   5915           p->pMethod = (**(finder_type*)pVfs->pAppData)(0, 0);
  5911   5916           p->pVfs = pVfs;
  5912   5917           p->h = -1;
  5913         -        p->ctrlFlags = UNIXFILE_DEFERRED;
  5914         -        if( sqlite3_uri_boolean(((flags & UNIXFILE_URI) ? zPath : 0),
  5915         -                           "psow", SQLITE_POWERSAFE_OVERWRITE) ){
  5916         -          p->ctrlFlags |= UNIXFILE_PSOW;
  5917         -        }
         5918  +        p->ctrlFlags |= UNIXFILE_DEFERRED;
  5918   5919           p->openFlags = flags;
  5919   5920           p->zPath = zPath;
  5920   5921           if( pOutFlags ) *pOutFlags = flags;
         5922  +        OpenCounter(+1);
  5921   5923           return SQLITE_OK;
  5922   5924         }
  5923   5925       }
  5924   5926     }
  5925         -  return unixOpen(pVfs, zPath, pFile, flags, pOutFlags);
         5927  +
         5928  +  rc = unixOpen(pVfs, zPath, pFile, flags, pOutFlags);
         5929  +  OpenCounter( rc==SQLITE_OK );
         5930  +  return rc;
  5926   5931   }
  5927   5932   
  5928   5933   /*
  5929   5934   ** Delete the file at zPath. If the dirSync argument is true, fsync()
  5930   5935   ** the directory after deleting the file.
  5931   5936   */
  5932   5937   static int unixDelete(

Changes to test/backup.test.

   320    320   
   321    321     db close
   322    322     db2 close
   323    323     incr iTest
   324    324   }
   325    325   }
   326    326   }
          327  +
          328  +proc file_size {zFile} {
          329  +  if {[file exists $zFile]} {
          330  +    return [file size $zFile]
          331  +  }
          332  +  return 0
          333  +}
   327    334   
   328    335   #--------------------------------------------------------------------
   329    336   do_test backup-3.$iTest.1 {
   330    337     catch { forcedelete test.db }
   331    338     catch { forcedelete test2.db }
   332    339     sqlite3 db test.db
   333    340     set iTab 1
   334    341   
   335    342     db eval { PRAGMA page_size = 512 }
   336         -  while {[file size test.db] <= $::sqlite_pending_byte} {
          343  +  while {[file_size test.db] <= $::sqlite_pending_byte} {
   337    344       db eval "CREATE TABLE t${iTab}(a, b, c)"
   338    345       incr iTab
   339    346     }
   340    347   
   341    348     sqlite3 db2 test2.db
   342    349     db2 eval { PRAGMA page_size = 4096 }
   343         -  while {[file size test2.db] < $::sqlite_pending_byte} {
          350  +  while {[file_size test2.db] < $::sqlite_pending_byte} {
   344    351       db2 eval "CREATE TABLE t${iTab}(a, b, c)"
   345    352       incr iTab
   346    353     }
   347    354   
   348    355     sqlite3_backup B db2 main db main
   349    356     B step -1
   350    357   } {SQLITE_DONE}

Changes to test/backup4.test.

    18     18   # schema cookie and change counter. Doing that could cause other clients
    19     19   # to become confused and continue using out-of-date cache data.
    20     20   #
    21     21   
    22     22   set testdir [file dirname $argv0]
    23     23   source $testdir/tester.tcl
    24     24   set testprefix backup4
           25  +
           26  +proc file_size {zFile} {
           27  +  if {[file exists $zFile]} {
           28  +    return [file size $zFile]
           29  +  }
           30  +  return 0
           31  +}
    25     32   
    26     33   #-------------------------------------------------------------------------
    27     34   # At one point this test was failing because [db] was using an out of
    28     35   # date schema in test case 1.2.
    29     36   #
    30     37   do_execsql_test 1.0 {
    31     38     CREATE TABLE t1(x, y, UNIQUE(x, y));
................................................................................
    68     75   do_test 2.3 {
    69     76     sqlite3 db1 test.db2
    70     77     db1 backup test.db
    71     78     db1 close
    72     79     file size test.db
    73     80   } {1024}
    74     81   
    75         -do_test 2.4 { file size test.db2 } 0
           82  +do_test 2.4 { file_size test.db2 } 0
    76     83   
    77     84   db close
    78     85   forcedelete test.db
    79     86   forcedelete test.db2
    80     87   sqlite3 db test.db
    81     88   
    82     89   #-------------------------------------------------------------------------
................................................................................
    94    101   do_test 3.3 {
    95    102     sqlite3 db1 test.db2
    96    103     db1 backup test.db
    97    104     db1 close
    98    105     file size test.db
    99    106   } {1024}
   100    107   
   101         -do_test 3.4 { file size test.db2 } 0
          108  +do_test 3.4 { file_size test.db2 } 0
   102    109   
   103    110   finish_test

Changes to test/capi3e.test.

    66     66   foreach name $names {
    67     67     incr i
    68     68     do_test capi3e-1.1.$i {
    69     69       set db2 [sqlite3_open $name {}]
    70     70       sqlite3_errcode $db2
    71     71     } {SQLITE_OK}
    72     72     do_test capi3e-1.2.$i {
           73  +    sqlite3_exec $db2 { CREATE TABLE t1(x) }
           74  +  } {0 {}}
           75  +  do_test capi3e-1.3.$i {
    73     76       sqlite3_close $db2
    74     77     } {SQLITE_OK}
    75         -  do_test capi3e-1.3.$i {
           78  +  do_test capi3e-1.4.$i {
    76     79       file isfile $name
    77     80     } {1}
    78     81   }
    79     82   
    80     83   ifcapable {utf16} {
    81     84     set i 0
    82     85     foreach name $names {

Changes to test/e_uri.test.

    60     60     # Tests with SQLITE_CONFIG_URI configured to false. URI intepretation is
    61     61     # only enabled if the SQLITE_OPEN_URI flag is specified.
    62     62     sqlite3_shutdown
    63     63     sqlite3_config_uri 0
    64     64     do_test 1.1 {
    65     65       forcedelete file:test.db test.db
    66     66       set DB [sqlite3_open_v2 file:test.db [concat $flags SQLITE_OPEN_URI] ""]
           67  +    sqlite3_exec $DB {CREATE TABLE t1(x)}
    67     68       list [file exists file:test.db] [file exists test.db]
    68     69     } {0 1}
    69     70     do_test 1.2 {
    70     71       forcedelete file:test.db2 test.db2
    71     72       set STMT [sqlite3_prepare $DB "ATTACH 'file:test.db2' AS aux" -1 dummy]
    72     73       sqlite3_step $STMT
    73     74       sqlite3_finalize $STMT
           75  +    sqlite3_exec $DB {CREATE TABLE aux.t1(x)}
    74     76       list [file exists file:test.db2] [file exists test.db2]
    75     77     } {0 1}
    76     78     sqlite3_close $DB
    77     79     do_test 1.3 {
    78     80       forcedelete file:test.db test.db
    79     81       set DB [sqlite3_open_v2 file:test.db [concat $flags] ""]
           82  +    sqlite3_exec $DB {CREATE TABLE t1(x)}
    80     83       list [file exists file:test.db] [file exists test.db]
    81     84     } {1 0}
    82     85     do_test 1.4 {
    83     86       forcedelete file:test.db2 test.db2
    84     87       set STMT [sqlite3_prepare $DB "ATTACH 'file:test.db2' AS aux" -1 dummy]
    85     88       sqlite3_step $STMT
    86     89       sqlite3_finalize $STMT
           90  +    sqlite3_exec $DB {CREATE TABLE aux.t1(x)}
    87     91       list [file exists file:test.db2] [file exists test.db2]
    88     92     } {1 0}
    89     93     sqlite3_close $DB
    90     94   
    91     95     # Tests with SQLITE_CONFIG_URI configured to true. URI intepretation is
    92     96     # enabled with or without SQLITE_OPEN_URI.
    93     97     #
    94     98     sqlite3_shutdown
    95     99     sqlite3_config_uri 1
    96    100     do_test 1.5 {
    97    101       forcedelete file:test.db test.db
    98    102       set DB [sqlite3_open_v2 file:test.db [concat $flags SQLITE_OPEN_URI] ""]
          103  +    sqlite3_exec $DB {CREATE TABLE t1(x)}
    99    104       list [file exists file:test.db] [file exists test.db]
   100    105     } {0 1}
   101    106     do_test 1.6 {
   102    107       forcedelete file:test.db2 test.db2
   103    108       set STMT [sqlite3_prepare $DB "ATTACH 'file:test.db2' AS aux" -1 dummy]
   104    109       sqlite3_step $STMT
   105    110       sqlite3_finalize $STMT
          111  +    sqlite3_exec $DB {CREATE TABLE aux.t1(x)}
   106    112       list [file exists file:test.db2] [file exists test.db2]
   107    113     } {0 1}
   108    114     sqlite3_close $DB
   109    115     do_test 1.7 {
   110    116       forcedelete file:test.db test.db
   111    117       set DB [sqlite3_open_v2 file:test.db [concat $flags] ""]
          118  +    sqlite3_exec $DB {CREATE TABLE t1(x)}
   112    119       list [file exists file:test.db] [file exists test.db]
   113    120     } {0 1}
   114    121     do_test 1.8 {
   115    122       forcedelete file:test.db2 test.db2
   116    123       set STMT [sqlite3_prepare $DB "ATTACH 'file:test.db2' AS aux" -1 dummy]
   117    124       sqlite3_step $STMT
   118    125       sqlite3_finalize $STMT
          126  +    sqlite3_exec $DB {CREATE TABLE aux.t1(x)}
   119    127       list [file exists file:test.db2] [file exists test.db2]
   120    128     } {0 1}
   121    129     sqlite3_close $DB
   122    130   }
   123    131   
   124    132   # ensure uri processing enabled for the rest of the tests
   125    133   sqlite3_shutdown
................................................................................
   310    318   
   311    319   # EVIDENCE-OF: R-20590-08726 It is an error to specify a value for the
   312    320   # mode parameter that is less restrictive than that specified by the
   313    321   # flags passed in the third parameter to sqlite3_open_v2().
   314    322   #
   315    323   forcedelete test.db
   316    324   sqlite3 db test.db
          325  +db eval {CREATE TABLE t1(x)}
   317    326   db close
   318    327   foreach {tn uri flags error} {
   319    328     1   {file:test.db?mode=ro}   ro    {not an error}
   320    329     2   {file:test.db?mode=ro}   rw    {not an error}
   321    330     3   {file:test.db?mode=ro}   rwc   {not an error}
   322    331   
   323    332     4   {file:test.db?mode=rw}   ro    {access mode not allowed: rw}
................................................................................
   327    336     7   {file:test.db?mode=rwc}  ro    {access mode not allowed: rwc}
   328    337     8   {file:test.db?mode=rwc}  rw    {access mode not allowed: rwc}
   329    338     9   {file:test.db?mode=rwc}  rwc   {not an error}
   330    339   } {
   331    340     set f(ro)  [list SQLITE_OPEN_READONLY SQLITE_OPEN_URI]
   332    341     set f(rw)  [list SQLITE_OPEN_READWRITE SQLITE_OPEN_URI]
   333    342     set f(rwc) [list SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_URI]
   334         -
          343  +breakpoint
   335    344     set DB [sqlite3_open_v2 $uri $f($flags) ""]
   336    345     set e [sqlite3_errmsg $DB]
   337    346     sqlite3_close $DB
   338    347   
   339    348     do_test 9.$tn { set e } $error
   340    349   }
   341    350   

Changes to test/exclusive2.test.

    65     65     incr ret [expr ($d&0x000000FF)<<0]
    66     66   
    67     67     if {$needClose} {close $fd}
    68     68     return $ret
    69     69   }
    70     70   
    71     71   proc readPagerChangeCounter {filename} {
    72         -  set fd [open $filename RDONLY]
    73         -  fconfigure $fd -translation binary -encoding binary
    74         -
    75         -  seek $fd 24
    76         -  foreach {a b c d} [list 0 0 0 0] {}
    77         -  binary scan [read $fd 4] cccc a b c d
    78         -  set  ret [expr ($a&0x000000FF)<<24]
    79         -  incr ret [expr ($b&0x000000FF)<<16]
    80         -  incr ret [expr ($c&0x000000FF)<<8]
    81         -  incr ret [expr ($d&0x000000FF)<<0]
    82         -
    83         -  close $fd
           72  +  if {[file exists $filename]} {
           73  +    set fd [open $filename RDONLY]
           74  +    fconfigure $fd -translation binary -encoding binary
           75  +    seek $fd 24
           76  +    foreach {a b c d} [list 0 0 0 0] {}
           77  +    binary scan [read $fd 4] cccc a b c d
           78  +    set  ret [expr ($a&0x000000FF)<<24]
           79  +    incr ret [expr ($b&0x000000FF)<<16]
           80  +    incr ret [expr ($c&0x000000FF)<<8]
           81  +    incr ret [expr ($d&0x000000FF)<<0]
           82  +    close $fd
           83  +  } else {
           84  +    set ret 0
           85  +  }
    84     86     return $ret
    85     87   }
    86     88   
    87     89   
    88     90   proc t1sig {{db db}} {
    89     91     execsql {SELECT count(*), md5sum(a) FROM t1} $db
    90     92   }

Changes to test/tkt4018.test.

    42     42     }
    43     43   } {}
    44     44   
    45     45   # The database is locked by connection [db]. Open and close a second
    46     46   # connection to test.db 10000 times. If file-descriptors are not being
    47     47   # reused, then the process will quickly exceed its maximum number of
    48     48   # file descriptors (1024 by default on linux).
           49  +breakpoint
    49     50   do_test tkt4018-1.2 {
    50     51     for {set i 0} {$i < 10000} {incr i} {
    51     52       sqlite3 db2 test.db
    52     53       db2 close
    53     54     }
    54     55   } {}
    55     56