SQLite

Check-in [2ef8b85db7]
Login

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

Overview
Comment:Get I/O error tests working on windows. (CVS 3007)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2ef8b85db7607eb0989c5ecf49cc554fa13d894f
User & Date: drh 2006-01-23 16:25:22.000
Context
2006-01-23
17:43
Bug fix in the ROWID generation logic of the VDBE. I think this is a benign bug - it never causes a real fault. But I am not certain. (CVS 3008) (check-in: dfe2823868 user: drh tags: trunk)
16:25
Get I/O error tests working on windows. (CVS 3007) (check-in: 2ef8b85db7 user: drh tags: trunk)
16:24
Fix uninitialized variable in os_unix.c. (CVS 3006) (check-in: 892e644d20 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/os_win.c.
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
      *pReadonly = 1;
    }else{
      *pReadonly = 0;
    }
#endif /* OS_WINCE */
  }
  f.h = h;
  f.locktype = NO_LOCK;
  f.sharedLockByte = 0;
#if OS_WINCE
  f.zDeleteOnClose = 0;
#endif
  TRACE3("OPEN R/W %d \"%s\"\n", h, zFilename);
  return allocateWinFile(&f, pId);
}








<
<







599
600
601
602
603
604
605


606
607
608
609
610
611
612
      *pReadonly = 1;
    }else{
      *pReadonly = 0;
    }
#endif /* OS_WINCE */
  }
  f.h = h;


#if OS_WINCE
  f.zDeleteOnClose = 0;
#endif
  TRACE3("OPEN R/W %d \"%s\"\n", h, zFilename);
  return allocateWinFile(&f, pId);
}

663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
    );
#endif /* OS_WINCE */
  }
  if( h==INVALID_HANDLE_VALUE ){
    return SQLITE_CANTOPEN;
  }
  f.h = h;
  f.locktype = NO_LOCK;
  f.sharedLockByte = 0;
#if OS_WINCE
  f.zDeleteOnClose = delFlag ? utf8ToUnicode(zFilename) : 0;
  f.hMutex = NULL;
#endif
  TRACE3("OPEN EX %d \"%s\"\n", h, zFilename);
  return allocateWinFile(&f, pId);
}

/*
** Attempt to open a new file for read-only access.







<
<


<







661
662
663
664
665
666
667


668
669

670
671
672
673
674
675
676
    );
#endif /* OS_WINCE */
  }
  if( h==INVALID_HANDLE_VALUE ){
    return SQLITE_CANTOPEN;
  }
  f.h = h;


#if OS_WINCE
  f.zDeleteOnClose = delFlag ? utf8ToUnicode(zFilename) : 0;

#endif
  TRACE3("OPEN EX %d \"%s\"\n", h, zFilename);
  return allocateWinFile(&f, pId);
}

