/ Check-in [7257fcc8]
Login

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

Overview
Comment:Change the name of the SQLITE_OPEN_REUSE_SCHEMA flag to SQLITE_OPEN_SHARED_SCHEMA.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | reuse-schema
Files: files | file ages | folders
SHA3-256: 7257fcc8c990b46a4f6a9e506f4a4a40195e6b2c626efd380cfa01f0ce8eb0fb
User & Date: dan 2019-02-14 18:38:44
Wiki:reuse-schema
Context
2019-02-14
21:04
Fix SQLITE_DBSTATUS_SCHEMA_USED so that it works with SQLITE_OPEN_SHARED_SCHEMA connections. check-in: d43b3c05 user: dan tags: reuse-schema
18:38
Change the name of the SQLITE_OPEN_REUSE_SCHEMA flag to SQLITE_OPEN_SHARED_SCHEMA. check-in: 7257fcc8 user: dan tags: reuse-schema
17:59
Fix a typo in shared_schema.md. check-in: e47a5aea user: dan tags: reuse-schema
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

   278    278   ** list of users and their access credentials.
   279    279   */
   280    280   int sqlite3UserAuthTable(const char *zTable){
   281    281     return sqlite3_stricmp(zTable, "sqlite_user")==0;
   282    282   }
   283    283   #endif
   284    284   
   285         -static int loadReusableSchema(sqlite3 *db, int iDb){
          285  +/*
          286  +** If this database connection was opened with the SQLITE_OPEN_SHARED_SCHEMA
          287  +** flag specified, then ensure that the database schema for database iDb
          288  +** is loaded. Either by obtaining a Schema object from the schema-pool, or
          289  +** by reading the contents of the sqlite_master table.
          290  +**
          291  +** If the database handle was not opened with SQLITE_OPEN_SHARED_SCHEMA, or
          292  +** if the schema for database iDb is already loaded, this function is a no-op.
          293  +**
          294  +** Non-zero is returned if a schema is loaded, or zero if it was already 
          295  +** loaded when this function was called..
          296  +*/
          297  +static int loadSharableSchema(sqlite3 *db, int iDb){
   286    298     if( IsReuseSchema(db) 
   287    299      && DbHasProperty(db, iDb, DB_SchemaLoaded)==0 
   288    300      && (db->init.busy==0 || (iDb!=1 && db->init.iDb==1))
   289    301     ){
   290    302       char *zDummy = 0;
   291    303       struct sqlite3InitInfo sv = db->init;
   292    304       memset(&db->init, 0, sizeof(struct sqlite3InitInfo));
................................................................................
   325    337   #endif
   326    338     while(1){
   327    339       for(i=OMIT_TEMPDB; i<db->nDb; i++){
   328    340         int j = (i<2) ? i^1 : i;   /* Search TEMP before MAIN */
   329    341         if( zDatabase==0 || sqlite3StrICmp(zDatabase, db->aDb[j].zDbSName)==0 ){
   330    342           int bUnload;
   331    343           assert( sqlite3SchemaMutexHeld(db, j, 0) );
   332         -        bUnload = loadReusableSchema(db, j);
          344  +        bUnload = loadSharableSchema(db, j);
   333    345           p = sqlite3HashFind(&db->aDb[j].pSchema->tblHash, zName);
   334    346           if( p ) return p;
   335    347           if( bUnload ){
   336    348             sqlite3SchemaRelease(db, j);
   337    349           }
   338    350         }
   339    351       }
................................................................................
   382    394       ** can be an eponymous virtual table. */
   383    395       if( pParse->disableVtab==0 ){
   384    396         Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
   385    397         if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
   386    398           pMod = sqlite3PragmaVtabRegister(db, zName);
   387    399         }
   388    400         if( pMod ){
   389         -        loadReusableSchema(db, 0);
          401  +        loadSharableSchema(db, 0);
   390    402           if( sqlite3VtabEponymousTableInit(pParse, pMod) ){
   391    403             return pMod->pEpoTab;
   392    404           }
   393    405         }
   394    406       }
   395    407   #endif
   396    408       if( flags & LOCATE_NOERR ) return 0;

Changes to src/callback.c.

    13     13   ** This file contains functions used to access the internal hash tables
    14     14   ** of user defined functions and collation sequences.
    15     15   */
    16     16   
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20         -** Connections opened with the SQLITE_OPEN_REUSE_SCHEMA flag specified
           20  +** Connections opened with the SQLITE_OPEN_SHARED_SCHEMA flag specified
    21     21   ** may use SchemaPool objects for any database that is not the temp db
    22     22   ** (iDb==1). For such databases (type "struct Db") there are three states
    23     23   ** the Schema/SchemaPool object may be in.
    24     24   **
    25     25   **   1) pSPool==0, pSchema points to an empty object allocated by
    26     26   **      sqlite3_malloc(). DB_SchemaLoaded flag is clear.
    27     27   **
................................................................................
   514    514     if( pSchema->schemaFlags & DB_SchemaLoaded ){
   515    515       pSchema->iGeneration++;
   516    516     }
   517    517     pSchema->schemaFlags &= ~(DB_SchemaLoaded|DB_ResetWanted);
   518    518   }
   519    519   
   520    520   /*
   521         -** If this database was opened with the SQLITE_OPEN_REUSE_SCHEMA flag
          521  +** If this database was opened with the SQLITE_OPEN_SHARED_SCHEMA flag
   522    522   ** and iDb!=1, then disconnect from the schema-pool associated with
   523    523   ** database iDb. Otherwise, clear the Schema object belonging to
   524    524   ** database iDb. 
   525    525   **
   526    526   ** If an OOM error occurs while disconnecting from a schema-pool, 
   527    527   ** the db->mallocFailed flag is set.
   528    528   */
................................................................................
   548    548   */
   549    549   SchemaPool *sqlite3SchemaPoolList(void){ return schemaPoolList; }
   550    550   #endif
   551    551   
   552    552   /*
   553    553   ** Check that the schema of db iDb is writable (either because it is the 
   554    554   ** temp db schema or because the db handle was opened without
   555         -** SQLITE_OPEN_REUSE_SCHEMA). If so, do nothing. Otherwise, leave an 
          555  +** SQLITE_OPEN_SHARED_SCHEMA). If so, do nothing. Otherwise, leave an 
   556    556   ** error in the Parse object.
   557    557   */
   558    558   void sqlite3SchemaWritable(Parse *pParse, int iDb){
   559         -  if( iDb!=1 && (pParse->db->openFlags & SQLITE_OPEN_REUSE_SCHEMA) 
          559  +  if( iDb!=1 && (pParse->db->openFlags & SQLITE_OPEN_SHARED_SCHEMA) 
   560    560      && IN_DECLARE_VTAB==0
   561    561     ){
   562    562       sqlite3ErrorMsg(pParse, "attempt to modify read-only schema");
   563    563     }
   564    564   }
   565    565   
   566    566   /*
................................................................................
   591    591     pDb->pSchema = &pDb->pSPool->sSchema;
   592    592   
   593    593     assert( (pDb->pSchema->schemaFlags & DB_SchemaLoaded)==0 );
   594    594   }
   595    595   
   596    596   /*
   597    597   ** The schema for database iDb of database handle db, which was opened
   598         -** with SQLITE_OPEN_REUSE_SCHEMA, has just been parsed. This function either
          598  +** with SQLITE_OPEN_SHARED_SCHEMA, has just been parsed. This function either
   599    599   ** finds a matching SchemaPool object on the global list (schemaPoolList) or
   600    600   ** else allocates a new one and sets the Db.pSPool variable accordingly.
   601    601   **
   602    602   ** SQLITE_OK is returned if no error occurs, or an SQLite error code 
   603    603   ** (SQLITE_NOMEM) otherwise.
   604    604   */
   605    605   int sqlite3SchemaConnect(sqlite3 *db, int iDb, u64 cksum){
................................................................................
   647    647   
   648    648     db->aDb[iDb].pSPool = p;
   649    649     return (p ? SQLITE_OK : SQLITE_NOMEM);
   650    650   }
   651    651   
   652    652   /*
   653    653   ** If parameter iDb is 1 (the temp db), or if connection handle db was not
   654         -** opened with the SQLITE_OPEN_REUSE_SCHEMA flag, this function is a no-op.
          654  +** opened with the SQLITE_OPEN_SHARED_SCHEMA flag, this function is a no-op.
   655    655   ** Otherwise, it disconnects from the schema-pool associated with database
   656    656   ** iDb, assuming it is connected.
   657    657   **
   658    658   ** If parameter bNew is true, then Db.pSchema is set to point to a new, empty,
   659    659   ** Schema object obtained from sqlite3_malloc(). Or, if bNew is false, then
   660    660   ** Db.pSchema is set to NULL before returning.
   661    661   **
................................................................................
   774    774     }
   775    775     sqlite3_mutex_leave( sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER) );
   776    776   }
   777    777   
   778    778   /*
   779    779   ** In most cases, this function finds and returns the schema associated 
   780    780   ** with BTree handle pBt, creating a new one if necessary. However, if
   781         -** the database handle was opened with the SQLITE_OPEN_REUSE_SCHEMA flag
          781  +** the database handle was opened with the SQLITE_OPEN_SHARED_SCHEMA flag
   782    782   ** specified, a new, empty, Schema object in memory obtained by 
   783    783   ** sqlite3_malloc() is always returned.
   784    784   */
   785    785   Schema *sqlite3SchemaGet(sqlite3 *db, Btree *pBt){
   786    786     Schema *p;
   787         -  if( pBt && (db->openFlags & SQLITE_OPEN_REUSE_SCHEMA)==0 ){
          787  +  if( pBt && (db->openFlags & SQLITE_OPEN_SHARED_SCHEMA)==0 ){
   788    788       p = (Schema *)sqlite3BtreeSchema(pBt, sizeof(Schema), sqlite3SchemaClear);
   789    789     }else{
   790    790       p = (Schema *)sqlite3DbMallocZero(0, sizeof(Schema));
   791    791     }
   792    792     if( !p ){
   793    793       sqlite3OomFault(db);
   794    794     }else if ( 0==p->file_format ){

Changes to src/prepare.c.

   157    157        || pIndex->tnum<2
   158    158        || sqlite3IndexHasDuplicateRootPage(pIndex)
   159    159       ){
   160    160         corruptSchema(pData, argv[0], pIndex?"invalid rootpage":"orphan index");
   161    161       }
   162    162     }
   163    163   
   164         -  if( iDb!=1 && (db->openFlags & SQLITE_OPEN_REUSE_SCHEMA) ){
          164  +  if( iDb!=1 && (db->openFlags & SQLITE_OPEN_SHARED_SCHEMA) ){
   165    165       schemaUpdateChecksum(pData, argv[0], argv[1], argv[2]);
   166    166     }
   167    167     return 0;
   168    168   }
   169    169   
   170    170   /*
   171    171   ** Attempt to read the database schema and initialize internal
................................................................................
   388    388       ** purpose of this is to allow access to the sqlite_master table
   389    389       ** even when its contents have been corrupted.
   390    390       */
   391    391       DbSetProperty(db, iDb, DB_SchemaLoaded);
   392    392       rc = SQLITE_OK;
   393    393     }
   394    394   
   395         -  if( rc==SQLITE_OK && iDb!=1 && (db->openFlags & SQLITE_OPEN_REUSE_SCHEMA) ){
          395  +  if( rc==SQLITE_OK && iDb!=1 && (db->openFlags & SQLITE_OPEN_SHARED_SCHEMA) ){
   396    396       rc = sqlite3SchemaConnect(db, iDb, initData.cksum);
   397    397     }
   398    398   
   399    399     /* Jump here for an error that occurs after successfully allocating
   400    400     ** curMain and calling sqlite3BtreeEnter(). For an error that occurs
   401    401     ** before that point, jump to error_out.
   402    402     */

Changes to src/shell.c.in.

  3910   3910         }
  3911   3911         case SHELL_OPEN_READONLY: {
  3912   3912           sqlite3_open_v2(p->zDbFilename, &p->db, SQLITE_OPEN_READONLY, 0);
  3913   3913           break;
  3914   3914         }
  3915   3915         case SHELL_OPEN_REUSESCHEMA: {
  3916   3916           sqlite3_open_v2(p->zDbFilename, &p->db,
  3917         -           SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_REUSE_SCHEMA, 0);
         3917  +          SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_SHARED_SCHEMA,0);
  3918   3918           break;
  3919   3919         }
  3920   3920         case SHELL_OPEN_UNSPEC:
  3921   3921         case SHELL_OPEN_NORMAL: {
  3922   3922           sqlite3_open(p->zDbFilename, &p->db);
  3923   3923           break;
  3924   3924         }

Changes to src/sqlite.h.in.

   563    563   #define SQLITE_OPEN_NOMUTEX          0x00008000  /* Ok for sqlite3_open_v2() */
   564    564   #define SQLITE_OPEN_FULLMUTEX        0x00010000  /* Ok for sqlite3_open_v2() */
   565    565   #define SQLITE_OPEN_SHAREDCACHE      0x00020000  /* Ok for sqlite3_open_v2() */
   566    566   #define SQLITE_OPEN_PRIVATECACHE     0x00040000  /* Ok for sqlite3_open_v2() */
   567    567   #define SQLITE_OPEN_WAL              0x00080000  /* VFS only */
   568    568   
   569    569   /* Reserved:                         0x00F00000 */
   570         -#define SQLITE_OPEN_REUSE_SCHEMA     0x01000000  /* Ok for sqlite3_open_v2() */
          570  +#define SQLITE_OPEN_SHARED_SCHEMA    0x01000000  /* Ok for sqlite3_open_v2() */
   571    571   
   572    572   
   573    573   /*
   574    574   ** CAPI3REF: Device Characteristics
   575    575   **
   576    576   ** The xDeviceCharacteristics method of the [sqlite3_io_methods]
   577    577   ** object returns an integer which is a vector of these

Changes to src/sqliteInt.h.

  1501   1501     sqlite3 *pNextBlocked;        /* Next in list of all blocked connections */
  1502   1502   #endif
  1503   1503   #ifdef SQLITE_USER_AUTHENTICATION
  1504   1504     sqlite3_userauth auth;        /* User authentication information */
  1505   1505   #endif
  1506   1506   };
  1507   1507   
  1508         -#define IsReuseSchema(db) (((db)->openFlags & SQLITE_OPEN_REUSE_SCHEMA)!=0)
         1508  +#define IsReuseSchema(db) (((db)->openFlags & SQLITE_OPEN_SHARED_SCHEMA)!=0)
  1509   1509   
  1510   1510   /*
  1511   1511   ** A macro to discover the encoding of a database.
  1512   1512   */
  1513   1513   #define SCHEMA_ENC(db) ((db)->aDb[0].pSchema->enc)
  1514   1514   #define ENC(db)        ((db)->enc)
  1515   1515   

