| | @@ -1,8 +1,8 @@ |
| 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 |
| 7 | 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | 8 | ** translation unit. |
| | @@ -378,13 +378,13 @@ |
| 378 | 378 | ** |
| 379 | 379 | ** See also: [sqlite3_libversion()], |
| 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 |
| 389 | 389 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 390 | 390 | ** |
| | @@ -44996,29 +44996,49 @@ |
| 44996 | 44996 | */ |
| 44997 | 44997 | 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--; |
| 45010 | 45028 | *pp = pPage->pNext; |
| 45011 | 45029 | if( !pPage->isPinned ) pcache1PinPage(pPage); |
| 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 | /******************************************************************************/ |
| 45023 | 45043 | /******** sqlite3_pcache Methods **********************************************/ |
| 45024 | 45044 | |
| | @@ -45491,11 +45511,11 @@ |
| 45491 | 45511 | static void pcache1Destroy(sqlite3_pcache *p){ |
| 45492 | 45512 | PCache1 *pCache = (PCache1 *)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 ); |
| 45500 | 45520 | pGroup->nMinPage -= pCache->nMin; |
| 45501 | 45521 | pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; |
| | @@ -193998,11 +194018,11 @@ |
| 193998 | 194018 | int nArg, /* Number of args */ |
| 193999 | 194019 | sqlite3_value **apUnused /* Function arguments */ |
| 194000 | 194020 | ){ |
| 194001 | 194021 | assert( nArg==0 ); |
| 194002 | 194022 | UNUSED_PARAM2(nArg, apUnused); |
| 194003 | | - sqlite3_result_text(pCtx, "fts5: 2016-08-05 20:54:45 95578898835b933901603bd4d5e063f1219a016f", -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){ |
| 194007 | 194027 | static const sqlite3_module fts5Mod = { |
| 194008 | 194028 | /* iVersion */ 2, |
| 194009 | 194029 | |