mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
When searching a list of freelist trunk pages looking for a specific page
to allocate, avoid unnecessary journalling of the unchanged trunk pages towards the start of the list. FossilOrigin-Name: d03d63d77ed144ac2c02a0245c4b4b070b79c88e
This commit is contained in:
10
src/btree.c
10
src/btree.c
@@ -4819,7 +4819,7 @@ static int allocateBtreePage(
|
||||
goto end_allocate_page;
|
||||
}
|
||||
|
||||
k = get4byte(&pTrunk->aData[4]);
|
||||
k = get4byte(&pTrunk->aData[4]); /* # of leaves on this trunk page */
|
||||
if( k==0 && !searchList ){
|
||||
/* The trunk has no leaves and the list is not being searched.
|
||||
** So extract the trunk page itself and use it as the newly
|
||||
@@ -4904,10 +4904,6 @@ static int allocateBtreePage(
|
||||
u32 closest;
|
||||
Pgno iPage;
|
||||
unsigned char *aData = pTrunk->aData;
|
||||
rc = sqlite3PagerWrite(pTrunk->pDbPage);
|
||||
if( rc ){
|
||||
goto end_allocate_page;
|
||||
}
|
||||
if( nearby>0 ){
|
||||
u32 i;
|
||||
int dist;
|
||||
@@ -4937,11 +4933,12 @@ static int allocateBtreePage(
|
||||
TRACE(("ALLOCATE: %d was leaf %d of %d on trunk %d"
|
||||
": %d more free pages\n",
|
||||
*pPgno, closest+1, k, pTrunk->pgno, n-1));
|
||||
rc = sqlite3PagerWrite(pTrunk->pDbPage);
|
||||
if( rc ) goto end_allocate_page;
|
||||
if( closest<k-1 ){
|
||||
memcpy(&aData[8+closest*4], &aData[4+k*4], 4);
|
||||
}
|
||||
put4byte(&aData[4], k-1);
|
||||
assert( sqlite3PagerIswriteable(pTrunk->pDbPage) );
|
||||
noContent = !btreeGetHasContent(pBt, *pPgno);
|
||||
rc = btreeGetPage(pBt, *pPgno, ppPage, noContent);
|
||||
if( rc==SQLITE_OK ){
|
||||
@@ -5010,6 +5007,7 @@ end_allocate_page:
|
||||
}else{
|
||||
*ppPage = 0;
|
||||
}
|
||||
assert( rc!=SQLITE_OK || sqlite3PagerIswriteable((*ppPage)->pDbPage) );
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user