Changes to src/tclsqlite.c.

  3466   3466   static int sqliteCmdUsage(
  3467   3467     Tcl_Interp *interp,
  3468   3468     Tcl_Obj *const*objv
  3469   3469   ){
  3470   3470     Tcl_WrongNumArgs(interp, 1, objv,
  3471   3471       "HANDLE ?FILENAME? ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create BOOLEAN?"
  3472   3472       " ?-nomutex BOOLEAN? ?-fullmutex BOOLEAN? ?-uri BOOLEAN?"
  3473         -    " ?-reuse-schema BOOLEAN?"
         3473  +    " ?-shared-schema BOOLEAN?"
  3474   3474   #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_CODEC_FROM_TCL)
  3475   3475       " ?-key CODECKEY?"
  3476   3476   #endif
  3477   3477     );
  3478   3478     return TCL_ERROR;
  3479   3479   }
  3480   3480   
................................................................................
  3601   3601         int b;
  3602   3602         if( Tcl_GetBooleanFromObj(interp, objv[i], &b) ) return TCL_ERROR;
  3603   3603         if( b ){
  3604   3604           flags |= SQLITE_OPEN_URI;
  3605   3605         }else{
  3606   3606           flags &= ~SQLITE_OPEN_URI;
  3607   3607         }
  3608         -    }else if( strcmp(zArg, "-reuse-schema")==0 ){
         3608  +    }else if( strcmp(zArg, "-shared-schema")==0 ){
  3609   3609         int b;
  3610   3610         if( Tcl_GetBooleanFromObj(interp, objv[i], &b) ) return TCL_ERROR;
  3611   3611         if( b ){
  3612         -        flags |= SQLITE_OPEN_REUSE_SCHEMA;
         3612  +        flags |= SQLITE_OPEN_SHARED_SCHEMA;
  3613   3613         }else{
  3614         -        flags &= ~SQLITE_OPEN_REUSE_SCHEMA;
         3614  +        flags &= ~SQLITE_OPEN_SHARED_SCHEMA;
  3615   3615         }
  3616   3616       }else{
  3617   3617         Tcl_AppendResult(interp, "unknown option: ", zArg, (char*)0);
  3618   3618         return TCL_ERROR;
  3619   3619       }
  3620   3620     }
  3621   3621     zErrMsg = 0;

