]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Various fixes and test case updates so that veryquick.test passes again. deferred-open
authordan <dan@noemail.net>
Wed, 12 Feb 2014 15:05:05 +0000 (15:05 +0000)
committerdan <dan@noemail.net>
Wed, 12 Feb 2014 15:05:05 +0000 (15:05 +0000)
FossilOrigin-Name: f352ef57e39a9443b4bdf47fc2c9b01006fe3c10

13 files changed:
1  2 
manifest
manifest.uuid
src/os_unix.c
test/backup.test
test/backup4.test
test/incrvacuum.test
test/io.test
test/pager1.test
test/permutations.test
test/syscall.test
test/tester.tcl
test/uri.test
test/wal4.test

diff --cc manifest
index 7f2b597396a7bea56f7082bca2321b2480cfb831,19a6fafab1cded000323903998c0c260ceb71a82..fb3e8f6d5f9ee0b92b1d4a7de3c8dcd043baf2e4
+++ b/manifest
@@@ -1,5 -1,5 +1,5 @@@
- C Merge\slatest\strunk\schanges.
- D 2014-02-12T14:43:01.128
 -C Increase\sthe\sversion\snumber\sto\s3.8.4
 -D 2014-02-11T16:24:34.448
++C Various\sfixes\sand\stest\scase\supdates\sso\sthat\sveryquick.test\spasses\sagain.
++D 2014-02-12T15:05:05.674
  F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
  F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81
  F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@@ -205,7 -205,7 +205,7 @@@ F src/notify.c 976dd0f6171d4588e89e874f
  F src/os.c 1b147e4cf7cc39e618115c14a086aed44bc91ace
  F src/os.h 4a46270a64e9193af4a0aaa3bc2c66dc07c29b3f
  F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
- F src/os_unix.c d75a3d63df53542d74fd8af2f76ef7ea639cfc71
 -F src/os_unix.c 18f7f95dc6bcb9cf4d4a238d8e2de96611bc2ae5
++F src/os_unix.c c53e2683d8cc23d08f28dbecf0e3c2bcf1d1acca
  F src/os_win.c d4284f003445054a26689f1264b1b9bf7261bd1b
  F src/pager.c 0ffa313a30ed6d061d9c6601b7b175cc50a1cab7
  F src/pager.h ffd5607f7b3e4590b415b007a4382f693334d428
@@@ -336,9 -336,9 +336,9 @@@ F test/autovacuum.test 941892505d2c0f41
  F test/autovacuum_ioerr2.test 8a367b224183ad801e0e24dcb7d1501f45f244b4
  F test/avtrans.test 0252654f4295ddda3b2cce0e894812259e655a85
  F test/backcompat.test 5f8ad58b3eaebc78cd2c66c65476a42e6f32b2ad
- F test/backup.test cfac575288523288f0acfb6470b7e9cba6c16a52
 -F test/backup.test c9cdd23a495864b9edf75a9fa66f5cb7e10fcf62
++F test/backup.test 3b072335eadafa32ab940fceed5852fb48c30655
  F test/backup2.test 34986ef926ea522911a51dfdb2f8e99b7b75ebcf
- F test/backup4.test 4e3a2f9d83cdfeb4efd5dddb0dfbd06116d50957
 -F test/backup4.test 2a2e4a64388090b152de753fd9e123f28f6a3bd4
++F test/backup4.test 139a465f76d43259123d6e09281d080fccc59f8a
  F test/backup_ioerr.test 4c3c7147cee85b024ecf6e150e090c32fdbb5135
  F test/backup_malloc.test 7162d604ec2b4683c4b3799a48657fb8b5e2d450
  F test/badutf.test d5360fc31f643d37a973ab0d8b4fb85799c3169f
@@@ -602,7 -602,7 +602,7 @@@ F test/incrblob3.test d8d036fde015d4a15
  F test/incrblob4.test f26502a5697893e5acea268c910f16478c2f0fab
  F test/incrblob_err.test d2562d2771ebffd4b3af89ef64c140dd44371597
  F test/incrblobfault.test 280474078f6da9e732cd2a215d3d854969014b6e
--F test/incrvacuum.test d2a6ddf5e429720b5fe502766af747915ccf6c32
++F test/incrvacuum.test 0e0f03c3c4956de4f3b1d47fe03ea762bc9aaa83
  F test/incrvacuum2.test 379eeb8740b0ef60c372c439ad4cbea20b34bb9b
  F test/incrvacuum3.test 75256fb1377e7c39ef2de62bfc42bbff67be295a
  F test/incrvacuum_ioerr.test 6ae2f783424e47a0033304808fe27789cf93e635
