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

When the write_version flag in the database header is larger than what

the library understands, make the database read-only.  The old behavior
was to make the database unreadable. (CVS 3866)

FossilOrigin-Name: 10648e99929b4f640855433b6e47702687039286
This commit is contained in:
drh
2007-04-24 17:27:51 +00:00
parent af30469d67
commit 309169a118
4 changed files with 86 additions and 13 deletions

View File

@@ -9,7 +9,7 @@
** May you share freely, never taking more than you give.
**
*************************************************************************
** $Id: btree.c,v 1.356 2007/04/19 00:24:34 drh Exp $
** $Id: btree.c,v 1.357 2007/04/24 17:27:51 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
@@ -1870,7 +1870,10 @@ static int lockBtree(BtShared *pBt){
if( memcmp(page1, zMagicHeader, 16)!=0 ){
goto page1_init_failed;
}
if( page1[18]>1 || page1[19]>1 ){
if( page1[18]>1 ){
pBt->readOnly = 1;
}
if( page1[19]>1 ){
goto page1_init_failed;
}
pageSize = get2byte(&page1[16]);
@@ -2068,11 +2071,15 @@ int sqlite3BtreeBeginTrans(Btree *p, int wrflag){
if( pBt->pPage1==0 ){
rc = lockBtree(pBt);
}
if( rc==SQLITE_OK && wrflag ){
rc = sqlite3PagerBegin(pBt->pPage1->pDbPage, wrflag>1);
if( rc==SQLITE_OK ){
rc = newDatabase(pBt);
if( pBt->readOnly ){
rc = SQLITE_READONLY;
}else{
rc = sqlite3PagerBegin(pBt->pPage1->pDbPage, wrflag>1);
if( rc==SQLITE_OK ){
rc = newDatabase(pBt);
}
}
}