Changes to test/reuse1.test.

    32     32     CREATE INDEX i1 ON t1(z);
    33     33     PRAGMA schema_version;
    34     34   } {2}
    35     35   
    36     36   do_test 1.2 {
    37     37     db close
    38     38     db2 close
    39         -  sqlite3 db2 test.db2 -reuse-schema 1
    40         -  sqlite3 db  test.db -reuse-schema 1
           39  +  sqlite3 db2 test.db2 -shared-schema 1
           40  +  sqlite3 db  test.db -shared-schema 1
    41     41   } {}
    42     42   
    43     43   do_execsql_test -db db2 1.3.1 {
    44     44     INSERT INTO t1 VALUES(1, 2, 3);
    45     45     INSERT INTO t1 VALUES(4, 5, 6);
    46     46   }
    47     47   
................................................................................
   103    103       INSERT INTO ft VALUES('one'), ('two'), ('three');
   104    104       ATTACH 'test.db2' AS aux;
   105    105       CREATE VIRTUAL TABLE aux.ft USING fts5(a);
   106    106       INSERT INTO aux.ft VALUES('aux1'), ('aux2'), ('aux3');
   107    107     }
   108    108   
   109    109     db close
   110         -  sqlite3 db  test.db -reuse-schema 1
          110  +  sqlite3 db  test.db -shared-schema 1
   111    111   
   112    112     do_execsql_test 2.1 {
   113    113       ATTACH 'test.db2' AS aux;
   114    114       SELECT * FROM main.ft;
   115    115     } {one two three}
   116    116   
   117    117   breakpoint
