Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Correctly update the cache page-count when discarding pages in the xTruncate() method of the default pcache implementation. Otherwise the effective configured size of the cache shrinks each time xTruncate() is called. Fix for #3844. (CVS 6619) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
88211ceeec01ee0d3e55231512be26dd |
User & Date: | danielk1977 2009-05-08 06:52:48.000 |
Context
2009-05-08
| ||
11:34 | Fix a warning in the osx-specific part of os_unix.c. Ticket #3847. (CVS 6620) (check-in: 254ca3273c user: danielk1977 tags: trunk) | |
06:52 | Correctly update the cache page-count when discarding pages in the xTruncate() method of the default pcache implementation. Otherwise the effective configured size of the cache shrinks each time xTruncate() is called. Fix for #3844. (CVS 6619) (check-in: 88211ceeec user: danielk1977 tags: trunk) | |
2009-05-07
| ||
14:11 | If compiling FTS3 in the amalgamation, include the ctype.h header file. Ticket #3843. (CVS 6618) (check-in: 660108ef7a user: drh tags: trunk) | |
Changes
Changes to src/pcache1.c.
︙ | ︙ | |||
12 13 14 15 16 17 18 | ** ** This file implements the default page cache implementation (the ** sqlite3_pcache interface). It also contains part of the implementation ** of the SQLITE_CONFIG_PAGECACHE and sqlite3_release_memory() features. ** If the default page cache implementation is overriden, then neither of ** these two features are available. ** | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ** ** This file implements the default page cache implementation (the ** sqlite3_pcache interface). It also contains part of the implementation ** of the SQLITE_CONFIG_PAGECACHE and sqlite3_release_memory() features. ** If the default page cache implementation is overriden, then neither of ** these two features are available. ** ** @(#) $Id: pcache1.c,v 1.12 2009/05/08 06:52:48 danielk1977 Exp $ */ #include "sqliteInt.h" typedef struct PCache1 PCache1; typedef struct PgHdr1 PgHdr1; typedef struct PgFreeslot PgFreeslot; |
︙ | ︙ | |||
356 357 358 359 360 361 362 363 364 365 366 367 368 369 | ** ** The global mutex must be held when this function is called. */ static void pcache1TruncateUnsafe( PCache1 *pCache, unsigned int iLimit ){ unsigned int h; assert( sqlite3_mutex_held(pcache1.mutex) ); for(h=0; h<pCache->nHash; h++){ PgHdr1 **pp = &pCache->apHash[h]; PgHdr1 *pPage; while( (pPage = *pp)!=0 ){ if( pPage->iKey>=iLimit ){ | > | > > > | 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | ** ** The global mutex must be held when this function is called. */ static void pcache1TruncateUnsafe( PCache1 *pCache, unsigned int iLimit ){ TESTONLY( int nPage = 0; ) /* Used to assert pCache->nPage is correct */ unsigned int h; assert( sqlite3_mutex_held(pcache1.mutex) ); for(h=0; h<pCache->nHash; h++){ PgHdr1 **pp = &pCache->apHash[h]; PgHdr1 *pPage; while( (pPage = *pp)!=0 ){ if( pPage->iKey>=iLimit ){ pCache->nPage--; *pp = pPage->pNext; pcache1PinPage(pPage); pcache1FreePage(pPage); }else{ pp = &pPage->pNext; TESTONLY( nPage++; ) } } } assert( pCache->nPage==nPage ); } /******************************************************************************/ /******** sqlite3_pcache Methods **********************************************/ /* ** Implementation of the sqlite3_pcache.xInit method. |
︙ | ︙ |
Changes to test/pcache.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2008 August 29 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # # This file is focused on testing the pcache module. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2008 August 29 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # # This file is focused on testing the pcache module. # # $Id: pcache.test,v 1.5 2009/05/08 06:52:48 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # The pcache module limits the number of pages available to purgeable # caches to the sum of the 'cache_size' values for the set of open |
︙ | ︙ | |||
141 142 143 144 145 146 147 148 | } {current 19 max 20 min 10 recyclable 19} do_test pcache-1.13 { execsql { PRAGMA cache_size = 15 } pcache_stats } {current 15 max 15 min 10 recyclable 15} finish_test | > > > > > > > > > > > > > > > > > > > > > | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | } {current 19 max 20 min 10 recyclable 19} do_test pcache-1.13 { execsql { PRAGMA cache_size = 15 } pcache_stats } {current 15 max 15 min 10 recyclable 15} do_test pcache-1.14 { hexio_write test.db 24 [hexio_render_int32 1000] execsql { SELECT * FROM sqlite_master } pcache_stats } {current 2 max 15 min 10 recyclable 2} do_test pcache-1.15 { execsql { SELECT * FROM t1 ORDER BY a; SELECT * FROM t1; SELECT * FROM t2 ORDER BY a; SELECT * FROM t2; SELECT * FROM t3 ORDER BY a; SELECT * FROM t3; SELECT * FROM t4 ORDER BY a; SELECT * FROM t4; SELECT * FROM t5 ORDER BY a; SELECT * FROM t5; SELECT * FROM t6 ORDER BY a; SELECT * FROM t6; SELECT * FROM t7 ORDER BY a; SELECT * FROM t7; SELECT * FROM t8 ORDER BY a; SELECT * FROM t8; SELECT * FROM t9 ORDER BY a; SELECT * FROM t9; } pcache_stats } {current 14 max 15 min 10 recyclable 14} finish_test |