aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordan <dan@noemail.net>2010-06-17 06:19:53 +0000
committerdan <dan@noemail.net>2010-06-17 06:19:53 +0000
commitc00251807484a735558da4f4bf9b3950bea2c31e (patch)
treed53d35c3d6a01726fa91fe101e4db33b1954166a /src
parent2a321c754704cd68f433cf1f0414628d14386003 (diff)
parentb28e59bbbb963e8e3c10628eccd432fa591f49a8 (diff)
downloadsqlite-c00251807484a735558da4f4bf9b3950bea2c31e.tar.gz
sqlite-c00251807484a735558da4f4bf9b3950bea2c31e.zip
Merge fix [f80c3f922a] with experimental changes.
FossilOrigin-Name: 20133e9ca98f5e6c42051ed3d65e4eb71d5366a5
Diffstat (limited to 'src')
-rw-r--r--src/btree.c2
-rw-r--r--src/pager.c11
2 files changed, 8 insertions, 5 deletions
diff --git a/src/btree.c b/src/btree.c
index 1e1b6f19e..37ea5e46b 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -2250,7 +2250,7 @@ static int lockBtree(BtShared *pBt){
if( (rc = sqlite3PagerPagecount(pBt->pPager, &nPageFile))!=SQLITE_OK ){;
goto page1_init_failed;
}
- if( nPage==0 ){
+ if( nPage==0 || memcmp(24+(u8*)pPage1->aData, 92+(u8*)pPage1->aData,4)!=0 ){
nPage = nPageFile;
}
if( nPage>0 ){
diff --git a/src/pager.c b/src/pager.c
index 46eb7bc63..a35e9d71d 100644
--- a/src/pager.c
+++ b/src/pager.c
@@ -2241,9 +2241,9 @@ static int readDbPage(PgHdr *pPg){
/* If the read is unsuccessful, set the dbFileVers[] to something
** that will never be a valid file version. dbFileVers[] is a copy
** of bytes 24..39 of the database. Bytes 28..31 should always be
- ** zero. Bytes 32..35 and 35..39 should be page numbers which are
- ** never 0xffffffff. So filling pPager->dbFileVers[] with all 0xff
- ** bytes should suffice.
+ ** zero or the size of the database in page. Bytes 32..35 and 35..39
+ ** should be page numbers which are never 0xffffffff. So filling
+ ** pPager->dbFileVers[] with all 0xff bytes should suffice.
**
** For an encrypted database, the situation is more complex: bytes
** 24..39 of the database are white noise. But the probability of
@@ -5011,7 +5011,10 @@ static int pager_incr_changecounter(Pager *pPager, int isDirectMode){
change_counter++;
put32bits(((char*)pPgHdr->pData)+24, change_counter);
- /* Also store the SQLite version number in bytes 96..99 */
+ /* Also store the SQLite version number in bytes 96..99 and in
+ ** bytes 92..95 store the change counter for which the version number
+ ** is valid. */
+ put32bits(((char*)pPgHdr->pData)+92, change_counter);
put32bits(((char*)pPgHdr->pData)+96, SQLITE_VERSION_NUMBER);
/* If running in direct mode, write the contents of page 1 to the file. */