................................................................................
   158    158   } {1 2 3}
   159    159   
   160    160   do_execsql_test 3.3 {
   161    161     SELECT * FROM aux.v1;
   162    162   } {4 5 6}
   163    163   
   164    164   db close
   165         -sqlite3 db test.db -reuse-schema 1
          165  +sqlite3 db test.db -shared-schema 1
   166    166   
   167    167   do_execsql_test 3.4 { ATTACH 'test.db2' AS aux } {}
   168    168   do_execsql_test 3.5 { SELECT * FROM main.v1 } {1 2 3}
   169    169   do_execsql_test 3.6 { SELECT * FROM aux.v1  } {4 5 6}
   170    170   
   171    171   do_execsql_test 3.7.1 { INSERT INTO aux.t1 VALUES(8, 9, 10); }
   172    172   do_execsql_test 3.7.2 { SELECT * FROM main.v1 } {1 2 3}
................................................................................
   214    214     CREATE TRIGGER tr1 AFTER DELETE ON t1 BEGIN
   215    215       INSERT INTO del VALUES(old.a, old.b, old.c);
   216    216     END;
   217    217   }
   218    218   forcecopy test.db test.db2
   219    219   
   220    220   db close
   221         -sqlite3 db test.db -reuse-schema 1
          221  +sqlite3 db test.db -shared-schema 1
   222    222   execsql { 
   223    223     ATTACH 'test.db2' AS aux;
   224    224     PRAGMA recursive_triggers = 1;
   225    225   }
   226    226   
   227    227   do_execsql_test 4.1 {
   228    228     INSERT INTO main.t1 VALUES(1, 2, 3);
................................................................................
   253    253     INSERT INTO t1 VALUES(1, 2, 3), (4, 5, 6);
   254    254     ANALYZE;
   255    255     PRAGMA writable_schema = 1;
   256    256     DELETE FROM sqlite_stat1;
   257    257   }
   258    258   db close
   259    259   forcecopy test.db test.db2
   260         -sqlite3 db test.db -reuse-schema 1
          260  +sqlite3 db test.db -shared-schema 1
   261    261   execsql { ATTACH 'test.db2' AS aux }
   262    262   
   263    263   foreach {tn sql} {
   264    264     1 { CREATE TABLE t3(x) }
   265    265     2 { DROP TABLE t2 }
   266    266     3 { CREATE INDEX i2 ON t2(b) }
   267    267     4 { DROP INDEX i1 }
................................................................................
   297    297   do_execsql_test 5.4 {
   298    298     CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
   299    299     CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c);
   300    300     CREATE INDEX i1 ON t1(b);
   301    301     INSERT INTO t1 VALUES(1, 2, 3), (4, 5, 6);
   302    302   }
   303    303   db close
   304         -sqlite3 db test.db -reuse-schema 1
          304  +sqlite3 db test.db -shared-schema 1
   305    305   foreach {tn sql} {
   306    306     1 { ANALYZE }
   307    307     2 { ANALYZE t1 }
   308    308     3 { ANALYZE i1 }
   309    309     4 { ANALYZE main }
   310    310     5 { ANALYZE main.t1 }
   311    311     6 { ANALYZE main.i1 }
................................................................................
   318    318   reset_db
   319    319   do_execsql_test 6.0 {
   320    320     CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
   321    321     CREATE VIEW v1 AS SELECT * FROM t1;
   322    322   }
   323    323   db close
   324    324   forcecopy test.db test.db2
   325         -sqlite3 db test.db -reuse-schema 1
          325  +sqlite3 db test.db -shared-schema 1
   326    326   execsql { ATTACH 'test.db2' AS aux }
   327    327   
   328    328   do_execsql_test 6.1 {
   329    329     INSERT INTO main.t1(a) VALUES(1), (2), (3);
   330    330     INSERT INTO aux.t1(a) VALUES(4), (5), (6);
   331    331     CREATE TEMP TABLE t2(i,t);
   332    332     INSERT INTO t2 VALUES(2, 'two'), (5, 'five');
................................................................................
   346    346     CREATE TABLE p1(a PRIMARY KEY, b);
   347    347     CREATE TABLE p2(a PRIMARY KEY, b);
   348    348     CREATE TABLE c1(x REFERENCES p1 ON UPDATE CASCADE ON DELETE CASCADE);
   349    349   }
   350    350   
   351    351   db close
   352    352   forcecopy test.db test.db2
   353         -sqlite3 db test.db -reuse-schema 1
          353  +sqlite3 db test.db -shared-schema 1
   354    354   execsql { ATTACH 'test.db2' AS aux }
   355    355   
   356    356   do_execsql_test 7.1 {
   357    357     INSERT INTO aux.p1 VALUES(1, 'one');
   358    358     INSERT INTO aux.p1 VALUES(2, 'two');
   359    359     PRAGMA foreign_keys = on;
   360    360   }

Changes to test/reuse2.test.

    21     21     CREATE INDEX i1 ON t1(z);
    22     22     PRAGMA schema_version;
    23     23   } {2}
    24     24   
    25     25   do_test 1.2 {
    26     26     catch { db close }
    27     27     catch { db2 close }
    28         -  sqlite3 db2 test.db -reuse-schema 1
    29         -  sqlite3 db  test.db -reuse-schema 1
           28  +  sqlite3 db2 test.db -shared-schema 1
           29  +  sqlite3 db  test.db -shared-schema 1
    30     30   } {}
    31     31   
    32     32   do_execsql_test -db db2 1.3.1 {
    33     33     INSERT INTO t1 VALUES(1, 2, 3);
    34     34   }
    35     35   
    36     36   do_execsql_test -db db2 1.3.2 {
................................................................................
    45     45   reset_db
    46     46   ifcapable fts5 {
    47     47     do_execsql_test 2.0 {
    48     48       CREATE VIRTUAL TABLE ft USING fts5(c);
    49     49       INSERT INTO ft VALUES('one two three');
    50     50     }
    51     51     db close
    52         -  sqlite3 db test.db -reuse-schema 1
           52  +  sqlite3 db test.db -shared-schema 1
    53     53   
    54     54     do_execsql_test 2.1 {
    55     55       SELECT * FROM ft
    56     56     } {{one two three}}
    57     57   }
    58     58   
    59     59   #--------------------------------------------------------------------------
................................................................................
    61     61   do_execsql_test 3.0 {
    62     62     CREATE TABLE t1(x INTEGER PRIMARY KEY, y UNIQUE, z);
    63     63     CREATE INDEX i1 ON t1(z);
    64     64     PRAGMA schema_version;
    65     65   } {2}
    66     66   
    67     67   do_test 3.1 {
    68         -  sqlite3 db1 test.db -reuse-schema 1
    69         -  sqlite3 db2 test.db -reuse-schema 1
           68  +  sqlite3 db1 test.db -shared-schema 1
           69  +  sqlite3 db2 test.db -shared-schema 1
    70     70   } {}
    71     71   
    72     72   do_execsql_test -db db1 3.2.1 { SELECT * FROM t1 }
    73     73   do_execsql_test -db db2 3.2.2 { SELECT * FROM t1 }
    74     74   
    75     75   register_schemapool_module db
    76     76   do_execsql_test 3.3 { 
    77     77     SELECT 'nref=' || nRef, 'nschema=' || nSchema FROM schemapool;
    78     78   } {nref=2 nschema=1}
    79     79   
    80         -sqlite3 db3 test.db -reuse-schema 1
           80  +sqlite3 db3 test.db -shared-schema 1
    81     81   register_schemapool_module db3
    82     82   
    83     83   do_execsql_test 3.5 { 
    84     84     SELECT 'nref=' || nRef, 'nschema=' || nSchema FROM schemapool;
    85     85   } {nref=2 nschema=1}
    86     86   
    87     87   do_execsql_test -db db3 3.6 { 
................................................................................
   125    125   do_test 4.0.2 {
   126    126     db close
   127    127     for {set i 1} {$i < 6} {incr i} {
   128    128       forcedelete test.db${i}-journal test.db${i}-wal test.db${i}-wal2 
   129    129       forcecopy test.db test.db${i}
   130    130     }
   131    131     sqlite3 db  test.db
   132         -  sqlite3 db2 test.db -reuse-schema 1
          132  +  sqlite3 db2 test.db -shared-schema 1
   133    133   } {}
   134    134   
   135    135   register_schemapool_module db
   136    136   do_execsql_test 4.0.3 {
   137    137     SELECT 'nref=' || nRef, 'nschema=' || nSchema FROM schemapool ORDER BY 1;
   138    138   } {}
   139    139   
................................................................................
   254    254   catch {db3 close}
   255    255   reset_db
   256    256   do_execsql_test 5.0.1 {
   257    257     CREATE TABLE bbb(a INTEGER PRIMARY KEY, b);
   258    258   }
   259    259   db close
   260    260   do_test 5.0.2 {
   261         -  sqlite3 db2 test.db -reuse-schema 1
          261  +  sqlite3 db2 test.db -shared-schema 1
   262    262     register_schemapool_module db2
   263    263     for {set i 1} {$i<6} {incr i} {
   264    264       forcedelete test.db${i}-journal test.db${i}-wal test.db${i}-wal2 
   265    265       forcecopy test.db test.db${i}
   266    266       sqlite3 db test.db${i}
   267    267       db eval { INSERT INTO bbb VALUES(123, 'database_' || $i) }
   268    268       db close

Changes to test/reuse3.test.

    19     19   do_execsql_test 1.0 {
    20     20     CREATE TABLE t1(x INTEGER PRIMARY KEY, y UNIQUE, z);
    21     21     CREATE INDEX i1 ON t1(z);
    22     22     CREATE TABLE t2(a);
    23     23   } {}
    24     24   
    25     25   db close
    26         -sqlite3 db test.db -reuse-schema 1
           26  +sqlite3 db test.db -shared-schema 1
    27     27   
    28     28   do_execsql_test 1.1 {
    29     29     CREATE TEMP VIEW v1 AS SELECT * FROM t1;
    30     30     SELECT * FROM v1;
    31     31   }
    32     32   
    33     33   do_execsql_test 1.2 {
................................................................................
    75     75     CREATE TABLE x1(a, b, c);
    76     76     CREATE TABLE y1(d, e, f);
    77     77     PRAGMA writable_schema = 1;
    78     78     UPDATE sqlite_master SET sql = 'CREATE TBL y1(d, e, f)' WHERE name = 'y1';
    79     79   }
    80     80   db close
    81     81   
    82         -sqlite3 db test.db -reuse-schema 1
           82  +sqlite3 db test.db -shared-schema 1
    83     83   do_catchsql_test 2.1 {
    84     84     SELECT * FROM x1;
    85     85   } {1 {no such table: x1}}
    86     86   
    87     87   do_catchsql_test 2.2 {
    88     88     SELECT * FROM x1;
    89     89   } {1 {no such table: x1}}
    90     90   
    91     91   finish_test
    92     92