/ Check-in [9a431362]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Test cases. Minor problems fixed. All appears to work now.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | cache_spill=N
Files: files | file ages | folders
SHA1:9a431362dccbc9b8f93375f30a3b8955903cca79
User & Date: drh 2015-11-12 15:47:48
Context
2015-11-12
16:44
Enhance the "PRAGMA cache_spill" statement to accept an integer argument which is the threshold at which spilling will begin. check-in: f79d264d user: drh tags: trunk
15:47
Test cases. Minor problems fixed. All appears to work now. Closed-Leaf check-in: 9a431362 user: drh tags: cache_spill=N
14:57
First attempt at enhancing the "PRAGMA cache_spill" statement to accept a cache threashold size. check-in: 549d42be user: drh tags: cache_spill=N
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pcache.c.

   648    648   ** be the larger of the szSpill and szCache.
   649    649   */
   650    650   int sqlite3PcacheSetSpillsize(PCache *p, int mxPage){
   651    651     int res;
   652    652     assert( p->pCache!=0 );
   653    653     if( mxPage ){
   654    654       if( mxPage<0 ){
   655         -      mxPage = (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra));
          655  +      mxPage = (int)((-1024*(i64)mxPage)/(p->szPage+p->szExtra));
   656    656       }
   657    657       p->szSpill = mxPage;
   658    658     }
   659    659     res = numberOfCachePages(p);
   660    660     if( res<p->szSpill ) res = p->szSpill; 
   661    661     return res;
   662    662   }

Changes to src/pragma.c.

   765    765     ** cache_size pages, no spilling occurs until the page count exceeds
   766    766     ** the number of cache_size pages.
   767    767     **
   768    768     ** The cache_spill=BOOLEAN setting applies to all attached schemas,
   769    769     ** not just the schema specified.
   770    770     */
   771    771     case PragTyp_CACHE_SPILL: {
   772         -    int size;
   773    772       assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
   774    773       if( !zRight ){
   775    774         if( sqlite3ReadSchema(pParse) ) goto pragma_out;
   776    775         returnSingleInt(v, "cache_spill", 
   777    776            (db->flags & SQLITE_CacheSpill)==0 ? 0 : 
   778    777               sqlite3BtreeSetSpillSize(pDb->pBt,0));
   779    778       }else{
          779  +      int size = 1;
   780    780         if( sqlite3GetInt32(zRight, &size) ){
   781    781           sqlite3BtreeSetSpillSize(pDb->pBt, size);
   782    782         }
   783         -      if( sqlite3GetBoolean(zRight, 0) ){
          783  +      if( sqlite3GetBoolean(zRight, size!=0) ){
   784    784           db->flags |= SQLITE_CacheSpill;
   785    785         }else{
   786    786           db->flags &= ~SQLITE_CacheSpill;
   787    787         }
          788  +      setAllPagerFlags(db);
   788    789       }
   789    790       break;
   790    791     }
   791    792   
   792    793     /*
   793    794     **  PRAGMA [schema.]mmap_size(N)
   794    795     **

Changes to test/pragma2.test.

   193    193       ROLLBACK;
   194    194       PRAGMA cache_spill=100000;
   195    195       PRAGMA cache_spill;
   196    196       BEGIN;
   197    197       UPDATE t1 SET c=c+1;
   198    198       PRAGMA lock_status;
   199    199     }
   200         -} {100000 main reserved temp unknown}   ;# Large cache spill threshold
          200  +} {100000 main reserved temp unknown}   ;# Big spill threshold -> no excl lock
   201    201   do_test pragma2-4.5.3 {
   202    202     db eval {
   203    203       ROLLBACK;
   204    204       PRAGMA cache_spill=25;
          205  +    PRAGMA main.cache_spill;
          206  +    BEGIN;
          207  +    UPDATE t1 SET c=c+1;
          208  +    PRAGMA lock_status;
          209  +  }
          210  +} {50 main exclusive temp unknown}   ;# Small cache spill -> exclusive lock
          211  +do_test pragma2-4.5.4 {
          212  +  db eval {
          213  +    ROLLBACK;
          214  +    PRAGMA cache_spill(-25);
          215  +    PRAGMA main.cache_spill;
   205    216       BEGIN;
   206    217       UPDATE t1 SET c=c+1;
   207    218       PRAGMA lock_status;
   208    219     }
   209         -} {main exclusive temp unknown}   ;# Large cache spill, so no exclusive lock
          220  +} {50 main exclusive temp unknown}   ;# Small cache spill -> exclusive lock
   210    221   
   211    222   
   212    223   # Verify that newly attached databases inherit the cache_spill=OFF
   213    224   # setting.
   214    225   #
   215    226   do_execsql_test pragma2-4.6 {
   216    227     ROLLBACK;
................................................................................
   227    238   sqlite3_release_memory
   228    239   do_execsql_test pragma2-4.8 {
   229    240     PRAGMA cache_spill=ON; -- Applies to all databases
   230    241     BEGIN;
   231    242     UPDATE t2 SET c=c-1;
   232    243     PRAGMA lock_status;
   233    244   } {main unlocked temp unknown aux1 exclusive}
          245  +db close
          246  +forcedelete test.db
          247  +sqlite3 db test.db
          248  +
          249  +breakpoint
          250  +do_execsql_test pragma2-5.1 {
          251  +  PRAGMA page_size=16384;
          252  +  CREATE TABLE t1(x);
          253  +  PRAGMA cache_size=2;
          254  +  PRAGMA cache_spill=YES;
          255  +  PRAGMA cache_spill;
          256  +} {2}
          257  +do_execsql_test pragma2-5.2 {
          258  +  PRAGMA cache_spill=NO;
          259  +  PRAGMA cache_spill;
          260  +} {0}
          261  +do_execsql_test pragma2-5.3 {
          262  +  PRAGMA cache_spill(-51);
          263  +  PRAGMA cache_spill;
          264  +} {3}
   234    265      
   235    266   test_restore_config_pagecache
   236    267   finish_test