@@@ -625,7 -625,7 +625,7 @@@ F test/instr.test 737bbf80685232033f3ab
  F test/intarray.test 066b7d7ac38d25bf96f87f1b017bfc687551cdd4
  F test/interrupt.test dfe9a67a94b0b2d8f70545ba1a6cca10780d71cc
  F test/intpkey.test 7506090fc08e028712a8bf47e5f54111947e3844
--F test/io.test 3a7abcef18727cc0f2399e04b0e8903eccae50f8
++F test/io.test 148556665d0f5181f510d072f434855bd40be1be
  F test/ioerr.test 2a24bd6ed5a8b062e64bfe1f6cf94fb25e92210d
  F test/ioerr2.test 9d71166f8466eda510f1af6137bdabaa82b5408d
  F test/ioerr3.test d3cec5e1a11ad6d27527d0d38573fbff14c71bdd
@@@ -725,7 -725,7 +725,7 @@@ F test/orderby3.test 8619d06a3debdcd80a
  F test/orderby4.test 4d39bfbaaa3ae64d026ca2ff166353d2edca4ba4
  F test/orderby5.test 0eb82d5890c3f3d0563966560cfdc984ea69e30c
  F test/oserror.test 50417780d0e0d7cd23cf12a8277bb44024765df3
--F test/pager1.test 1acbdb14c5952a72dd43129cabdbf69aaa3ed1fa
++F test/pager1.test c609ea28a3692d8983e945a253ebae25ad385977
  F test/pager2.test 67b8f40ae98112bcdba1f2b2d03ea83266418c71
  F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f
  F test/pager4.test a122e9e6925d5b23b31e3dfef8c6a44bbf19590e
@@@ -737,7 -737,7 +737,7 @@@ F test/pagesize.test 1dd51367e752e742f5
  F test/pcache.test b09104b03160aca0d968d99e8cd2c5b1921a993d
  F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025
  F test/percentile.test b98fc868d71eb5619d42a1702e9ab91718cbed54
- F test/permutations.test 64771d6c1cbe270acb788dfdc32ede157a627583
 -F test/permutations.test 40add071ba71aefe1c04f5845308cf46f7de8d04
++F test/permutations.test deb0e98ed7e2849fd896a39e3443b342b7feda2a
  F test/pragma.test e882183ecd21d064cec5c7aaea174fbd36293429
  F test/pragma2.test aea7b3d82c76034a2df2b38a13745172ddc0bc13
  F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552
@@@ -835,7 -835,7 +835,7 @@@ F test/subselect.test d24fd8757daf97daf
  F test/substr.test 18f57c4ca8a598805c4d64e304c418734d843c1a
  F test/superlock.test 1cde669f68d2dd37d6c9bd35eee1d95491ae3fc2
  F test/sync.test a34cd43e98b7fb84eabbf38f7ed8f7349b3f3d85
--F test/syscall.test a653783d985108c4912cc64d341ffbbb55ad2806
++F test/syscall.test 8e96912cf2e41b572d00c537ac71b9f5bb72477e
  F test/sysfault.test fa776e60bf46bdd3ae69f0b73e46ee3977a58ae6
  F test/table.test 580d23530187026d4502fae74a490f0408cf2cc7
  F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126
@@@ -844,7 -844,7 +844,7 @@@ F test/tclsqlite.test 37a61c2da7e3bfe3b
  F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c
  F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30
  F test/temptrigger.test 8ec228b0db5d7ebc4ee9b458fc28cb9e7873f5e1
--F test/tester.tcl 9bd04481b8b0ef1f2049ad01f28e175ee9a14f7b
++F test/tester.tcl cc5fc5ecfbbd90f4c100d3aaea65eb5d3b3de988
  F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5
  F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58
  F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7
@@@ -1019,7 -1019,7 +1019,7 @@@ F test/unique.test 93f8b2ef5ea51b9495f8
  F test/unixexcl.test a9870e46cc6f8390a494513d4f2bf55b5a8b3e46
  F test/unordered.test ef85ac8f2f3c93ed2b9e811b684de73175fc464c
  F test/update.test 1b6c488a8f993d090b7ee9ad0e234faa161b3aeb
