SQLite

Check-in [7c2ec2d4cf]
Login

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

Overview
Comment:Fix a problem with OPEN_REUSE_SCHEMA connections reloading the temp schema.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | reuse-schema
Files: files | file ages | folders
SHA3-256: 7c2ec2d4cfcda9c0aa6d57bd9a12ff98b78e648533d49da27f91d5a37bf1e001
User & Date: dan 2019-02-13 08:40:34.055
Context
2019-02-13
14:06
Rearrange the code in the VDBE to help out the C-compiler optimizer. And fix a harmless compiler warning. (check-in: 219b39e149 user: drh tags: reuse-schema)
13:48
Performance optimization in the VDBE, and a fix for a harmless compiler warning. (Closed-Leaf check-in: e002666ac7 user: drh tags: reuse-schema-vdbe-opt)
08:40
Fix a problem with OPEN_REUSE_SCHEMA connections reloading the temp schema. (check-in: 7c2ec2d4cf user: dan tags: reuse-schema)
2019-02-12
20:58
Add tests for creating temp schema objects with SQLITE_OPEN_REUSE_SCHEMA connections. (check-in: 8c07b609fc user: dan tags: reuse-schema)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/build.c.
311
312
313
314
315
316
317
318

319


320
321

322
323
324
325
326
327
328
311
312
313
314
315
316
317

318
319
320
321
322
323
324
325
326
327
328
329
330
331







-
+

+
+


+







    for(i=OMIT_TEMPDB; i<db->nDb; i++){
      int j = (i<2) ? i^1 : i;   /* Search TEMP before MAIN */
      if( zDatabase==0 || sqlite3StrICmp(zDatabase, db->aDb[j].zDbSName)==0 ){
        int bUnload = 0;
        assert( sqlite3SchemaMutexHeld(db, j, 0) );
        if( IsReuseSchema(db) 
         && DbHasProperty(db, j, DB_SchemaLoaded)==0 
         && db->init.busy==0
         && (db->init.busy==0 || (j!=1 && db->init.iDb==1))
        ){
          struct sqlite3InitInfo sv = db->init;
          memset(&db->init, 0, sizeof(struct sqlite3InitInfo));
          sqlite3InitOne(db, j, 0, 0);
          bUnload = (j!=1);
          db->init = sv;
        }
        p = sqlite3HashFind(&db->aDb[j].pSchema->tblHash, zName);
        if( p ) return p;
        if( bUnload ){
          sqlite3SchemaRelease(db, j);
        }
      }
Changes to test/reuse2.test.
162
163
164
165
166
167
168
169

170
171
172
173
174
175
176
162
163
164
165
166
167
168

169
170
171
172
173
174
175
176







-
+







  SELECT 'nref=' || nRef, 'nschema=' || nSchema FROM schemapool ORDER BY 1;
} {nref=2 nschema=1}
do_execsql_test -db db2 4.1.7 {
  SELECT * FROM x1
}
do_execsql_test 4.1.8 {
  SELECT 'nref=' || nRef, 'nschema=' || nSchema FROM schemapool ORDER BY 1;
} {nref=3 nschema=1}
} {nref=6 nschema=1}

do_test 4.2.1 {
  catchsql { SELECT * FROM abc } db2
} {1 {no such table: abc}}
do_execsql_test 4.2.2 {
  SELECT 'nref=' || nRef, 'nschema=' || nSchema FROM schemapool ORDER BY 1;
} {nref=6 nschema=1}
Changes to test/reuse3.test.
48
49
50
51
52
53
54







55
56
57
58
59

60
61
62
63
64
65
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

66
67
68
69
70
71
72







+
+
+
+
+
+
+




-
+






  SELECT * FROM v1
} {1 2 3}

do_execsql_test 1.6 {
  BEGIN;
    DROP TRIGGER tr1;
  ROLLBACK;
}

do_execsql_test 1.7 {
  SELECT * FROM v1
} {1 2 3}

do_execsql_test 1.8 {
  INSERT INTO t1 VALUES(4, 5, 6);
  SELECT * FROM t2
} {1 4}

do_execsql_test 1.7 {
do_execsql_test 1.9 {
  SELECT * FROM v1
} {1 2 3 4 5 6}

finish_test