mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Change an unreachable branch into an assert() in sqlite3PagerAcquire()
and optimize sqlite3PcacheOpenSavepoint() by factoring out rarely used code into a subroutine. FossilOrigin-Name: b406b20ecdf0bff63c5c222fab11cb9acee86765
This commit is contained in:
12
manifest
12
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Optimization\sto\sthe\ssqlite3PcacheFetch()\slogic.
|
C Change\san\sunreachable\sbranch\sinto\san\sassert()\sin\ssqlite3PagerAcquire()\nand\soptimize\ssqlite3PcacheOpenSavepoint()\sby\sfactoring\sout\srarely\sused\scode\ninto\sa\ssubroutine.
|
||||||
D 2015-06-30T03:57:59.045
|
D 2015-06-30T11:07:32.245
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in 285a0a234ed7610d431d91671c136098c2bd86a9
|
F Makefile.in 285a0a234ed7610d431d91671c136098c2bd86a9
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -314,7 +314,7 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa
|
|||||||
F src/os_unix.c 23eb5f56fac54d8fe0cb204291f3b3b2d94f23fc
|
F src/os_unix.c 23eb5f56fac54d8fe0cb204291f3b3b2d94f23fc
|
||||||
F src/os_win.c 27cc135e2d0b8b1e2e4944db1e2669a6a18fa0f8
|
F src/os_win.c 27cc135e2d0b8b1e2e4944db1e2669a6a18fa0f8
|
||||||
F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
|
F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
|
||||||
F src/pager.c 3fa869dafdb59ece9d318177e3b9972039dfee39
|
F src/pager.c 922d8ea28387b79a117488da06ee84f77d50d71e
|
||||||
F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77
|
F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77
|
||||||
F src/parse.y 6d60dda8f8d418b6dc034f1fbccd816c459983a8
|
F src/parse.y 6d60dda8f8d418b6dc034f1fbccd816c459983a8
|
||||||
F src/pcache.c cde06aa50962595e412d497e22fd2e07878ba1f0
|
F src/pcache.c cde06aa50962595e412d497e22fd2e07878ba1f0
|
||||||
@@ -1364,7 +1364,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
|
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
|
||||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||||
P a0fa6b3ba59716e53b8c035b497602050ed0ccb8
|
P d9a0481ce0fd9824b1566f182d68ec46ef091b1b
|
||||||
R ef96145c17347794d738ef415b1d0f04
|
R 24b6e6de7d9b089958239ab689d72050
|
||||||
U drh
|
U drh
|
||||||
Z a3fb1d60e02fc08f324c2aa0fa9d650d
|
Z 9400732c29ac033e0975f1d6b596266c
|
||||||
|
@@ -1 +1 @@
|
|||||||
d9a0481ce0fd9824b1566f182d68ec46ef091b1b
|
b406b20ecdf0bff63c5c222fab11cb9acee86765
|
80
src/pager.c
80
src/pager.c
@@ -5319,7 +5319,7 @@ int sqlite3PagerAcquire(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pPg = *ppPage = sqlite3PcacheFetchFinish(pPager->pPCache, pgno, pBase);
|
pPg = *ppPage = sqlite3PcacheFetchFinish(pPager->pPCache, pgno, pBase);
|
||||||
if( pPg==0 ) rc = SQLITE_NOMEM;
|
assert( pPg!=0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6475,54 +6475,62 @@ int sqlite3PagerIsMemdb(Pager *pPager){
|
|||||||
** occurs while opening the sub-journal file, then an IO error code is
|
** occurs while opening the sub-journal file, then an IO error code is
|
||||||
** returned. Otherwise, SQLITE_OK.
|
** returned. Otherwise, SQLITE_OK.
|
||||||
*/
|
*/
|
||||||
int sqlite3PagerOpenSavepoint(Pager *pPager, int nSavepoint){
|
static SQLITE_NOINLINE int pagerOpenSavepoint(Pager *pPager, int nSavepoint){
|
||||||
int rc = SQLITE_OK; /* Return code */
|
int rc = SQLITE_OK; /* Return code */
|
||||||
int nCurrent = pPager->nSavepoint; /* Current number of savepoints */
|
int nCurrent = pPager->nSavepoint; /* Current number of savepoints */
|
||||||
|
int ii; /* Iterator variable */
|
||||||
|
PagerSavepoint *aNew; /* New Pager.aSavepoint array */
|
||||||
|
|
||||||
assert( pPager->eState>=PAGER_WRITER_LOCKED );
|
assert( pPager->eState>=PAGER_WRITER_LOCKED );
|
||||||
assert( assert_pager_state(pPager) );
|
assert( assert_pager_state(pPager) );
|
||||||
|
assert( nSavepoint>nCurrent && pPager->useJournal );
|
||||||
|
|
||||||
if( nSavepoint>nCurrent && pPager->useJournal ){
|
/* Grow the Pager.aSavepoint array using realloc(). Return SQLITE_NOMEM
|
||||||
int ii; /* Iterator variable */
|
** if the allocation fails. Otherwise, zero the new portion in case a
|
||||||
PagerSavepoint *aNew; /* New Pager.aSavepoint array */
|
** malloc failure occurs while populating it in the for(...) loop below.
|
||||||
|
*/
|
||||||
|
aNew = (PagerSavepoint *)sqlite3Realloc(
|
||||||
|
pPager->aSavepoint, sizeof(PagerSavepoint)*nSavepoint
|
||||||
|
);
|
||||||
|
if( !aNew ){
|
||||||
|
return SQLITE_NOMEM;
|
||||||
|
}
|
||||||
|
memset(&aNew[nCurrent], 0, (nSavepoint-nCurrent) * sizeof(PagerSavepoint));
|
||||||
|
pPager->aSavepoint = aNew;
|
||||||
|
|
||||||
/* Grow the Pager.aSavepoint array using realloc(). Return SQLITE_NOMEM
|
/* Populate the PagerSavepoint structures just allocated. */
|
||||||
** if the allocation fails. Otherwise, zero the new portion in case a
|
for(ii=nCurrent; ii<nSavepoint; ii++){
|
||||||
** malloc failure occurs while populating it in the for(...) loop below.
|
aNew[ii].nOrig = pPager->dbSize;
|
||||||
*/
|
if( isOpen(pPager->jfd) && pPager->journalOff>0 ){
|
||||||
aNew = (PagerSavepoint *)sqlite3Realloc(
|
aNew[ii].iOffset = pPager->journalOff;
|
||||||
pPager->aSavepoint, sizeof(PagerSavepoint)*nSavepoint
|
}else{
|
||||||
);
|
aNew[ii].iOffset = JOURNAL_HDR_SZ(pPager);
|
||||||
if( !aNew ){
|
}
|
||||||
|
aNew[ii].iSubRec = pPager->nSubRec;
|
||||||
|
aNew[ii].pInSavepoint = sqlite3BitvecCreate(pPager->dbSize);
|
||||||
|
if( !aNew[ii].pInSavepoint ){
|
||||||
return SQLITE_NOMEM;
|
return SQLITE_NOMEM;
|
||||||
}
|
}
|
||||||
memset(&aNew[nCurrent], 0, (nSavepoint-nCurrent) * sizeof(PagerSavepoint));
|
if( pagerUseWal(pPager) ){
|
||||||
pPager->aSavepoint = aNew;
|
sqlite3WalSavepoint(pPager->pWal, aNew[ii].aWalData);
|
||||||
|
|
||||||
/* Populate the PagerSavepoint structures just allocated. */
|
|
||||||
for(ii=nCurrent; ii<nSavepoint; ii++){
|
|
||||||
aNew[ii].nOrig = pPager->dbSize;
|
|
||||||
if( isOpen(pPager->jfd) && pPager->journalOff>0 ){
|
|
||||||
aNew[ii].iOffset = pPager->journalOff;
|
|
||||||
}else{
|
|
||||||
aNew[ii].iOffset = JOURNAL_HDR_SZ(pPager);
|
|
||||||
}
|
|
||||||
aNew[ii].iSubRec = pPager->nSubRec;
|
|
||||||
aNew[ii].pInSavepoint = sqlite3BitvecCreate(pPager->dbSize);
|
|
||||||
if( !aNew[ii].pInSavepoint ){
|
|
||||||
return SQLITE_NOMEM;
|
|
||||||
}
|
|
||||||
if( pagerUseWal(pPager) ){
|
|
||||||
sqlite3WalSavepoint(pPager->pWal, aNew[ii].aWalData);
|
|
||||||
}
|
|
||||||
pPager->nSavepoint = ii+1;
|
|
||||||
}
|
}
|
||||||
assert( pPager->nSavepoint==nSavepoint );
|
pPager->nSavepoint = ii+1;
|
||||||
assertTruncateConstraint(pPager);
|
|
||||||
}
|
}
|
||||||
|
assert( pPager->nSavepoint==nSavepoint );
|
||||||
|
assertTruncateConstraint(pPager);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
int sqlite3PagerOpenSavepoint(Pager *pPager, int nSavepoint){
|
||||||
|
assert( pPager->eState>=PAGER_WRITER_LOCKED );
|
||||||
|
assert( assert_pager_state(pPager) );
|
||||||
|
|
||||||
|
if( nSavepoint>pPager->nSavepoint && pPager->useJournal ){
|
||||||
|
return pagerOpenSavepoint(pPager, nSavepoint);
|
||||||
|
}else{
|
||||||
|
return SQLITE_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This function is called to rollback or release (commit) a savepoint.
|
** This function is called to rollback or release (commit) a savepoint.
|
||||||
|
Reference in New Issue
Block a user