1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Preliminary fix for ticket #599. More testing and analysis needed. (CVS 1208)

FossilOrigin-Name: dc5be2c82b591a385adf02863d89e113272e2ebd
This commit is contained in:
drh
2004-02-08 00:40:52 +00:00
parent e84a306b91
commit 240c5795d5
4 changed files with 41 additions and 14 deletions

View File

@@ -18,7 +18,7 @@
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.92 2004/01/07 02:52:08 drh Exp $
** @(#) $Id: pager.c,v 1.93 2004/02/08 00:40:52 drh Exp $
*/
#include "os.h" /* Must be first to enable large file support */
#include "sqliteInt.h"
@@ -571,6 +571,10 @@ static int pager_playback(Pager *pPager, int useJournalSize){
if( rc!=SQLITE_OK ){
goto end_playback;
}
/* If the journal file is too small to contain a complete header,
** then ignore the journal completely.
*/
if( szJ < sizeof(aMagic)+sizeof(Pgno) ){
goto end_playback;
}
@@ -594,6 +598,15 @@ static int pager_playback(Pager *pPager, int useJournalSize){
goto end_playback;
}
if( format>=JOURNAL_FORMAT_3 ){
if( szJ < sizeof(aMagic) + 3*sizeof(u32) ){
/* Ignore the journal if it is too small to contain a complete
** header. We already did this test once above, but at the prior
** test, we did not know the journal format and so we had to assume
** the smallest possible header. Now we know the header is bigger
** than that so we test again.
*/
goto end_playback;
}
rc = read32bits(format, &pPager->jfd, (u32*)&nRec);
if( rc ) goto end_playback;
rc = read32bits(format, &pPager->jfd, &pPager->cksumInit);
@@ -630,7 +643,7 @@ static int pager_playback(Pager *pPager, int useJournalSize){
/* Pages that have been written to the journal but never synced
** where not restored by the loop above. We have to restore those
** pages by reading the back from the original database.
** pages by reading them back from the original database.
*/
if( rc==SQLITE_OK ){
PgHdr *pPg;
@@ -1896,7 +1909,8 @@ int sqlitepager_commit(Pager *pPager){
return rc;
}
assert( pPager->journalOpen );
if( pPager->needSync && sqliteOsSync(&pPager->jfd)!=SQLITE_OK ){
rc = syncAllPages(pPager);
if( rc!=SQLITE_OK ){
goto commit_abort;
}
pPg = pager_get_all_dirty_pages(pPager);