/ Check-in [8a9b43f9]
Login

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

Overview
Comment:Merge the shared-cache KeyInfo fix from trunk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | apple-osx
Files: files | file ages | folders
SHA1: 8a9b43f930de9c789b230909233eee64ad1db93d
User & Date: drh 2014-12-05 20:16:52
Context
2014-12-09
15:01
Increase the default PMA size from 10 to 250 pages and provide the SQLITE_SORTER_PMASZ compile-time option to change this default. Add needed mutex call when clearing the KeyInfo cache in shared-cache mode. check-in: 6e2da589 user: drh tags: apple-osx
2014-12-05
20:16
Merge the shared-cache KeyInfo fix from trunk. check-in: 8a9b43f9 user: drh tags: apple-osx
19:50
Make sure the WhereTerm objects are fully zeroed when they are allocated. check-in: fdb66733 user: drh tags: trunk
00:49
Import compiler warning and autoconf makefile fixes from trunk. check-in: 5437e053 user: drh tags: apple-osx
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/main.c.

  1031   1031     /* Free any outstanding Savepoint structures. */
  1032   1032     sqlite3CloseSavepoints(db);
  1033   1033   
  1034   1034     /* Close all database connections */
  1035   1035     for(j=0; j<db->nDb; j++){
  1036   1036       struct Db *pDb = &db->aDb[j];
  1037   1037       if( pDb->pBt ){
         1038  +      if( pDb->pSchema ){
         1039  +        /* Must clear the KeyInfo cache.  See ticket [e4a18565a36884b00edf] */
         1040  +        for(i=sqliteHashFirst(&pDb->pSchema->idxHash); i; i=sqliteHashNext(i)){
         1041  +          Index *pIdx = sqliteHashData(i);
         1042  +          sqlite3KeyInfoUnref(pIdx->pKeyInfo);
         1043  +          pIdx->pKeyInfo = 0;
         1044  +        }
         1045  +      }
  1038   1046         sqlite3BtreeClose(pDb->pBt);
  1039   1047         pDb->pBt = 0;
  1040   1048         if( j!=1 ){
  1041   1049           pDb->pSchema = 0;
  1042   1050         }
  1043   1051       }
  1044   1052     }

Changes to src/where.c.

   218    218         return 0;
   219    219       }
   220    220       memcpy(pWC->a, pOld, sizeof(pWC->a[0])*pWC->nTerm);
   221    221       if( pOld!=pWC->aStatic ){
   222    222         sqlite3DbFree(db, pOld);
   223    223       }
   224    224       pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]);
          225  +    memset(&pWC->a[pWC->nTerm], 0, sizeof(pWC->a[0])*(pWC->nSlot-pWC->nTerm));
   225    226     }
   226    227     pTerm = &pWC->a[idx = pWC->nTerm++];
   227    228     if( p && ExprHasProperty(p, EP_Unlikely) ){
   228    229       pTerm->truthProb = sqlite3LogEst(p->iTable) - 270;
   229    230     }else{
   230    231       pTerm->truthProb = 1;
   231    232     }

Added test/sharedB.test.

            1  +# 2014-12-05
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +#
           12  +# Open two database connections on the same database in shared cache
           13  +# mode.  Hold one open while repeatedly closing, reopening, and using
           14  +# the second.
           15  +#
           16  +# This test is designed to demostrate that the fix for ticket
           17  +# [e4a18565a36884b00edf66541f38c693827968ab] works.  
           18  +#
           19  +
           20  +
           21  +set testdir [file dirname $argv0]
           22  +source $testdir/tester.tcl
           23  +if {[run_thread_tests]==0} { finish_test ; return }
           24  +db close
           25  +set ::testprefix sharedB
           26  +
           27  +set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
           28  +
           29  +#-------------------------------------------------------------------------
           30  +#
           31  +do_test 1.1 {
           32  +  sqlite3 db1 test.db
           33  +  sqlite3 db2 test.db
           34  +
           35  +  db1 eval {
           36  +    CREATE TABLE t1(x,y TEXT COLLATE nocase);
           37  +    WITH RECURSIVE
           38  +      c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<100)
           39  +    INSERT INTO t1(x,y) SELECT i, printf('x%03dy',i) FROM c;
           40  +    CREATE INDEX t1yx ON t1(y,x);
           41  +  }
           42  +  db2 eval {
           43  +    SELECT x FROM t1 WHERE y='X014Y';
           44  +  }
           45  +} {14}
           46  +
           47  +for {set j 1} {$j<=100} {incr j} {
           48  +  do_test 1.2.$j {
           49  +    db2 close
           50  +    sqlite3 db2 test.db
           51  +    db2 eval {
           52  +      SELECT x FROM t1 WHERE y='X014Y';
           53  +    }
           54  +  } {14}
           55  +}
           56  +
           57  +db1 close
           58  +db2 close
           59  +sqlite3_enable_shared_cache $::enable_shared_cache
           60  +finish_test