SQLite

Check-in [f352ef57e3]
Login

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

Overview
Comment:Various fixes and test case updates so that veryquick.test passes again.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | deferred-open
Files: files | file ages | folders
SHA1: f352ef57e39a9443b4bdf47fc2c9b01006fe3c10
User & Date: dan 2014-02-12 15:05:05.674
Context
2014-02-12
15:05
Various fixes and test case updates so that veryquick.test passes again. (Leaf check-in: f352ef57e3 user: dan tags: deferred-open)
14:43
Merge latest trunk changes. (check-in: 4d7057c494 user: dan tags: deferred-open)
2014-02-11
16:24
Increase the version number to 3.8.4 (check-in: 0a8bcbbd4e user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/os_unix.c.
1440
1441
1442
1443
1444
1445
1446













1447
1448
1449
1450
1451
1452
1453
  }else{
    rc = osFcntl(pFile->h, F_SETLK, pLock);
  }
  return rc;
}

static int unixOpen(sqlite3_vfs*, const char*, sqlite3_file*, int, int *);














/*
** Lock the file with the lock specified by parameter eFileLock - one
** of the following:
**
**     (1) SHARED_LOCK
**     (2) RESERVED_LOCK







>
>
>
>
>
>
>
>
>
>
>
>
>







1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
  }else{
    rc = osFcntl(pFile->h, F_SETLK, pLock);
  }
  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:
**
**     (1) SHARED_LOCK
**     (2) RESERVED_LOCK
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
    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.  */
    eOrigLock = pFile->eFileLock;
    rc = unixOpen(pFile->pVfs, zPath, id, pFile->openFlags, 0);
    if( rc==SQLITE_OK && eOrigLock ){
      rc = unixLock(id, eOrigLock);
    }
    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 pending lock.







<
<
<
|
<







1553
1554
1555
1556
1557
1558
1559



1560

1561
1562
1563
1564
1565
1566
1567
    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 pending lock.
3321
3322
3323
3324
3325
3326
3327









