mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-14 00:22:38 +03:00
Modifications to the journal format to make it more robust. (CVS 1686)
FossilOrigin-Name: 504246a18daca794473b17a7874096f1ec8648ee
This commit is contained in:
@@ -207,14 +207,24 @@ static int writeCache2(OsTestFile *pFile, int crash){
|
||||
u8 *p = pFile->apBlk[i];
|
||||
if( p ){
|
||||
int skip = 0;
|
||||
int trash = 0;
|
||||
if( crash ){
|
||||
char random;
|
||||
sqlite3Randomness(1, &random);
|
||||
if( random & 0x01 ){
|
||||
skip = 1;
|
||||
if( 0 && random & 0x02 ){
|
||||
trash = 1;
|
||||
#ifdef TRACE_WRITECACHE
|
||||
printf("Not writing block %d of %s\n", i, pFile->zName);
|
||||
printf("Trashing block %d of %s\n", i, pFile->zName);
|
||||
#endif
|
||||
}else{
|
||||
skip = 1;
|
||||
#ifdef TRACE_WRITECACHE
|
||||
printf("Skiping block %d of %s\n", i, pFile->zName);
|
||||
#endif
|
||||
}
|
||||
}else{
|
||||
#ifdef TRACE_WRITECACHE
|
||||
printf("Writing block %d of %s\n", i, pFile->zName);
|
||||
#endif
|
||||
}
|
||||
@@ -227,6 +237,9 @@ printf("Writing block %d of %s\n", i, pFile->zName);
|
||||
if( BLOCK_OFFSET(i+1)>nMax ){
|
||||
len = nMax-BLOCK_OFFSET(i);
|
||||
}
|
||||
if( trash ){
|
||||
sqlite3Randomness(len, p);
|
||||
}
|
||||
rc = sqlite3RealWrite(&pFile->fd, p, len);
|
||||
}
|
||||
sqliteFree(p);
|
||||
|
||||
Reference in New Issue
Block a user