-C Update\stest_journal.c\sto\saccount\sfor\s(6817).\sChanges\sto\stest\scode\sonly.\s(CVS\s6818)
-D 2009-06-26T09:01:28
+C Another\schange\sto\stest_journal.c\sto\saccount\sfor\s(6817).\sAgain,\sonly\stest\scode\shas\schanged.\s(CVS\s6819)
+D 2009-06-26T10:39:36
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 8b8fb7823264331210cddf103831816c286ba446
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F src/test_devsym.c 9f4bc2551e267ce7aeda195f3897d0f30c5228f4
F src/test_func.c b8140bc4ed0d290d5e22972eb2a3bfd40aa798dc
F src/test_hexio.c 2f1122aa3f012fa0142ee3c36ce5c902a70cd12f
-F src/test_journal.c de9b1c132fa7b81b40ddba1e1cc219cfa7f71593
+F src/test_journal.c dab49b7c47b53242f039c9563b18cafb67ebfe03
F src/test_loadext.c 97dc8800e46a46ed002c2968572656f37e9c0dd9
F src/test_malloc.c c3aabe4b48d1f4f1e78b6561ce92ca04b7495ee5
F src/test_md5.c 032ae2bb6f81da350d2404e81fa8d560c8268026
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
-P a5ecffcf025da2fcb241e83c7bebc1095a3b51d6
-R c676cf0f55e46f711692cbb781213a1a
+P 542ee8cced2a37095808d8baf5002dc66f4a64d6
+R c84107e8653fbec4d656c36416c49db0
U danielk1977
-Z afb621a0d984d29cdcb0c1a658c4dfbf
+Z 3ae5a098ab66146aa838154cfa456687
** correctly populates and syncs a journal file before writing to a
** corresponding database file.
**
-** $Id: test_journal.c,v 1.16 2009/06/26 09:01:28 danielk1977 Exp $
+** $Id: test_journal.c,v 1.17 2009/06/26 10:39:36 danielk1977 Exp $
*/
#if SQLITE_TEST /* This file is used for testing only */
}
extern int sqlite3_io_error_pending;
-static void stop_ioerr_simulation(int *piSave){
+extern int sqlite3_io_error_hit;
+static void stop_ioerr_simulation(int *piSave, int *piSave2){
*piSave = sqlite3_io_error_pending;
+ *piSave2 = sqlite3_io_error_hit;
sqlite3_io_error_pending = -1;
+ sqlite3_io_error_hit = 0;
}
-static void start_ioerr_simulation(int iSave){
+static void start_ioerr_simulation(int iSave, int iSave2){
sqlite3_io_error_pending = iSave;
+ sqlite3_io_error_hit = iSave2;
}
/*
}else if( pMain->nPage>0 ){
u32 iTrunk;
int iSave;
+ int iSave2;
- stop_ioerr_simulation(&iSave);
+ stop_ioerr_simulation(&iSave, &iSave2);
/* Read the database free-list. Add the page-number for each free-list
** leaf to the jt_file.pWritable bitvec.
}
}
- start_ioerr_simulation(iSave);
+ start_ioerr_simulation(iSave, iSave2);
}
sqlite3_free(aData);
return rc;
}
-/*
-** Write data to an jt-file.
-*/
-static int jtWrite(
- sqlite3_file *pFile,
- const void *zBuf,
- int iAmt,
- sqlite_int64 iOfst
-){
- jt_file *p = (jt_file *)pFile;
- if( p->flags&SQLITE_OPEN_MAIN_JOURNAL ){
- if( iOfst==0 ){
- jt_file *pMain = locateDatabaseHandle(p->zName);
- assert( pMain );
-
- if( iAmt==28 ){
- /* Zeroing the first journal-file header. This is the end of a
- ** transaction. */
- closeTransaction(pMain);
- }else if( iAmt!=12 ){
- /* Writing the first journal header to a journal file. This happens
- ** when a transaction is first started. */
- int rc;
- u8 *z = (u8 *)zBuf;
- pMain->nPage = decodeUint32(&z[16]);
- pMain->nPagesize = decodeUint32(&z[24]);
- if( SQLITE_OK!=(rc=openTransaction(pMain, p)) ){
- return rc;
- }
- }
- }
- if( p->iMaxOff<(iOfst + iAmt) ){
- p->iMaxOff = iOfst + iAmt;
- }
- }
-
- if( p->flags&SQLITE_OPEN_MAIN_DB && p->pWritable ){
- if( iAmt<p->nPagesize
- && p->nPagesize%iAmt==0
- && iOfst>=(PENDING_BYTE+512)
- && iOfst+iAmt<=PENDING_BYTE+p->nPagesize
- ){
- /* No-op. This special case is hit when the backup code is copying a
- ** to a database with a larger page-size than the source database and
- ** it needs to fill in the non-locking-region part of the original
- ** pending-byte page.
- */
- }else{
- u32 pgno = iOfst/p->nPagesize + 1;
- assert( (iAmt==1||iAmt==p->nPagesize) && ((iOfst+iAmt)%p->nPagesize)==0 );
- assert( pgno<=p->nPage || p->nSync>0 );
- assert( pgno>p->nPage || sqlite3BitvecTest(p->pWritable, pgno) );
- }
- }
-
- return sqlite3OsWrite(p->pReal, zBuf, iAmt, iOfst);
-}
-
-/*
-** Truncate an jt-file.
-*/
-static int jtTruncate(sqlite3_file *pFile, sqlite_int64 size){
- jt_file *p = (jt_file *)pFile;
- if( p->flags&SQLITE_OPEN_MAIN_JOURNAL && size==0 ){
- /* Truncating a journal file. This is the end of a transaction. */
- jt_file *pMain = locateDatabaseHandle(p->zName);
- closeTransaction(pMain);
- }
- if( p->flags&SQLITE_OPEN_MAIN_DB && p->pWritable ){
- u32 pgno;
- u32 locking_page = (u32)(PENDING_BYTE/p->nPagesize+1);
- for(pgno=size/p->nPagesize+1; pgno<=p->nPage; pgno++){
- assert( pgno==locking_page || sqlite3BitvecTest(p->pWritable, pgno) );
- }
- }
- return sqlite3OsTruncate(p->pReal, size);
-}
-
/*
** The first argument to this function is a handle open on a journal file.
** This function reads the journal file and adds the page number for each
sqlite3_int64 iSize = p->iMaxOff;
unsigned char *aPage;
int iSave;
+ int iSave2;
aPage = sqlite3_malloc(pMain->nPagesize);
if( !aPage ){
return SQLITE_IOERR_NOMEM;
}
- stop_ioerr_simulation(&iSave);
+ stop_ioerr_simulation(&iSave, &iSave2);
while( rc==SQLITE_OK && iOff<iSize ){
u32 nRec, nPage, nSector, nPagesize;
}
finish_rjf:
- start_ioerr_simulation(iSave);
+ start_ioerr_simulation(iSave, iSave2);
sqlite3_free(aPage);
if( rc==SQLITE_IOERR_SHORT_READ ){
rc = SQLITE_OK;
return rc;
}
+
+/*
+** Write data to an jt-file.
+*/
+static int jtWrite(
+ sqlite3_file *pFile,
+ const void *zBuf,
+ int iAmt,
+ sqlite_int64 iOfst
+){
+ int rc;
+ jt_file *p = (jt_file *)pFile;
+ if( p->flags&SQLITE_OPEN_MAIN_JOURNAL ){
+ if( iOfst==0 ){
+ jt_file *pMain = locateDatabaseHandle(p->zName);
+ assert( pMain );
+
+ if( iAmt==28 ){
+ /* Zeroing the first journal-file header. This is the end of a
+ ** transaction. */
+ closeTransaction(pMain);
+ }else if( iAmt!=12 ){
+ /* Writing the first journal header to a journal file. This happens
+ ** when a transaction is first started. */
+ u8 *z = (u8 *)zBuf;
+ pMain->nPage = decodeUint32(&z[16]);
+ pMain->nPagesize = decodeUint32(&z[24]);
+ if( SQLITE_OK!=(rc=openTransaction(pMain, p)) ){
+ return rc;
+ }
+ }
+ }
+ if( p->iMaxOff<(iOfst + iAmt) ){
+ p->iMaxOff = iOfst + iAmt;
+ }
+ }
+
+ if( p->flags&SQLITE_OPEN_MAIN_DB && p->pWritable ){
+ if( iAmt<p->nPagesize
+ && p->nPagesize%iAmt==0
+ && iOfst>=(PENDING_BYTE+512)
+ && iOfst+iAmt<=PENDING_BYTE+p->nPagesize
+ ){
+ /* No-op. This special case is hit when the backup code is copying a
+ ** to a database with a larger page-size than the source database and
+ ** it needs to fill in the non-locking-region part of the original
+ ** pending-byte page.
+ */
+ }else{
+ u32 pgno = iOfst/p->nPagesize + 1;
+ assert( (iAmt==1||iAmt==p->nPagesize) && ((iOfst+iAmt)%p->nPagesize)==0 );
+ assert( pgno<=p->nPage || p->nSync>0 );
+ assert( pgno>p->nPage || sqlite3BitvecTest(p->pWritable, pgno) );
+ }
+ }
+
+ rc = sqlite3OsWrite(p->pReal, zBuf, iAmt, iOfst);
+ if( (p->flags&SQLITE_OPEN_MAIN_JOURNAL) && iAmt==12 ){
+ jt_file *pMain = locateDatabaseHandle(p->zName);
+ int rc2 = readJournalFile(p, pMain);
+ if( rc==SQLITE_OK ) rc = rc2;
+ }
+ return rc;
+}
+
+/*
+** Truncate an jt-file.
+*/
+static int jtTruncate(sqlite3_file *pFile, sqlite_int64 size){
+ jt_file *p = (jt_file *)pFile;
+ if( p->flags&SQLITE_OPEN_MAIN_JOURNAL && size==0 ){
+ /* Truncating a journal file. This is the end of a transaction. */
+ jt_file *pMain = locateDatabaseHandle(p->zName);
+ closeTransaction(pMain);
+ }
+ if( p->flags&SQLITE_OPEN_MAIN_DB && p->pWritable ){
+ u32 pgno;
+ u32 locking_page = (u32)(PENDING_BYTE/p->nPagesize+1);
+ for(pgno=size/p->nPagesize+1; pgno<=p->nPage; pgno++){
+ assert( pgno==locking_page || sqlite3BitvecTest(p->pWritable, pgno) );
+ }
+ }
+ return sqlite3OsTruncate(p->pReal, size);
+}
+
/*
** Sync an jt-file.
*/