1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Fix a bug in the logic for journaling pages when the device sector-size is greater than the page size. (CVS 4270)

FossilOrigin-Name: b6399dff1370449912391cc5925bdc468b5dade0
This commit is contained in:
danielk1977
2007-08-22 18:54:32 +00:00
parent cab5ed7a57
commit dd97a49c1a
3 changed files with 34 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
C Get\sthe\squick.test\sscript\srunning\swith\sSQLITE_THREADSAFE\senabled.\s(CVS\s4269) C Fix\sa\sbug\sin\sthe\slogic\sfor\sjournaling\spages\swhen\sthe\sdevice\ssector-size\sis\sgreater\sthan\sthe\spage\ssize.\s(CVS\s4270)
D 2007-08-22T11:41:18 D 2007-08-22T18:54:33
F Makefile.in 0c0e53720f658c7a551046442dd7afba0b72bfbe F Makefile.in 0c0e53720f658c7a551046442dd7afba0b72bfbe
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499 F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -115,7 +115,7 @@ F src/os_unix.c 7aad42b1ee70d68034a4ac45fa822edccdc3d9e6
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
F src/os_win.c 29c0e19c1072679a4c7818c49fab2f35d2ad7747 F src/os_win.c 29c0e19c1072679a4c7818c49fab2f35d2ad7747
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
F src/pager.c 3568c1c557b2ff8faf054732abd32bc640116684 F src/pager.c 029a441236e9f504e25a3e2d2944afeae48c297c
F src/pager.h 53087c6fb9db01aed17c7fd044662a27507e89b8 F src/pager.h 53087c6fb9db01aed17c7fd044662a27507e89b8
F src/parse.y 2d2ce439dc6184621fb0b86f4fc5aca7f391a590 F src/parse.y 2d2ce439dc6184621fb0b86f4fc5aca7f391a590
F src/pragma.c 9b989506a1b7c8aecd6befb8235e2f57a4aba7e5 F src/pragma.c 9b989506a1b7c8aecd6befb8235e2f57a4aba7e5
@@ -559,7 +559,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 581fadfe31757e3fb97b12f93c1e3c085e4b6009 P 1f28b7e47bba221c14a10a37e7425c9975bb2312
R 04edf60a36c6b67ded0e1d8395cfcdd2 R cf0de8a627c4e3c426ffb917c87f2598
U drh U danielk1977
Z 751a55fa40ff7163f0ed16353fbe540e Z fbf5424b267fecb1d05194b85e3145a4

View File

@@ -1 +1 @@
1f28b7e47bba221c14a10a37e7425c9975bb2312 b6399dff1370449912391cc5925bdc468b5dade0

View File

@@ -18,7 +18,7 @@
** file simultaneously, or one process from reading the database while ** file simultaneously, or one process from reading the database while
** another is writing. ** another is writing.
** **
** @(#) $Id: pager.c,v 1.366 2007/08/22 11:22:04 danielk1977 Exp $ ** @(#) $Id: pager.c,v 1.367 2007/08/22 18:54:33 danielk1977 Exp $
*/ */
#ifndef SQLITE_OMIT_DISKIO #ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -1928,7 +1928,7 @@ int sqlite3PagerOpen(
return ((rc==SQLITE_OK)?SQLITE_NOMEM:rc); return ((rc==SQLITE_OK)?SQLITE_NOMEM:rc);
} }
PAGERTRACE3("OPEN %d %s\n", FILEHANDLEID(fd), zFullPathname); PAGERTRACE3("OPEN %d %s\n", FILEHANDLEID(pPager->fd), zFullPathname);
IOTRACE(("OPEN %p %s\n", pPager, zFullPathname)) IOTRACE(("OPEN %p %s\n", pPager, zFullPathname))
/* Fill in Pager.zDirectory[] */ /* Fill in Pager.zDirectory[] */
@@ -3753,6 +3753,7 @@ static int pager_write(PgHdr *pPg){
}else{ }else{
u32 cksum, saved; u32 cksum, saved;
char *pData2, *pEnd; char *pData2, *pEnd;
/* We should never write to the journal file the page that /* We should never write to the journal file the page that
** contains the database locks. The following assert verifies ** contains the database locks. The following assert verifies
** that we do not. */ ** that we do not. */
@@ -3870,6 +3871,7 @@ int sqlite3PagerWrite(DbPage *pDbPage){
Pgno pg1; /* First page of the sector pPg is located on. */ Pgno pg1; /* First page of the sector pPg is located on. */
int nPage; /* Number of pages starting at pg1 to journal */ int nPage; /* Number of pages starting at pg1 to journal */
int ii; int ii;
int needSync = 0;
/* Set the doNotSync flag to 1. This is because we cannot allow a journal /* Set the doNotSync flag to 1. This is because we cannot allow a journal
** header to be written between the pages journaled by this function. ** header to be written between the pages journaled by this function.
@@ -3897,19 +3899,40 @@ int sqlite3PagerWrite(DbPage *pDbPage){
for(ii=0; ii<nPage && rc==SQLITE_OK; ii++){ for(ii=0; ii<nPage && rc==SQLITE_OK; ii++){
Pgno pg = pg1+ii; Pgno pg = pg1+ii;
PgHdr *pPage;
if( !pPager->aInJournal || pg==pPg->pgno || if( !pPager->aInJournal || pg==pPg->pgno ||
pg>pPager->origDbSize || !(pPager->aInJournal[pg/8]&(1<<(pg&7))) pg>pPager->origDbSize || !(pPager->aInJournal[pg/8]&(1<<(pg&7)))
) { ) {
if( pg!=PAGER_MJ_PGNO(pPager) ){ if( pg!=PAGER_MJ_PGNO(pPager) ){
PgHdr *pPage;
rc = sqlite3PagerGet(pPager, pg, &pPage); rc = sqlite3PagerGet(pPager, pg, &pPage);
if( rc==SQLITE_OK ){ if( rc==SQLITE_OK ){
rc = pager_write(pPage); rc = pager_write(pPage);
if( pPage->needSync ){
needSync = 1;
}
sqlite3PagerUnref(pPage); sqlite3PagerUnref(pPage);
} }
} }
}else if( (pPage = pager_lookup(pPager, pg)) ){
if( pPage->needSync ){
needSync = 1;
} }
} }
}
/* If the PgHdr.needSync flag is set for any of the nPage pages
** starting at pg1, then it needs to be set for all of them. Because
** writing to any of these nPage pages may damage the others, the
** journal file must contain sync()ed copies of all of them
** before any of them can be written out to the database file.
*/
if( needSync ){
for(ii=0; ii<nPage && needSync; ii++){
PgHdr *pPage = pager_lookup(pPager, pg1+ii);
if( pPage ) pPage->needSync = 1;
}
assert(pPager->needSync);
}
assert( pPager->doNotSync==1 ); assert( pPager->doNotSync==1 );
pPager->doNotSync = 0; pPager->doNotSync = 0;