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

Avoid unnecessary calls to fstat() to determine the database file size.

FossilOrigin-Name: c733a1dea37e4678e7bd0d3d0ca9b8eae1fbdc28615f75d8f1e5141aa53567d9
This commit is contained in:
drh
2017-05-29 14:57:23 +00:00
parent 8abc54e2e8
commit 5f5a2d1c3c
3 changed files with 14 additions and 16 deletions

View File

@@ -5263,19 +5263,14 @@ int sqlite3PagerSharedLock(Pager *pPager){
** detected. The chance of an undetected change is so small that
** it can be neglected.
*/
Pgno nPage = 0;
char dbFileVers[sizeof(pPager->dbFileVers)];
rc = pagerPagecount(pPager, &nPage);
if( rc ) goto failed;
if( nPage>0 ){
IOTRACE(("CKVERS %p %d\n", pPager, sizeof(dbFileVers)));
rc = sqlite3OsRead(pPager->fd, &dbFileVers, sizeof(dbFileVers), 24);
if( rc!=SQLITE_OK && rc!=SQLITE_IOERR_SHORT_READ ){
IOTRACE(("CKVERS %p %d\n", pPager, sizeof(dbFileVers)));
rc = sqlite3OsRead(pPager->fd, &dbFileVers, sizeof(dbFileVers), 24);
if( rc!=SQLITE_OK ){
if( rc!=SQLITE_IOERR_SHORT_READ ){
goto failed;
}
}else{
memset(dbFileVers, 0, sizeof(dbFileVers));
}