/ Changes On Branch fix-stale-keyinfo-cache
Login

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

Changes In Branch fix-stale-keyinfo-cache Excluding Merge-Ins

This is equivalent to a diff from e9955c0e14 to 71f589e3f8

2014-12-05
14:44
When closing a (shared-cache) database connection, be sure to clear out all KeyInfo objects cached on Index objects. Fix for ticket [e4a18565a36884b00edf]. (check-in: adca7688de user: drh tags: trunk)
14:36
Add code to check the validity of CollSeq objects during runtime. This code was not able to detect anomalies such as came up as a result of ticket [e4a18565a36884b00edf66541f38c693827968ab] so it is put into a branch for historical reference, with the intent of leaving it out of trunk. (Closed-Leaf check-in: 68b23c3d41 user: drh tags: collseq-checking)
14:34
Improved comment on the sharedB.test test script. (Closed-Leaf check-in: 71f589e3f8 user: drh tags: fix-stale-keyinfo-cache)
14:07
Test case demonstrating the problem described by ticket [e4a18565a36884b00edf]. (check-in: ffea3e905a user: drh tags: fix-stale-keyinfo-cache)
05:38
When closing a (shared-cache) database connection, be sure to clear out all KeyInfo objects cached on Index objects. Proposed fix for ticket [e4a18565a36884b00edf]. (check-in: 651ed97de1 user: drh tags: fix-stale-keyinfo-cache)
00:49
Import compiler warning and autoconf makefile fixes from trunk. (check-in: 5437e0534a user: drh tags: apple-osx)
00:41
Import from trunk the fix the "test" target on the autoconf and MSVC makefiles and some minor compiler warning fixes. (check-in: c9f20eb2fb user: drh tags: sessions)
00:32
Fix compiler warnings. (check-in: e9955c0e14 user: drh tags: trunk)
00:17
Fix the autoconf and MSVC makefiles, which have been broken for nearly a month. :-( (check-in: 520c2b838d user: drh tags: trunk)

Changes to src/main.c.

1030
1031
1032
1033
1034
1035
1036
1037







1038
1039
1040
1041
1042
1043
1044
1030
1031
1032
1033
1034
1035
1036

1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050







-
+
+
+
+
+
+
+








  /* Close all database connections */
  for(j=0; j<db->nDb; j++){
    struct Db *pDb = &db->aDb[j];
    if( pDb->pBt ){
      sqlite3BtreeClose(pDb->pBt);
      pDb->pBt = 0;
      if( j!=1 ){
      if( j!=1 && pDb->pSchema ){
        /* Must clear the KeyInfo cache.  See ticket [e4a18565a36884b00edf] */
        for(i=sqliteHashFirst(&pDb->pSchema->idxHash); i; i=sqliteHashNext(i)){
          Index *pIdx = sqliteHashData(i);
          sqlite3KeyInfoUnref(pIdx->pKeyInfo);
          pIdx->pKeyInfo = 0;
        }
        pDb->pSchema = 0;
      }
    }
  }
  /* Clear the TEMP schema separately and last */
  if( db->aDb[1].pSchema ){
    sqlite3SchemaClear(db->aDb[1].pSchema);

Added test/sharedB.test.





























































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# 2014-12-05
#
# 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.
#
#***********************************************************************
#
# Open two database connections on the same database in shared cache
# mode.  Hold one open while repeatedly closing, reopening, and using
# the second.
#
# This test is designed to demostrate that the fix for ticket
# [e4a18565a36884b00edf66541f38c693827968ab] works.  
#


set testdir [file dirname $argv0]
source $testdir/tester.tcl
if {[run_thread_tests]==0} { finish_test ; return }
db close
set ::testprefix sharedB

set ::enable_shared_cache [sqlite3_enable_shared_cache 1]

#-------------------------------------------------------------------------
#
do_test 1.1 {
  sqlite3 db1 test.db
  sqlite3 db2 test.db

  db1 eval {
    CREATE TABLE t1(x,y TEXT COLLATE nocase);
    WITH RECURSIVE
      c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<100)
    INSERT INTO t1(x,y) SELECT i, printf('x%03dy',i) FROM c;
    CREATE INDEX t1yx ON t1(y,x);
  }
  db2 eval {
    SELECT x FROM t1 WHERE y='X014Y';
  }
} {14}

for {set j 1} {$j<=100} {incr j} {
  do_test 1.2.$j {
    db2 close
    sqlite3 db2 test.db
    db2 eval {
      SELECT x FROM t1 WHERE y='X014Y';
    }
  } {14}
}

db1 close
db2 close
sqlite3_enable_shared_cache $::enable_shared_cache
finish_test