--F test/uri.test 63e03df051620a18f794b4f4adcdefb3c23b6751
++F test/uri.test 6aad91f02090012a03d0545a30c7cea02c70947a
  F test/utf16align.test 54cd35a27c005a9b6e7815d887718780b6a462ae
  F test/vacuum.test ce91c39f7f91a4273bf620efad21086b5aa6ef1d
  F test/vacuum2.test af432e6e3bfc0ea20a80cb86a03c7d9876d38324
@@@ -1049,7 -1049,7 +1049,7 @@@ F test/vtab_shared.test 6acafaae7126c9f
  F test/wal.test 40073e54359d43354925b2b700b7eebd5e207285
  F test/wal2.test a8e3963abf6b232cf0b852b09b53665ef34007af
  F test/wal3.test b22eb662bcbc148c5f6d956eaf94b047f7afe9c0
--F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c
++F test/wal4.test fc104ae9670221a5326c611789c205889aebe9fa
  F test/wal5.test 8f888b50f66b78821e61ed0e233ded5de378224b
  F test/wal6.test 527581f5527bf9c24394991e2be83000aace5f9e
  F test/wal7.test 2ae8f427d240099cc4b2dfef63cff44e2a68a1bd
@@@ -1153,7 -1153,7 +1153,7 @@@ F tool/vdbe-compress.tcl 0cf56e9263a152
  F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
  F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
  F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
- P 8ef97420b2614f50de6e6d7c758483b8b888f325 0a8bcbbd4e11a60923736b2be9b1ce83ea2263fb
- R 49c6d16c122de920ce19e3016ce96465
 -P f5ad1e1bf2828c5da70c1ff944d8212036142e6f
 -R 07c665af95e97929880dcb47f3f495f9
 -U drh
 -Z 585a1fb26982d5587e4e3f114773e866
++P 4d7057c4942464b4302031a1ee9f195700c5e66d 0a8bcbbd4e11a60923736b2be9b1ce83ea2263fb
++R 4a7f56d4353f8f673e4fcc636c77fc4f
 +U dan
- Z b1935a89c2fa8977f31cb64f1fee4e2a
++Z be45f6e8774a4940e329c99165e0e8a7
diff --cc manifest.uuid
index bf4a1bedd4685410a41e7f4ccb2812df4b4615c7,a4c42c8f7f3d962e8f9044cc6ee882889424743e..45fc3ac9d9bc08aae89a5f9d5f6b4074d6709682
@@@ -1,1 -1,1 +1,1 @@@
- 4d7057c4942464b4302031a1ee9f195700c5e66d
 -0a8bcbbd4e11a60923736b2be9b1ce83ea2263fb
++f352ef57e39a9443b4bdf47fc2c9b01006fe3c10
diff --cc src/os_unix.c
index 75a567ac0b3c50db3209729573ff890921b76642,deb9e51d076fccf8364a908134ad86dcd9818d9d..116428e902f30bacf76ee13cacec8b826d59fcb3
@@@ -1443,8 -1439,6 +1443,21 @@@ static int unixFileLock(unixFile *pFile
    return rc;
  }
  
 +static int unixOpen(sqlite3_vfs*, const char*, sqlite3_file*, int, int *);
 +
++static int unixOpenAndLock(unixFile *pFile){
++  sqlite3_file *id = (sqlite3_file*)pFile;
++  int eOrigLock = pFile->eFileLock;
++  int rc;
++
++  assert( pFile->ctrlFlags & UNIXFILE_DEFERRED );
++  rc = unixOpen(pFile->pVfs, pFile->zPath, id, pFile->openFlags, 0);
++  if( rc==SQLITE_OK && eOrigLock ){
++    rc = id->pMethods->xLock(id, eOrigLock);
++  }
++  return rc;
++}
++
  /*
  ** Lock the file with the lock specified by parameter eFileLock - one
  ** of the following:
@@@ -1529,33 -1523,9 +1542,29 @@@ static int unixLock(sqlite3_file *id, i
      return SQLITE_OK;
    }
  
-     eOrigLock = pFile->eFileLock;
-     rc = unixOpen(pFile->pVfs, zPath, id, pFile->openFlags, 0);
-     if( rc==SQLITE_OK && eOrigLock ){
-       rc = unixLock(id, eOrigLock);
-     }
 +  if( pFile->ctrlFlags & UNIXFILE_DEFERRED ){
 +    const char *zPath = pFile->zPath;       /* Full-path to database file */
 +    int eOrigLock;                          /* Current lock held on pFile */
 +
 +    assert( pFile->eFileLock==SHARED_LOCK || pFile->eFileLock==NO_LOCK );
 +
 +    /* If SQLite is requesting a SHARED lock and the database file does
 +    ** not exist, return early without opening the file. */ 
 +    if( eFileLock==SHARED_LOCK && osAccess(zPath, F_OK) && errno==ENOENT ){
 +      pFile->eFileLock = SHARED_LOCK;
 +      return SQLITE_OK;
 +    }
 +
 +    /* Or, if the database file has been created or a write lock is 
 +    ** requested, open the database file now.  */
