/ Check-in [c1be211c]
Login

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

Overview
Comment:Use the IsReuseSchema() macro more consistently. Also, rename it to IsSharedSchema().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | reuse-schema
Files: files | file ages | folders
SHA3-256:c1be211c0286a6ff3ef8ab6839136175efb000118ff8704d3cc01b2a23b841ab
User & Date: dan 2019-03-20 20:02:03
Wiki:reuse-schema
Context
2019-03-21
17:13
Disable the feature on this branch in non-SQLITE_ENABLE_SHARED_SCHEMA builds. check-in: b8e53608 user: dan tags: reuse-schema
2019-03-20
20:02
Use the IsReuseSchema() macro more consistently. Also, rename it to IsSharedSchema(). check-in: c1be211c user: dan tags: reuse-schema
19:17
Fix an error message. check-in: a70fdaa3 user: dan tags: reuse-schema
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/attach.c.

   229    229     ** If this fails, or if opening the file failed, then close the file and 
   230    230     ** remove the entry from the db->aDb[] array. i.e. put everything back the
   231    231     ** way we found it.
   232    232     */
   233    233     if( rc==SQLITE_OK ){
   234    234       db->init.iDb = 0;
   235    235       db->mDbFlags &= ~(DBFLAG_SchemaKnownOk);
   236         -    if( !IsReuseSchema(db) && !REOPEN_AS_MEMDB(db) ){
          236  +    if( !IsSharedSchema(db) && !REOPEN_AS_MEMDB(db) ){
   237    237         sqlite3BtreeEnterAll(db);
   238    238         rc = sqlite3Init(db, &zErrDyn);
   239    239         sqlite3BtreeLeaveAll(db);
   240    240         assert( zErrDyn==0 || rc!=SQLITE_OK );
   241    241       }
   242    242     }
   243    243   #ifdef SQLITE_USER_AUTHENTICATION

Changes to src/build.c.

   300    300   ** SQLITE_OK is returned if successful, or an SQLite error code otherwise. If
   301    301   ** an error code is returned, (*pzErr) may be set to point to a buffer
   302    302   ** containing an error message. It is the responsibility of the caller to
   303    303   ** eventually free this buffer using sqlite3_free().
   304    304   */
   305    305   int sqlite3SchemaLoad(sqlite3 *db, int iDb, int *pbUnload, char **pzErr){
   306    306     int rc = SQLITE_OK;
   307         -  if( IsReuseSchema(db) 
          307  +  if( IsSharedSchema(db) 
   308    308         && DbHasProperty(db, iDb, DB_SchemaLoaded)==0 
   309    309         && (db->init.busy==0 || (iDb!=1 && db->init.iDb==1))
   310    310     ){
   311    311       struct sqlite3InitInfo sv = db->init;
   312    312       memset(&db->init, 0, sizeof(struct sqlite3InitInfo));
   313    313       rc = sqlite3InitOne(db, iDb, pzErr, 0);
   314    314       db->init = sv;
................................................................................
   344    344   #endif
   345    345     while(1){
   346    346       for(i=OMIT_TEMPDB; i<db->nDb; i++){
   347    347         int j = (i<2) ? i^1 : i;   /* Search TEMP before MAIN */
   348    348         if( zDatabase==0 || sqlite3StrICmp(zDatabase, db->aDb[j].zDbSName)==0 ){
   349    349           int bUnload = 0;
   350    350           assert( sqlite3SchemaMutexHeld(db, j, 0) );
   351         -        if( IsReuseSchema(db) ){
          351  +        if( IsSharedSchema(db) ){
   352    352             Parse *pParse = db->pParse;
   353    353             if( pParse && pParse->nErr==0 ){
   354    354               pParse->rc = sqlite3SchemaLoad(db, j, &bUnload, &pParse->zErrMsg);
   355    355               if( pParse->rc ) pParse->nErr++;
   356    356             }
   357    357           }
   358    358           p = sqlite3HashFind(&db->aDb[j].pSchema->tblHash, zName);
................................................................................
   389    389   ){
   390    390     Table *p;
   391    391     sqlite3 *db = pParse->db;
   392    392   
   393    393     /* Read the database schema. If an error occurs, leave an error message
   394    394     ** and code in pParse and return NULL. */
   395    395     if( (db->mDbFlags & DBFLAG_SchemaKnownOk)==0 
   396         -   && !IsReuseSchema(db)
          396  +   && !IsSharedSchema(db)
   397    397      && SQLITE_OK!=sqlite3ReadSchema(pParse)
   398    398     ){
   399    399       return 0;
   400    400     }
   401    401   
   402    402     p = sqlite3FindTable(db, zName, zDbase);
   403    403     if( p==0 ){
................................................................................
   407    407       ** can be an eponymous virtual table. */
   408    408       if( pParse->disableVtab==0 ){
   409    409         Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
   410    410         if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
   411    411           pMod = sqlite3PragmaVtabRegister(db, zName);
   412    412         }
   413    413         if( pMod ){
   414         -        if( IsReuseSchema(db) && pParse->nErr==0 ){
          414  +        if( IsSharedSchema(db) && pParse->nErr==0 ){
   415    415             int bDummy = 0;
   416    416             pParse->rc = sqlite3SchemaLoad(db, 0, &bDummy, &pParse->zErrMsg);
   417    417             if( pParse->rc ) pParse->nErr++;
   418    418           }
   419    419           if( sqlite3VtabEponymousTableInit(pParse, pMod) ){
   420    420             Table *pEpoTab = pMod->pEpoTab;
   421         -          assert( IsReuseSchema(db) || pEpoTab->pSchema==db->aDb[0].pSchema );
          421  +          assert( IsSharedSchema(db) || pEpoTab->pSchema==db->aDb[0].pSchema );
   422    422             pEpoTab->pSchema = db->aDb[0].pSchema;  /* For SHARED_SCHEMA mode */
   423    423             return pEpoTab;
   424    424           }
   425    425         }
   426    426       }
   427    427   #endif
   428    428       if( flags & LOCATE_NOERR ) return 0;
   429    429       pParse->checkSchema = 1;
   430    430     }else if( IsVirtual(p) && pParse->disableVtab ){
   431    431       p = 0;
   432    432     }
   433    433   
   434         -  if( p==0 && (!IsReuseSchema(db) || pParse->nErr==0) ){
          434  +  if( p==0 && (!IsSharedSchema(db) || pParse->nErr==0) ){
   435    435       const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
   436    436       if( zDbase ){
   437    437         sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
   438    438       }else{
   439    439         sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
   440    440       }
   441    441     }
................................................................................
   994    994     ** it does. The exception is if the statement being parsed was passed
   995    995     ** to an sqlite3_declare_vtab() call. In that case only the column names
   996    996     ** and types will be used, so there is no need to test for namespace
   997    997     ** collisions.
   998    998     */
   999    999     if( !IN_SPECIAL_PARSE ){
  1000   1000       char *zDb = db->aDb[iDb].zDbSName;
  1001         -    if( !IsReuseSchema(db) && SQLITE_OK!=sqlite3ReadSchema(pParse) ){
         1001  +    if( !IsSharedSchema(db) && SQLITE_OK!=sqlite3ReadSchema(pParse) ){
  1002   1002         goto begin_table_error;
  1003   1003       }
  1004   1004       pTable = sqlite3FindTable(db, zName, zDb);
  1005   1005       if( pTable ){
  1006   1006         if( !noErr ){
  1007   1007           sqlite3ErrorMsg(pParse, "table %T already exists", pName);
  1008   1008         }else{
................................................................................
  2719   2719     int iDb;
  2720   2720   
  2721   2721     if( db->mallocFailed ){
  2722   2722       goto exit_drop_table;
  2723   2723     }
  2724   2724     assert( pParse->nErr==0 );
  2725   2725     assert( pName->nSrc==1 );
  2726         -  if( !IsReuseSchema(db) && sqlite3ReadSchema(pParse) ) goto exit_drop_table;
         2726  +  if( !IsSharedSchema(db) && sqlite3ReadSchema(pParse) ) goto exit_drop_table;
  2727   2727     if( noErr ) db->suppressErr++;
  2728   2728     assert( isView==0 || isView==LOCATE_VIEW );
  2729   2729     pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]);
  2730   2730     if( noErr ) db->suppressErr--;
  2731   2731   
  2732   2732     if( pTab==0 ){
  2733   2733       if( noErr ) sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);
................................................................................
  3143   3143   
  3144   3144     if( db->mallocFailed || pParse->nErr>0 ){
  3145   3145       goto exit_create_index;
  3146   3146     }
  3147   3147     if( IN_DECLARE_VTAB && idxType!=SQLITE_IDXTYPE_PRIMARYKEY ){
  3148   3148       goto exit_create_index;
  3149   3149     }
  3150         -  if( !IsReuseSchema(db) && SQLITE_OK!=sqlite3ReadSchema(pParse) ){
         3150  +  if( !IsSharedSchema(db) && SQLITE_OK!=sqlite3ReadSchema(pParse) ){
  3151   3151       goto exit_create_index;
  3152   3152     }
  3153   3153   
  3154   3154     /*
  3155   3155     ** Find the table that is to be indexed.  Return early if not found.
  3156   3156     */
  3157   3157     if( pTblName!=0 ){

Changes to src/callback.c.

    38     38     Schema *pSchema;                /* Linked list of Schema objects */
    39     39     Schema sSchema;                 /* The single dummy schema object */
    40     40     SchemaPool *pNext;              /* Next element in schemaPoolList */
    41     41   };
    42     42   
    43     43   #ifdef SQLITE_DEBUG
    44     44   static void assert_schema_state_ok(sqlite3 *db){
    45         -  if( IsReuseSchema(db) && db->magic!=SQLITE_MAGIC_ZOMBIE ){
           45  +  if( IsSharedSchema(db) && db->magic!=SQLITE_MAGIC_ZOMBIE ){
    46     46       int i;
    47     47       for(i=0; i<db->nDb; i++){
    48     48         if( i!=1 ){
    49     49           Db *pDb = &db->aDb[i];
    50     50           Btree *pBt = pDb->pBt;
    51     51           assert( pBt==0 || sqlite3BtreeSchema(pBt, 0, 0)==0 );
    52     52           assert( pDb->pSchema );
................................................................................
   525    525   ** database iDb. 
   526    526   **
   527    527   ** If an OOM error occurs while disconnecting from a schema-pool, 
   528    528   ** the db->mallocFailed flag is set.
   529    529   */
   530    530   void sqlite3SchemaClearOrDisconnect(sqlite3 *db, int iDb){
   531    531     Db *pDb = &db->aDb[iDb];
   532         -  if( IsReuseSchema(db) && iDb!=1 && pDb->pSPool ){
          532  +  if( IsSharedSchema(db) && iDb!=1 && pDb->pSPool ){
   533    533       sqlite3SchemaDisconnect(db, iDb, 1);
   534    534     }else{
   535    535       sqlite3SchemaClear(pDb->pSchema);
   536    536     }
   537    537   }
   538    538   
   539    539   /*
................................................................................
   575    575   /*
   576    576   ** Check that the schema of db iDb is writable (either because it is the 
   577    577   ** temp db schema or because the db handle was opened without
   578    578   ** SQLITE_OPEN_SHARED_SCHEMA). If so, do nothing. Otherwise, leave an 
   579    579   ** error in the Parse object.
   580    580   */
   581    581   void sqlite3SchemaWritable(Parse *pParse, int iDb){
   582         -  if( iDb!=1 && (pParse->db->openFlags & SQLITE_OPEN_SHARED_SCHEMA) 
   583         -   && IN_DECLARE_VTAB==0
   584         -  ){
          582  +  if( iDb!=1 && IsSharedSchema(pParse->db) && IN_DECLARE_VTAB==0 ){
   585    583       sqlite3ErrorMsg(pParse, "attempt to modify read-only schema");
   586    584     }
   587    585   }
   588    586   
   589    587   /*
   590    588   ** The schema object passed as the only argument was allocated using
   591    589   ** sqlite3_malloc() and then populated using the usual mechanism. This
................................................................................
   703    701   ** If the bNew parameter is true, then this function may allocate memory. 
   704    702   ** If the allocation attempt fails, then SQLITE_NOMEM is returned and the
   705    703   ** schema-pool is not disconnected from. Or, if no OOM error occurs, 
   706    704   ** SQLITE_OK is returned.
   707    705   */
   708    706   int sqlite3SchemaDisconnect(sqlite3 *db, int iDb, int bNew){
   709    707     int rc = SQLITE_OK;
   710         -  if( IsReuseSchema(db) ){
          708  +  if( IsSharedSchema(db) ){
   711    709       Db *pDb = &db->aDb[iDb];
   712    710       SchemaPool *pSPool = pDb->pSPool;
   713    711       assert_schema_state_ok(db);
   714    712       assert( pDb->pSchema );
   715    713   
   716    714       if( pSPool==0 ){
   717    715         assert( pDb->pVTable==0 );
................................................................................
   817    815   ** with BTree handle pBt, creating a new one if necessary. However, if
   818    816   ** the database handle was opened with the SQLITE_OPEN_SHARED_SCHEMA flag
   819    817   ** specified, a new, empty, Schema object in memory obtained by 
   820    818   ** sqlite3_malloc() is always returned.
   821    819   */
   822    820   Schema *sqlite3SchemaGet(sqlite3 *db, Btree *pBt){
   823    821     Schema *p;
   824         -  if( pBt && (db->openFlags & SQLITE_OPEN_SHARED_SCHEMA)==0 ){
          822  +  if( pBt && IsSharedSchema(db)==0 ){
   825    823       p = (Schema*)sqlite3BtreeSchema(pBt, sizeof(Schema), sqlite3SchemaClear);
   826    824     }else{
   827    825       db->lookaside.bDisable++;
   828    826       p = (Schema*)sqlite3DbMallocZero(db, sizeof(Schema));
   829    827       db->lookaside.bDisable--;
   830    828     }
   831    829     if( !p ){

Changes to src/main.c.

  1050   1050       Schema *pSchema = db->aDb[i].pSchema;
  1051   1051       if( pSchema ){
  1052   1052         for(p=sqliteHashFirst(&pSchema->tblHash); p; p=sqliteHashNext(p)){
  1053   1053           Table *pTab = (Table *)sqliteHashData(p);
  1054   1054           if( IsVirtual(pTab) ) sqlite3VtabDisconnect(db, pTab);
  1055   1055         }
  1056   1056       }
  1057         -    if( i!=1 && IsReuseSchema(db) ){
         1057  +    if( i!=1 && IsSharedSchema(db) ){
  1058   1058         VTable *pVTable;
  1059   1059         VTable *pNext;
  1060   1060         for(pVTable=db->aDb[i].pVTable; pVTable; pVTable=pNext){
  1061   1061           pNext = pVTable->pNext;
  1062   1062           sqlite3VtabUnlock(pVTable);
  1063   1063         }
  1064   1064         db->aDb[i].pVTable = 0;
................................................................................
  3622   3622     }
  3623   3623   #endif
  3624   3624   
  3625   3625     /* Ensure the database schema has been loaded */
  3626   3626     sqlite3_mutex_enter(db->mutex);
  3627   3627     bUnlock = sqlite3LockReusableSchema(db);
  3628   3628     sqlite3BtreeEnterAll(db);
  3629         -  if( IsReuseSchema(db)==0 ){
         3629  +  if( IsSharedSchema(db)==0 ){
  3630   3630       rc = sqlite3Init(db, &zErrMsg);
  3631   3631     }
  3632   3632   
  3633   3633     /* Locate the table in question */
  3634   3634     if( rc==SQLITE_OK ){
  3635   3635       Parse sParse;                   /* Fake Parse object for FindTable */
  3636   3636       Parse *pSaved = db->pParse;

Changes to src/pragma.c.

   416    416   
   417    417     /* Locate the pragma in the lookup table */
   418    418     pPragma = pragmaLocate(zLeft);
   419    419     if( pPragma==0 ) goto pragma_out;
   420    420   
   421    421     /* Make sure the database schema is loaded if the pragma requires that */
   422    422     if( (pPragma->mPragFlg & PragFlg_NeedSchema)!=0 ){
   423         -    if( IsReuseSchema(db) && (zDb || (pPragma->mPragFlg & PragFlg_OneSchema)) ){
          423  +    if( IsSharedSchema(db) && (zDb || (pPragma->mPragFlg & PragFlg_OneSchema)) ){
   424    424         assert( iDb>=0 && iDb<db->nDb );
   425    425         pParse->rc = sqlite3SchemaLoad(db, iDb, 0, &pParse->zErrMsg);
   426    426         if( pParse->rc ) goto pragma_out;
   427    427       }else{
   428    428         if( sqlite3ReadSchema(pParse) ) goto pragma_out;
   429    429       }
   430    430     }

Changes to src/prepare.c.

    30     30     }else if( pData->pzErrMsg[0]!=0 ){
    31     31       /* A error message has already been generated.  Do not overwrite it */
    32     32     }else if( pData->mInitFlags & INITFLAG_AlterTable ){
    33     33       *pData->pzErrMsg = sqlite3DbStrDup(db, zExtra);
    34     34       pData->rc = SQLITE_ERROR;
    35     35     }else if( db->flags & SQLITE_WriteSchema ){
    36     36       pData->rc = SQLITE_CORRUPT_BKPT;
    37         -  }else if( IsReuseSchema(db) 
           37  +  }else if( IsSharedSchema(db) 
    38     38            && 0==sqlite3StrNICmp(zExtra, "malformed database schema", 17)
    39     39     ){
    40     40       pData->rc = SQLITE_CORRUPT_BKPT;
    41     41       *pData->pzErrMsg = sqlite3DbStrDup(db, zExtra);
    42     42     }else{
    43     43       char *z;
    44     44       if( zObj==0 ) zObj = "?";
................................................................................
   165    165        || pIndex->tnum<2
   166    166        || sqlite3IndexHasDuplicateRootPage(pIndex)
   167    167       ){
   168    168         corruptSchema(pData, argv[0], pIndex?"invalid rootpage":"orphan index");
   169    169       }
   170    170     }
   171    171   
   172         -  if( iDb!=1 && (db->openFlags & SQLITE_OPEN_SHARED_SCHEMA) ){
          172  +  if( iDb!=1 && IsSharedSchema(db) ){
   173    173       schemaUpdateChecksum(pData, argv[0], argv[1], argv[2]);
   174    174     }
   175    175     return 0;
   176    176   }
   177    177   
   178    178   /*
   179    179   ** Attempt to read the database schema and initialize internal
................................................................................
   194    194     int meta[5];
   195    195     InitData initData;
   196    196     const char *zMasterName;
   197    197     int openedTransaction = 0;
   198    198   
   199    199     assert( (db->mDbFlags & DBFLAG_SchemaKnownOk)==0 );
   200    200     assert( iDb>=0 && iDb<db->nDb );
   201         -  assert( db->aDb[iDb].pSchema || (IsReuseSchema(db) && iDb!=1) );
          201  +  assert( db->aDb[iDb].pSchema || (IsSharedSchema(db) && iDb!=1) );
   202    202     assert( sqlite3_mutex_held(db->mutex) );
   203    203     assert( iDb==1 || sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) );
   204    204   
   205    205     pDb = &db->aDb[iDb];
   206         -  assert( pDb->pSPool==0 || IsReuseSchema(db) );
          206  +  assert( pDb->pSPool==0 || IsSharedSchema(db) );
   207    207     if( pDb->pSPool ){
   208    208       /* See if there is a free schema object in the schema-pool. If not,
   209    209       ** disconnect from said schema pool and continue. This function will
   210    210       ** connect to a (possibly different) schema-pool before returning. */
   211    211       Schema *pNew = sqlite3SchemaExtract(pDb->pSPool);
   212    212       if( pNew ){
   213    213         pDb->pSchema = pNew;
................................................................................
   396    396       ** purpose of this is to allow access to the sqlite_master table
   397    397       ** even when its contents have been corrupted.
   398    398       */
   399    399       DbSetProperty(db, iDb, DB_SchemaLoaded);
   400    400       rc = SQLITE_OK;
   401    401     }
   402    402   
   403         -  if( rc==SQLITE_OK && iDb!=1 && (db->openFlags & SQLITE_OPEN_SHARED_SCHEMA) ){
          403  +  if( rc==SQLITE_OK && iDb!=1 && IsSharedSchema(db) ){
   404    404       rc = sqlite3SchemaConnect(db, iDb, initData.cksum);
   405    405     }
   406    406   
   407    407     /* Jump here for an error that occurs after successfully allocating
   408    408     ** curMain and calling sqlite3BtreeEnter(). For an error that occurs
   409    409     ** before that point, jump to error_out.
   410    410     */
................................................................................
   422    422       sqlite3ResetOneSchema(db, iDb);
   423    423     }
   424    424     db->init.busy = 0;
   425    425     return rc;
   426    426   }
   427    427   
   428    428   int sqlite3LockReusableSchema(sqlite3 *db){
   429         -  if( IsReuseSchema(db) && (db->mDbFlags & DBFLAG_SchemaInuse)==0 ){
          429  +  if( IsSharedSchema(db) && (db->mDbFlags & DBFLAG_SchemaInuse)==0 ){
   430    430       db->mDbFlags |= DBFLAG_SchemaInuse;
   431    431       return 1;
   432    432     }
   433    433     return 0;
   434    434   }
   435    435   void sqlite3UnlockReusableSchema(sqlite3 *db, int bRelease){
   436    436     if( bRelease ){
................................................................................
   490    490     assert( sqlite3_mutex_held(db->mutex) );
   491    491     if( !db->init.busy ){
   492    492       db->mDbFlags |= DBFLAG_FreeSchema;      /* For sharable-schema mode */
   493    493       rc = sqlite3Init(db, &pParse->zErrMsg);
   494    494       if( rc!=SQLITE_OK ){
   495    495         pParse->rc = rc;
   496    496         pParse->nErr++;
   497         -    }else if( db->noSharedCache && !IsReuseSchema(db) ){
          497  +    }else if( db->noSharedCache && !IsSharedSchema(db) ){
   498    498         db->mDbFlags |= DBFLAG_SchemaKnownOk;
   499    499       }
   500    500     }
   501    501     return rc;
   502    502   }
   503    503   
   504    504   

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_SHARED_SCHEMA)!=0)
         1508  +#define IsSharedSchema(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   
................................................................................
  3263   3263     u8 op;                  /* One of TK_DELETE, TK_UPDATE, TK_INSERT         */
  3264   3264     u8 tr_tm;               /* One of TRIGGER_BEFORE, TRIGGER_AFTER */
  3265   3265     Expr *pWhen;            /* The WHEN clause of the expression (may be NULL) */
  3266   3266     IdList *pColumns;       /* If this is an UPDATE OF <column-list> trigger,
  3267   3267                                the <column-list> is stored here */
  3268   3268     Schema *pSchema;        /* Schema containing the trigger */
  3269   3269     Schema *pTabSchema;     /* Schema containing the table */
  3270         -  char *zTabSchema;       /* Temp triggers in IsReuseSchema() dbs only */
         3270  +  char *zTabSchema;       /* Temp triggers in IsSharedSchema() dbs only */
  3271   3271     TriggerStep *step_list; /* Link list of trigger program steps             */
  3272   3272     Trigger *pNext;         /* Next trigger associated with the table */
  3273   3273   };
  3274   3274   
  3275   3275   /*
  3276   3276   ** A trigger is either a BEFORE or an AFTER trigger.  The following constants
  3277   3277   ** determine which.

Changes to src/trigger.c.

    54     54       return 0;
    55     55     }
    56     56   
    57     57     if( pTmpSchema!=pTab->pSchema ){
    58     58       sqlite3 *db = pParse->db;
    59     59       HashElem *p;
    60     60       char *zSchema = 0;
    61         -    if( IsReuseSchema(db) ){
           61  +    if( IsSharedSchema(db) ){
    62     62         zSchema = db->aDb[sqlite3SchemaToIndex(db, pTab->pSchema)].zDbSName;
    63     63       }
    64     64       assert( sqlite3SchemaMutexHeld(db, 0, pTmpSchema) );
    65     65       for(p=sqliteHashFirst(&pTmpSchema->trigHash); p; p=sqliteHashNext(p)){
    66     66         Trigger *pTrig = (Trigger *)sqliteHashData(p);
    67     67         if( (zSchema==0 && pTrig->pTabSchema==pTab->pSchema)
    68     68          || (zSchema!=0 && 0==sqlite3StrICmp(pTrig->zTabSchema, zSchema))
................................................................................
   249    249   
   250    250     /* Build the Trigger object */
   251    251     pTrigger = (Trigger*)sqlite3DbMallocZero(db, sizeof(Trigger));
   252    252     if( pTrigger==0 ) goto trigger_cleanup;
   253    253     pTrigger->zName = zName;
   254    254     zName = 0;
   255    255     pTrigger->table = sqlite3DbStrDup(db, pTableName->a[0].zName);
   256         -  if( IsReuseSchema(db) && iDb==1 ){
          256  +  if( IsSharedSchema(db) && iDb==1 ){
   257    257       int iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);
   258    258       pTrigger->zTabSchema = sqlite3DbStrDup(db, db->aDb[iTabDb].zDbSName);
   259    259     }
   260    260     pTrigger->pSchema = db->aDb[iDb].pSchema;
   261    261     pTrigger->pTabSchema = pTab->pSchema;
   262    262     pTrigger->op = (u8)op;
   263    263     pTrigger->tr_tm = tr_tm==TK_BEFORE ? TRIGGER_BEFORE : TRIGGER_AFTER;

Changes to src/vtab.c.

   140    140   ** pTab is a pointer to a Table structure representing a virtual-table.
   141    141   ** Return a pointer to the VTable object used by connection db to access 
   142    142   ** this virtual-table, if one has been created, or NULL otherwise.
   143    143   */
   144    144   VTable *sqlite3GetVTable(sqlite3 *db, Table *pTab){
   145    145     VTable *pVtab;
   146    146     assert( IsVirtual(pTab) );
   147         -  if( IsReuseSchema(db) ){
          147  +  if( IsSharedSchema(db) ){
   148    148       int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
   149    149       if( iDb!=1 ){
   150    150         for(pVtab=db->aDb[iDb].pVTable; pVtab; pVtab=pVtab->pNext){
   151    151           if( sqlite3StrICmp(pTab->zName, pVtab->zName)==0 ) break;
   152    152         }
   153    153         return pVtab;
   154    154       }
................................................................................
   587    587         /* If everything went according to plan, link the new VTable structure
   588    588         ** into the linked list headed by pTab->pVTable. Or, if this is a
   589    589         ** reusable schema, into the linked list headed by Db.pVTable.
   590    590         **
   591    591         ** Then loop through the columns of the table to see if any of them
   592    592         ** contain the token "hidden". If so, set the Column COLFLAG_HIDDEN flag
   593    593         ** and remove the token from the type string.  */
   594         -      if( IsReuseSchema(db) && iDb!=1 ){
          594  +      if( IsSharedSchema(db) && iDb!=1 ){
   595    595           pVTable->pNext = db->aDb[iDb].pVTable;
   596    596           db->aDb[iDb].pVTable = pVTable;
   597    597         }else{
   598    598           pVTable->pNext = pTab->pVTable;
   599    599           pTab->pVTable = pVTable;
   600    600         }
   601    601