/ Check-in [7c2ec2d4]
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 | SQL 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
Wiki:reuse-schema
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: 219b39e1 user: drh tags: reuse-schema
13:48
Performance optimization in the VDBE, and a fix for a harmless compiler warning. Closed-Leaf check-in: e002666a user: drh tags: reuse-schema-vdbe-opt
08:40
Fix a problem with OPEN_REUSE_SCHEMA connections reloading the temp schema. check-in: 7c2ec2d4 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: 8c07b609 user: dan tags: reuse-schema
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

   311    311       for(i=OMIT_TEMPDB; i<db->nDb; i++){
   312    312         int j = (i<2) ? i^1 : i;   /* Search TEMP before MAIN */
   313    313         if( zDatabase==0 || sqlite3StrICmp(zDatabase, db->aDb[j].zDbSName)==0 ){
   314    314           int bUnload = 0;
   315    315           assert( sqlite3SchemaMutexHeld(db, j, 0) );
   316    316           if( IsReuseSchema(db) 
   317    317            && DbHasProperty(db, j, DB_SchemaLoaded)==0 
   318         -         && db->init.busy==0
          318  +         && (db->init.busy==0 || (j!=1 && db->init.iDb==1))
   319    319           ){
          320  +          struct sqlite3InitInfo sv = db->init;
          321  +          memset(&db->init, 0, sizeof(struct sqlite3InitInfo));
   320    322             sqlite3InitOne(db, j, 0, 0);
   321    323             bUnload = (j!=1);
          324  +          db->init = sv;
   322    325           }
   323    326           p = sqlite3HashFind(&db->aDb[j].pSchema->tblHash, zName);
   324    327           if( p ) return p;
   325    328           if( bUnload ){
   326    329             sqlite3SchemaRelease(db, j);
   327    330           }
   328    331         }

Changes to test/reuse2.test.

   162    162     SELECT 'nref=' || nRef, 'nschema=' || nSchema FROM schemapool ORDER BY 1;
   163    163   } {nref=2 nschema=1}
   164    164   do_execsql_test -db db2 4.1.7 {
   165    165     SELECT * FROM x1
   166    166   }
   167    167   do_execsql_test 4.1.8 {
   168    168     SELECT 'nref=' || nRef, 'nschema=' || nSchema FROM schemapool ORDER BY 1;
   169         -} {nref=3 nschema=1}
          169  +} {nref=6 nschema=1}
   170    170   
   171    171   do_test 4.2.1 {
   172    172     catchsql { SELECT * FROM abc } db2
   173    173   } {1 {no such table: abc}}
   174    174   do_execsql_test 4.2.2 {
   175    175     SELECT 'nref=' || nRef, 'nschema=' || nSchema FROM schemapool ORDER BY 1;
   176    176   } {nref=6 nschema=1}

Changes to test/reuse3.test.

    48     48     SELECT * FROM v1
    49     49   } {1 2 3}
    50     50   
    51     51   do_execsql_test 1.6 {
    52     52     BEGIN;
    53     53       DROP TRIGGER tr1;
    54     54     ROLLBACK;
           55  +}
           56  +
           57  +do_execsql_test 1.7 {
           58  +  SELECT * FROM v1
           59  +} {1 2 3}
           60  +
           61  +do_execsql_test 1.8 {
    55     62     INSERT INTO t1 VALUES(4, 5, 6);
    56     63     SELECT * FROM t2
    57     64   } {1 4}
    58     65   
    59         -do_execsql_test 1.7 {
           66  +do_execsql_test 1.9 {
    60     67     SELECT * FROM v1
    61     68   } {1 2 3 4 5 6}
    62     69   
    63     70   finish_test
    64     71   
    65     72