3328
3329
3330
3331
3332
3333
3334
  int amt,
  sqlite3_int64 offset 
){
  unixFile *pFile = (unixFile*)id;
  int wrote = 0;
  assert( id );
  assert( amt>0 );










  /* 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
  assert( pFile->pUnused==0
       || offset>=PENDING_BYTE+512
       || offset+amt<=PENDING_BYTE 







>
>
>
>
>
>
>
>
>







3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
  int amt,
  sqlite3_int64 offset 
){
  unixFile *pFile = (unixFile*)id;
  int wrote = 0;
  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
  assert( pFile->pUnused==0
       || offset>=PENDING_BYTE+512
       || offset+amt<=PENDING_BYTE 
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
  assert( zFilename!=0 || (ctrlFlags & UNIXFILE_NOLOCK)!=0 );

  OSTRACE(("OPEN    %-3d %s\n", h, zFilename));
  pNew->h = h;
  pNew->pVfs = pVfs;
  pNew->zPath = zFilename;
  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;
  }

#if OS_VXWORKS
  pNew->pId = vxworksFindFileId(zFilename);
  if( pNew->pId==0 ){







<
<
<







5248
5249
5250
5251
5252
5253
5254



5255
5256
5257
5258
5259
5260
5261
  assert( zFilename!=0 || (ctrlFlags & UNIXFILE_NOLOCK)!=0 );

  OSTRACE(("OPEN    %-3d %s\n", h, zFilename));
  pNew->h = h;
  pNew->pVfs = pVfs;
  pNew->zPath = zFilename;
  pNew->ctrlFlags = (unsigned short)ctrlFlags;



  if( strcmp(pVfs->zName,"unix-excl")==0 ){
    pNew->ctrlFlags |= UNIXFILE_EXCL;
  }

#if OS_VXWORKS
  pNew->pId = vxworksFindFileId(zFilename);
  if( pNew->pId==0 ){
5868
5869
5870
5871
5872
5873
5874




5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891

5892
5893
5894
5895
5896
5897
5898
5899



5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915

5916
5917
5918
5919
5920
5921
5922
5923

5924
5925
5926
5927
5928
5929
5930
    }
  }
#endif
  
  rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);

open_finished:




  return rc;
}

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 */


  /* Zero the file object */
  memset(p, 0, sizeof(unixFile));
  if( (flags & UNIXFILE_URI) 
   && sqlite3_uri_boolean(zPath, "psow", SQLITE_POWERSAFE_OVERWRITE) 
  ){
    p->ctrlFlags |= UNIXFILE_PSOW;
  }




  /* 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);

        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;







>
>
>
>

















>



<
|
<


>
>
>
















>
|
|
|
|
|
|
|
|
>







5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914

5915

5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
    }
  }
#endif
  
  rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);

open_finished:
  if( rc!=SQLITE_OK ){
    sqlite3_free(p->pUnused);
    p->pUnused = 0;
  }
  return rc;
}

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));

  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;
Changes to test/backup.test.
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
  db close
  db2 close
  incr iTest
}
}
}

proc file_size {zFile} {
  if {[file exists $zFile]} {
    return [file size $zFile]
  }
  return 0
}

#--------------------------------------------------------------------
do_test backup-3.$iTest.1 {
  catch { forcedelete test.db }
  catch { forcedelete test2.db }
  sqlite3 db test.db
  set iTab 1








<
<
<
<
<
<
<







321
322
323
324
325
326
327







328
329
330
331
332
333
334
  db close
  db2 close
  incr iTest
}
}
}








#--------------------------------------------------------------------
do_test backup-3.$iTest.1 {
  catch { forcedelete test.db }
  catch { forcedelete test2.db }
  sqlite3 db test.db
  set iTab 1

Changes to test/backup4.test.
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# to become confused and continue using out-of-date cache data.
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix backup4

proc file_size {zFile} {
  if {[file exists $zFile]} {
    return [file size $zFile]
  }
  return 0
}

#-------------------------------------------------------------------------
# At one point this test was failing because [db] was using an out of
# date schema in test case 1.2.
#
do_execsql_test 1.0 {
  CREATE TABLE t1(x, y, UNIQUE(x, y));
  INSERT INTO t1 VALUES('one', 'two');







<
<
<
<
<
<
<







19
20
21
22
23
24
25







26
27
28
29
30
31
32
# to become confused and continue using out-of-date cache data.
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix backup4








#-------------------------------------------------------------------------
# At one point this test was failing because [db] was using an out of
# date schema in test case 1.2.
#
do_execsql_test 1.0 {
  CREATE TABLE t1(x, y, UNIQUE(x, y));
  INSERT INTO t1 VALUES('one', 'two');
Changes to test/incrvacuum.test.
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
    pragma auto_vacuum;
  }
} $sqlite_options(default_autovacuum)
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}
} {0}
do_test incrvacuum-1.2 {
  # This command will create the database.
  execsql {
    pragma auto_vacuum = 'full';
    pragma auto_vacuum;
  }







|







34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
    pragma auto_vacuum;
  }
} $sqlite_options(default_autovacuum)
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}
} {0}
do_test incrvacuum-1.2 {
  # This command will create the database.
  execsql {
    pragma auto_vacuum = 'full';
    pragma auto_vacuum;
  }
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
sqlite3 db test.db  ;  set ::DB [sqlite3_connection_pointer db]
sqlite3 db2 test.db

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}
} {0}
do_test incrvacuum-13.2 {
  set ::STMT [sqlite3_prepare $::DB {PRAGMA auto_vacuum = 2} -1 DUMMY]
  execsql {
    PRAGMA auto_vacuum = none;
    PRAGMA default_cache_size = 1024;
    PRAGMA auto_vacuum;







|







696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
sqlite3 db test.db  ;  set ::DB [sqlite3_connection_pointer db]
sqlite3 db2 test.db

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}
} {0}
do_test incrvacuum-13.2 {
  set ::STMT [sqlite3_prepare $::DB {PRAGMA auto_vacuum = 2} -1 DUMMY]
  execsql {
    PRAGMA auto_vacuum = none;
    PRAGMA default_cache_size = 1024;
    PRAGMA auto_vacuum;
Changes to test/io.test.
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
    forcedelete test.db test.db-journal
    sqlite3 db test.db -vfs devsym
    db eval {
      PRAGMA auto_vacuum=OFF;
    }
    # 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}
  } {0}
  do_test io-3.2 {
    execsql { CREATE TABLE abc(a, b) }
    nSync
    execsql {
      PRAGMA temp_store = memory;
      PRAGMA cache_size = 10;







|







387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
    forcedelete test.db test.db-journal
    sqlite3 db test.db -vfs devsym
    db eval {
      PRAGMA auto_vacuum=OFF;
    }
    # 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}
  } {0}
  do_test io-3.2 {
    execsql { CREATE TABLE abc(a, b) }
    nSync
    execsql {
      PRAGMA temp_store = memory;
      PRAGMA cache_size = 10;
Changes to test/pager1.test.
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
    CREATE TABLE t1(a, b);
    CREATE TABLE t2(a, b);
  } db2
  sqlite3_backup B db2 main db main
  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]
} {1024 0}
db2 close

#-------------------------------------------------------------------------
# Test that regardless of the value returned by xSectorSize(), the
# minimum effective sector-size is 512 and the maximum 65536 bytes.
#







|







1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
    CREATE TABLE t1(a, b);
    CREATE TABLE t2(a, b);
  } db2
  sqlite3_backup B db2 main db main
  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]
} {1024 0}
db2 close

#-------------------------------------------------------------------------
# Test that regardless of the value returned by xSectorSize(), the
# minimum effective sector-size is 512 and the maximum 65536 bytes.
#
Changes to test/permutations.test.
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
lappend ::testsuitelist xxx

test_suite "veryquick" -prefix "" -description {
  "Very" quick test suite. Runs in less than 5 minutes on a workstation. 
  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_suite "mmap" -prefix "mm-" -description {
  Similar to veryquick. Except with memory mapping disabled.
} -presql {
  pragma mmap_size = 268435456;
} -files [







|
<







131
132
133
134
135
136
137
138

139
140
141
142
143
144
145
lappend ::testsuitelist xxx

test_suite "veryquick" -prefix "" -description {
  "Very" quick test suite. Runs in less than 5 minutes on a workstation. 
  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* 

]

test_suite "mmap" -prefix "mm-" -description {
  Similar to veryquick. Except with memory mapping disabled.
} -presql {
  pragma mmap_size = 268435456;
} -files [
Changes to test/syscall.test.
232
233
234
235
236
237
238

239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258

259
260
261
262
263
264
265

#-------------------------------------------------------------------------
# 
catch { db close }
forcedelete test.db test.db2

do_test 8.1 {

  sqlite3 db test.db
  file_control_chunksize_test db main 4096
  file size test.db
} {0}
foreach {tn hint size} {
  1  1000    4096 
  2  1000    4096 
  3  3000    4096 
  4  4096    4096 
  5  4197    8192 
} {
  do_test 8.2.$tn {
    file_control_sizehint_test db main $hint
    file size test.db
  } $size
}

do_test 8.3 {
  db close
  forcedelete test.db test.db2

  sqlite3 db test.db
  file_control_chunksize_test db main 16
  file size test.db
} {0}
foreach {tn hint size} {
  1  5       16 
  2  13      16 







>


|










|






>







232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267

#-------------------------------------------------------------------------
# 
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
} {0}
foreach {tn hint size} {
  1  1000    4096 
  2  1000    4096 
  3  3000    4096 
  4  4096    4096 
  5  4197    8192 
} {
  do_test 8.2.$tn {
    file_control_sizehint_test db main $hint
    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
} {0}
foreach {tn hint size} {
  1  5       16 
  2  13      16 
Changes to test/tester.tcl.
180
181
182
183
184
185
186










187
188
189
190
191
192
193
proc copy_file {from to} {
  do_copy_file false $from $to
}

proc forcecopy {from to} {
  do_copy_file true $from $to
}











proc do_copy_file {force from to} {
  set nRetry [getFileRetries]     ;# Maximum number of retries.
  set nDelay [getFileRetryDelay]  ;# Delay in ms before retrying.

  # On windows, sometimes even a [file copy -force] can fail. The cause is
  # usually "tag-alongs" - programs like anti-virus software, automatic backup







>
>
>
>
>
>
>
>
>
>







180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
proc copy_file {from to} {
  do_copy_file false $from $to
}

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.

  # On windows, sometimes even a [file copy -force] can fail. The cause is
  # usually "tag-alongs" - programs like anti-virus software, automatic backup
Changes to test/uri.test.
72
73
74
75
76
77
78

79
80
81
82
83
84
85

86
87
88
89
90
91
92
    set uri  [string map [list PWD/ [test_pwd /]] $uri]
  }

  if {[file isdir $file]} {error "$file is a directory"}
  forcedelete $file
  do_test 1.$tn.1 { file exists $file } 0
  set DB [sqlite3_open $uri]

  do_test 1.$tn.2 { file exists $file } 1
  sqlite3_close $DB
  forcedelete $file

  do_test 1.$tn.3 { file exists $file } 0
  sqlite3 db xxx.db
  catchsql { ATTACH $uri AS aux }

  do_test 1.$tn.4 { file exists $file } 1
  db close
}

#-------------------------------------------------------------------------
# Test that URI query parameters are passed through to the VFS layer
# correctly.







>







>







72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
    set uri  [string map [list PWD/ [test_pwd /]] $uri]
  }

  if {[file isdir $file]} {error "$file is a directory"}
  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

  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
}

#-------------------------------------------------------------------------
# Test that URI query parameters are passed through to the VFS layer
# correctly.
Changes to test/wal4.test.
52
53
54
55
56
57
58
59
60
61
62
63
64
  # deleted. In no case should the database file have been written, so
  # it should still be zero bytes in size regardless of whether or not
  # a fault was injected. Test these assertions:
  #
  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"
  }
}

finish_test







|
|




52
53
54
55
56
57
58
59
60
61
62
63
64
  # deleted. In no case should the database file have been written, so
  # it should still be zero bytes in size regardless of whether or not
  # a fault was injected. Test these assertions:
  #
  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"
  }
}

finish_test