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

Never allow the b-tree layers view of the number of pages in the database

file exceed the actual number of pages in the database file, even when
PRAGMA writeable_schema=ON.  This helps with earlier detection of corruption,
and prevents excess memory usage and CPU cycles in some integrity_check ops.

FossilOrigin-Name: 0407c8793700491b8519a649b9624f569b0e7e9b94d0db79d4a08139e0ecdb69
This commit is contained in:
drh
2022-01-17 14:42:38 +00:00
parent 7d44b22d45
commit 5a6f818d84
4 changed files with 16 additions and 13 deletions

View File

@@ -3235,9 +3235,13 @@ static int lockBtree(BtShared *pBt){
pageSize-usableSize);
return rc;
}
if( sqlite3WritableSchema(pBt->db)==0 && nPage>nPageFile ){
rc = SQLITE_CORRUPT_BKPT;
goto page1_init_failed;
if( nPage>nPageFile ){
if( sqlite3WritableSchema(pBt->db)==0 ){
rc = SQLITE_CORRUPT_BKPT;
goto page1_init_failed;
}else{
nPage = nPageFile;
}
}
/* EVIDENCE-OF: R-28312-64704 However, the usable size is not allowed to
** be less than 480. In other words, if the page size is 512, then the