1
1
/******************************************************************************
2
2
** This file is an amalgamation of many separate C source files from SQLite
3
- ** version 3.14.0 . By combining all the individual C code files into this
3
+ ** version 3.14.1 . By combining all the individual C code files into this
4
4
** single large file, the entire code can be compiled as a single translation
5
5
** unit. This allows many compilers to do optimizations that would not be
6
6
** possible if the files were compiled separately. Performance improvements
@@ -380,9 +380,9 @@ extern "C" {
380
380
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
381
381
** [sqlite_version()] and [sqlite_source_id()].
382
382
*/
383
- #define SQLITE_VERSION "3.14.0 "
384
- #define SQLITE_VERSION_NUMBER 3014000
385
- #define SQLITE_SOURCE_ID "2016-08-08 13:40:27 d5e98057028abcf7217d0d2b2e29bbbcdf09d6de "
383
+ #define SQLITE_VERSION "3.14.1 "
384
+ #define SQLITE_VERSION_NUMBER 3014001
385
+ #define SQLITE_SOURCE_ID "2016-08-11 18:53:32 a12d8059770df4bca59e321c266410344242bf7b "
386
386
387
387
/*
388
388
** CAPI3REF: Run-Time Library Version Numbers
@@ -44998,12 +44998,30 @@ static void pcache1TruncateUnsafe(
44998
44998
PCache1 *pCache, /* The cache to truncate */
44999
44999
unsigned int iLimit /* Drop pages with this pgno or larger */
45000
45000
){
45001
- TESTONLY( unsigned int nPage = 0; ) /* To assert pCache->nPage is correct */
45002
- unsigned int h;
45001
+ TESTONLY( int nPage = 0; ) /* To assert pCache->nPage is correct */
45002
+ unsigned int h, iStop ;
45003
45003
assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
45004
- for(h=0; h<pCache->nHash; h++){
45005
- PgHdr1 **pp = &pCache->apHash[h];
45004
+ assert( pCache->iMaxKey >= iLimit );
45005
+ assert( pCache->nHash > 0 );
45006
+ if( pCache->iMaxKey - iLimit < pCache->nHash ){
45007
+ /* If we are just shaving the last few pages off the end of the
45008
+ ** cache, then there is no point in scanning the entire hash table.
45009
+ ** Only scan those hash slots that might contain pages that need to
45010
+ ** be removed. */
45011
+ h = iLimit % pCache->nHash;
45012
+ iStop = pCache->iMaxKey % pCache->nHash;
45013
+ TESTONLY( nPage = -10; ) /* Disable the pCache->nPage validity check */
45014
+ }else{
45015
+ /* This is the general case where many pages are being removed.
45016
+ ** It is necessary to scan the entire hash table */
45017
+ h = pCache->nHash/2;
45018
+ iStop = h - 1;
45019
+ }
45020
+ for(;;){
45021
+ PgHdr1 **pp;
45006
45022
PgHdr1 *pPage;
45023
+ assert( h<pCache->nHash );
45024
+ pp = &pCache->apHash[h];
45007
45025
while( (pPage = *pp)!=0 ){
45008
45026
if( pPage->iKey>=iLimit ){
45009
45027
pCache->nPage--;
@@ -45012,11 +45030,13 @@ static void pcache1TruncateUnsafe(
45012
45030
pcache1FreePage(pPage);
45013
45031
}else{
45014
45032
pp = &pPage->pNext;
45015
- TESTONLY( nPage++; )
45033
+ TESTONLY( if( nPage>=0 ) nPage++; )
45016
45034
}
45017
45035
}
45036
+ if( h==iStop ) break;
45037
+ h = (h+1) % pCache->nHash;
45018
45038
}
45019
- assert( pCache->nPage==nPage );
45039
+ assert( nPage<0 || pCache->nPage==(unsigned) nPage );
45020
45040
}
45021
45041
45022
45042
/******************************************************************************/
@@ -45493,7 +45513,7 @@ static void pcache1Destroy(sqlite3_pcache *p){
45493
45513
PGroup *pGroup = pCache->pGroup;
45494
45514
assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) );
45495
45515
pcache1EnterMutex(pGroup);
45496
- pcache1TruncateUnsafe(pCache, 0);
45516
+ if( pCache->nPage ) pcache1TruncateUnsafe(pCache, 0);
45497
45517
assert( pGroup->nMaxPage >= pCache->nMax );
45498
45518
pGroup->nMaxPage -= pCache->nMax;
45499
45519
assert( pGroup->nMinPage >= pCache->nMin );
@@ -194000,7 +194020,7 @@ static void fts5SourceIdFunc(
194000
194020
){
194001
194021
assert( nArg==0 );
194002
194022
UNUSED_PARAM2(nArg, apUnused);
194003
- sqlite3_result_text(pCtx, "fts5: 2016-08-08 13:40:27 d5e98057028abcf7217d0d2b2e29bbbcdf09d6de ", -1, SQLITE_TRANSIENT);
194023
+ sqlite3_result_text(pCtx, "fts5: 2016-08-11 18:53:32 a12d8059770df4bca59e321c266410344242bf7b ", -1, SQLITE_TRANSIENT);
194004
194024
}
194005
194025
194006
194026
static int fts5Init(sqlite3 *db){
0 commit comments