++    rc = unixOpenAndLock(pFile);
 +    if( rc!=SQLITE_OK ) return rc;
 +  }
 +  assert( (pFile->ctrlFlags & UNIXFILE_DEFERRED)==0 );
 +
    /* Make sure the locking sequence is correct.
    **  (1) We never move from unlocked to anything higher than shared lock.
 -  **  (2) SQLite never explicitly requests a pendig lock.
 +  **  (2) SQLite never explicitly requests a pending lock.
    **  (3) A shared lock is always held when a reserve lock is requested.
    */
    assert( pFile->eFileLock!=NO_LOCK || eFileLock==SHARED_LOCK );
@@@ -3326,6 -3277,6 +3335,15 @@@ static int unixWrite
    assert( id );
    assert( amt>0 );
  
++  /* SQLite never actually calls xWrite on an empty file before obtaining
++  ** a RESERVED lock on it. So the following condition is never true if 
++  ** the VFS is being used directly by SQLite. But it may be if this module
++  ** is being used in some other way. By the multiplexor VFS, for example. */
++  if( pFile->ctrlFlags & UNIXFILE_DEFERRED ){
++    int rc = unixOpenAndLock(pFile);
++    if( rc!=SQLITE_OK ) return rc;
++  }
++
    /* If this is a database file (not a journal, master-journal or temp
    ** file), the bytes in the locking range should never be read or written. */
  #if 0
@@@ -5233,10 -5176,14 +5251,7 @@@ static int fillInUnixFile
    pNew->h = h;
    pNew->pVfs = pVfs;
    pNew->zPath = zFilename;
 -  pNew->ctrlFlags = (u8)ctrlFlags;
 -#if SQLITE_MAX_MMAP_SIZE>0
 -  pNew->mmapSizeMax = sqlite3GlobalConfig.szMmap;
 -#endif
 -  if( sqlite3_uri_boolean(((ctrlFlags & UNIXFILE_URI) ? zFilename : 0),
 -                           "psow", SQLITE_POWERSAFE_OVERWRITE) ){
 -    pNew->ctrlFlags |= UNIXFILE_PSOW;
 -  }
 +  pNew->ctrlFlags = (unsigned short)ctrlFlags;
- #if SQLITE_MAX_MMAP_SIZE>0
-   pNew->mmapSizeMax = sqlite3GlobalConfig.szMmap;
- #endif
    if( strcmp(pVfs->zName,"unix-excl")==0 ){
      pNew->ctrlFlags |= UNIXFILE_EXCL;
    }
@@@ -5872,63 -5816,12 +5887,71 @@@ static int unixOpen
    rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);
  
  open_finished:
+   if( rc!=SQLITE_OK ){
+     sqlite3_free(p->pUnused);
++    p->pUnused = 0;
+   }
    return rc;
  }
  