/*
** Attempt to open a new file for read-only access.
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
    );
#endif
  }
  if( h==INVALID_HANDLE_VALUE ){
    return SQLITE_CANTOPEN;
  }
  f.h = h;
  f.locktype = NO_LOCK;
  f.sharedLockByte = 0;
#if OS_WINCE
  f.zDeleteOnClose = 0;
  f.hMutex = NULL;
#endif
  TRACE3("OPEN RO %d \"%s\"\n", h, zFilename);
  return allocateWinFile(&f, pId);
}

/*
** Attempt to open a file descriptor for the directory that contains a







<
<


<







708
709
710
711
712
713
714


715
716

717
718
719
720
721
722
723
    );
#endif
  }
  if( h==INVALID_HANDLE_VALUE ){
    return SQLITE_CANTOPEN;
  }
  f.h = h;


#if OS_WINCE
  f.zDeleteOnClose = 0;

#endif
  TRACE3("OPEN RO %d \"%s\"\n", h, zFilename);
  return allocateWinFile(&f, pId);
}

/*
** Attempt to open a file descriptor for the directory that contains a
1304
1305
1306
1307
1308
1309
1310





1311

1312
1313
1314
1315
1316
1317
1318
    sqliteFree(pInit->zDeleteOnClose);
#endif
    *pId = 0;
    return SQLITE_NOMEM;
  }else{
    *pNew = *pInit;
    pNew->pMethod = &sqlite3WinIoMethod;





    *pId = (OsFile*)pNew;

    return SQLITE_OK;
  }
}


#endif /* SQLITE_OMIT_DISKIO */
/***************************************************************************







>
>
>
>
>

>







1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
    sqliteFree(pInit->zDeleteOnClose);
#endif
    *pId = 0;
    return SQLITE_NOMEM;
  }else{
    *pNew = *pInit;
    pNew->pMethod = &sqlite3WinIoMethod;
    pNew->locktype = NO_LOCK;
    pNew->sharedLockByte = 0;
#if OS_WINCE
    pNew->hMutex = NULL;
#endif
    *pId = (OsFile*)pNew;
    OpenCounter(+1);
    return SQLITE_OK;
  }
}


#endif /* SQLITE_OMIT_DISKIO */
/***************************************************************************
Changes to test/ioerr.test.
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# This file implements regression tests for SQLite library.  The
# focus of this file is testing for correct handling of I/O errors
# such as writes failing because the disk is full.
# 
# The tests in this file use special facilities that are only
# available in the SQLite test fixture.
#
# $Id: ioerr.test,v 1.23 2006/01/23 15:25:48 danielk1977 Exp $

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


# If SQLITE_DEFAULT_AUTOVACUUM is set to true, then a simulated IO error
# on the 8th IO operation in the SQL script below doesn't report an error.







|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# This file implements regression tests for SQLite library.  The
# focus of this file is testing for correct handling of I/O errors
# such as writes failing because the disk is full.
# 
# The tests in this file use special facilities that are only
# available in the SQLite test fixture.
#
# $Id: ioerr.test,v 1.24 2006/01/23 16:25:22 drh Exp $

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


# If SQLITE_DEFAULT_AUTOVACUUM is set to true, then a simulated IO error
# on the 8th IO operation in the SQL script below doesn't report an error.
200
201
202
203
204
205
206

207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226

227
228
229
230
231
232
233
  sqlite3 db test.db
} -sqlbody {
  SELECT c FROM t1;
}

# For test coverage: Cause an IO error whilst reading the master-journal
# name from a journal file.

do_ioerr_test ioerr-9 -tclprep {
  execsql {
    CREATE TABLE t1(a,b,c);
    INSERT INTO t1 VALUES(randstr(200,200), randstr(1000,1000), 2);
    BEGIN;
    INSERT INTO t1 VALUES(randstr(200,200), randstr(1000,1000), 2);
  }
  copy_file test.db-journal test2.db-journal
  execsql {
    COMMIT;
  }
  copy_file test2.db-journal test.db-journal
  set f [open test.db-journal a]
  fconfigure $f -encoding binary
  puts -nonewline $f "hello"
  puts -nonewline $f "\x00\x00\x00\x05\x01\x02\x03\x04"
  puts -nonewline $f "\xd9\xd5\x05\xf9\x20\xa1\x63\xd7"
  close $f
} -sqlbody {
  SELECT a FROM t1;

}

# For test coverage: Cause an IO error during statement playback (i.e. 
# a constraint).
do_ioerr_test ioerr-10 -tclprep {
  execsql {
    BEGIN;







>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>







200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
  sqlite3 db test.db
} -sqlbody {
  SELECT c FROM t1;
}

# For test coverage: Cause an IO error whilst reading the master-journal
# name from a journal file.
if {$tcl_platform(platform)=="unix"} {
  do_ioerr_test ioerr-9 -tclprep {
    execsql {
      CREATE TABLE t1(a,b,c);
      INSERT INTO t1 VALUES(randstr(200,200), randstr(1000,1000), 2);
      BEGIN;
      INSERT INTO t1 VALUES(randstr(200,200), randstr(1000,1000), 2);
    }
    copy_file test.db-journal test2.db-journal
    execsql {
      COMMIT;
    }
    copy_file test2.db-journal test.db-journal
    set f [open test.db-journal a]
    fconfigure $f -encoding binary
    puts -nonewline $f "hello"
    puts -nonewline $f "\x00\x00\x00\x05\x01\x02\x03\x04"
    puts -nonewline $f "\xd9\xd5\x05\xf9\x20\xa1\x63\xd7"
    close $f
  } -sqlbody {
    SELECT a FROM t1;
  }
}

# For test coverage: Cause an IO error during statement playback (i.e. 
# a constraint).
do_ioerr_test ioerr-10 -tclprep {
  execsql {
    BEGIN;