-   if( (flags & UNIXFILE_URI) 
-    && sqlite3_uri_boolean(zPath, "psow", SQLITE_POWERSAFE_OVERWRITE) 
-   ){
 +static int unixOpenDeferred(
 +  sqlite3_vfs *pVfs,           /* The VFS for which this is the xOpen method */
 +  const char *zPath,           /* Pathname of file to be opened */
 +  sqlite3_file *pFile,         /* The file descriptor to be filled in */
 +  int flags,                   /* Input flags to control the opening */
 +  int *pOutFlags               /* Output flags returned to SQLite core */
 +){
 +  const int mask1 = SQLITE_OPEN_MAIN_DB | SQLITE_OPEN_READWRITE
 +                  | SQLITE_OPEN_CREATE;
 +  const int mask2 = SQLITE_OPEN_READONLY  | SQLITE_OPEN_DELETEONCLOSE
 +                  | SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_AUTOPROXY;
 +
 +  int rc;                         /* Return code */
 +  unixFile *p = (unixFile*)pFile; /* File object to populate */
++  const char *zUri = (flags & UNIXFILE_URI) ? zPath : 0;
 +
 +  /* Zero the file object */
 +  memset(p, 0, sizeof(unixFile));
-         p->pVfs = pVfs;
-         p->h = -1;
-         p->ctrlFlags |= UNIXFILE_DEFERRED;
-         p->openFlags = flags;
-         p->zPath = zPath;
-         if( pOutFlags ) *pOutFlags = flags;
-         OpenCounter(+1);
-         return SQLITE_OK;
++  if( sqlite3_uri_boolean(zUri, "psow", SQLITE_POWERSAFE_OVERWRITE) ){
 +    p->ctrlFlags |= UNIXFILE_PSOW;
 +  }
++#if SQLITE_MAX_MMAP_SIZE>0
++  p->mmapSizeMax = sqlite3GlobalConfig.szMmap;
++#endif
 +
 +  /* If all the flags in mask1 are set, and all the flags in mask2 are
 +  ** clear, the file does not exist but the directory does and is
 +  ** writable, then this is a deferred open.  */
 +  if( zPath && (flags & (mask1 | mask2))==mask1 ){
 +    int posixrc;
 +    posixrc = osAccess(zPath, F_OK);
 +    if( posixrc && errno==ENOENT ){
 +      char zDirname[MAX_PATHNAME+1];
 +      int i;
 +      for(i=(int)strlen(zPath); i>1 && zPath[i]!='/'; i--);
 +      memcpy(zDirname, zPath, i);
 +      zDirname[i] = '\0';
 +      posixrc = osAccess(zDirname, W_OK);
 +      if( posixrc==0 ){
 +        p->pMethod = (**(finder_type*)pVfs->pAppData)(0, 0);
++        if( p->pMethod->xLock==unixLock ){
++          p->pVfs = pVfs;
++          p->h = -1;
++          p->ctrlFlags |= UNIXFILE_DEFERRED;
++          p->openFlags = flags;
++          p->zPath = zPath;
++          if( pOutFlags ) *pOutFlags = flags;
++          OpenCounter(+1);
++          return SQLITE_OK;
++        }
 +      }
 +    }
 +  }
 +
 +  rc = unixOpen(pVfs, zPath, pFile, flags, pOutFlags);
 +  OpenCounter( rc==SQLITE_OK );
 +  return rc;
 +}
  
  /*
  ** Delete the file at zPath. If the dirSync argument is true, fsync()
Simple merge
Simple merge
index 91f5c8e1e00c7959079e191e3f0647c95f445668,91f5c8e1e00c7959079e191e3f0647c95f445668..4bae063199ea9030b44afdbdf7f7b049313c7771
@@@ -38,7 -38,7 +38,7 @@@ do_test incrvacuum-1.2.0 
    # File size is sometimes 1 instead of 0 due to the hack we put in
    # to work around ticket #3260.  Search for comments on #3260 in
    # os_unix.c.
--  expr {[file size test.db] > 1}
++  expr {[file_size test.db] > 1}
  } {0}
  do_test incrvacuum-1.2 {
    # This command will create the database.
@@@ -700,7 -700,7 +700,7 @@@ do_test incrvacuum-13.1 
    # File size is sometimes 1 instead of 0 due to the hack we put in
    # to work around ticket #3260.  Search for comments on #3260 in
    # os_unix.c.
--  expr {[file size test.db]>1}
++  expr {[file_size test.db]>1}
  } {0}
  do_test incrvacuum-13.2 {
    set ::STMT [sqlite3_prepare $::DB {PRAGMA auto_vacuum = 2} -1 DUMMY]
diff --cc test/io.test
index c5086c10ecb391cb00cb53c3eb0d3f003d05f98a,c5086c10ecb391cb00cb53c3eb0d3f003d05f98a..0a080fb734daa587c3747bf8a44da0be30e8c55c
@@@ -391,7 -391,7 +391,7 @@@ ifcapable pager_pragmas 
      }
      # File size might be 1 due to the hack to work around ticket #3260.
      # Search for #3260 in os_unix.c for additional information.
--    expr {[file size test.db]>1}
++    expr {[file_size test.db]>1}
    } {0}
    do_test io-3.2 {
      execsql { CREATE TABLE abc(a, b) }
index 005b356080dd98271b8aaf306ca8bb021d3dc4ed,005b356080dd98271b8aaf306ca8bb021d3dc4ed..cd8299a0ddeef8551731855d48574bccfb3abfc5
@@@ -1373,7 -1373,7 +1373,7 @@@ do_test pager1-9.4.1 
    list [B step 10000] [B finish]
  } {SQLITE_DONE SQLITE_OK}
  do_test pager1-9.4.2 {
--  list [file size test.db2] [file size test.db]
++  list [file_size test.db2] [file_size test.db]
  } {1024 0}
  db2 close
  
index ad087c94763dfba6aeba2f83cf19cdf922c217a6,7f1485f8315fc1b13f6414322a155b9bc99f5fda..9c908d1b8bad15bb60bc601d1e962561acba9125
@@@ -135,8 -135,7 +135,7 @@@ test_suite "veryquick" -prefix "" -desc
    This test suite is the same as the "quick" tests, except that some files
    that test malloc and IO errors are omitted.
  } -files [
-   test_set $allquicktests -exclude *malloc* *ioerr* *fault* \
-     *multiplex* *quota* walbak.test
 -  test_set $allquicktests -exclude *malloc* *ioerr* *fault*
++  test_set $allquicktests -exclude *malloc* *ioerr* *fault* 
  ]
  
  test_suite "mmap" -prefix "mm-" -description {
index 5bf12258678610c0d9e27d89491cf71b6cfacb51,5bf12258678610c0d9e27d89491cf71b6cfacb51..290e8d715400b1d0018682910fcfa54f80426b41
@@@ -236,9 -236,9 +236,10 @@@ catch { db close 
  forcedelete test.db test.db2
  
  do_test 8.1 {
++  close [open test.db w]
    sqlite3 db test.db
    file_control_chunksize_test db main 4096
--  file size test.db
++  file_size test.db
  } {0}
  foreach {tn hint size} {
    1  1000    4096 
  } {
    do_test 8.2.$tn {
      file_control_sizehint_test db main $hint
--    file size test.db
++    file_size test.db
    } $size
  }
  
  do_test 8.3 {
    db close
    forcedelete test.db test.db2
++  close [open test.db w]
    sqlite3 db test.db
    file_control_chunksize_test db main 16
    file size test.db
diff --cc test/tester.tcl
index fefd5e8a8fc631e62084b74cca2a54f4c7da4dd6,fefd5e8a8fc631e62084b74cca2a54f4c7da4dd6..e032856194c11f64f95da31a7a8097800caf1700
@@@ -185,6 -185,6 +185,16 @@@ proc forcecopy {from to} 
    do_copy_file true $from $to
  }
  
++# If file $zFile exists in the file system, return its size in bytes. 
++# Otherwise, return zero.
++proc file_size {zFile} {
++  if {[file exists $zFile]} {
++    return [file size $zFile]
++  }
++  return 0
++}
++
++
  proc do_copy_file {force from to} {
    set nRetry [getFileRetries]     ;# Maximum number of retries.
    set nDelay [getFileRetryDelay]  ;# Delay in ms before retrying.
diff --cc test/uri.test
index af1ad672508744d55b8ae73011224bfc7f2696c2,af1ad672508744d55b8ae73011224bfc7f2696c2..0ff6b933cd16076bf28478192face474b5cd433d
@@@ -76,6 -76,6 +76,7 @@@ foreach {tn uri file} 
    forcedelete $file
    do_test 1.$tn.1 { file exists $file } 0
    set DB [sqlite3_open $uri]
++  sqlite3_exec $DB {CREATE TABLE t1(x)}
    do_test 1.$tn.2 { file exists $file } 1
    sqlite3_close $DB
    forcedelete $file
@@@ -83,6 -83,6 +84,7 @@@
    do_test 1.$tn.3 { file exists $file } 0
    sqlite3 db xxx.db
    catchsql { ATTACH $uri AS aux }
++  db eval {CREATE TABLE aux.t1(x)}
    do_test 1.$tn.4 { file exists $file } 1
    db close
  }
diff --cc test/wal4.test
index c7a4381341741db00f2f2a026a4230f48b543b79,c7a4381341741db00f2f2a026a4230f48b543b79..8e6831e3f37a511d063ad109e6b12219324687eb
@@@ -56,8 -56,8 +56,8 @@@ do_faultsim_test wal4-2 -prep 
    if { $testrc==0 && [file exists test.db-wal] } { 
      error "Wal file was not deleted"
    }
--  if { [file size test.db]!=0 } { 
--    error "Db file grew to [file size test.db] bytes"
++  if { [file_size test.db]!=0 } { 
++    error "Db file grew to [file_size test.db] bytes"
    }
  }