if( rc==SQLITE_OK && db->nDb>1 && !DbHasProperty(db, 1, DB_SchemaLoaded) ){ rc = sqliteInitOne(db, 1, pzErrMsg); if( rc ){ sqliteResetInternalSchema(db, 1); } }
int sqliteInit(sqlite *db, char **pzErrMsg){  int i, rc;    if( db->init.busy ) return SQLITE_OK;  assert( (db->flags & SQLITE_Initialized)==0 );  rc = SQLITE_OK;  db->init.busy = 1;  for(i=0; rc==SQLITE_OK && i<db->nDb; i++){    if( DbHasProperty(db, i, DB_SchemaLoaded) ) continue;    assert( i!=1 );  /* Should have been initialized together with 0 */    rc = sqliteInitOne(db, i, pzErrMsg);    if( rc ){      sqliteResetInternalSchema(db, i);    }  }  db->init.busy = 0;  if( rc==SQLITE_OK ){    db->flags |= SQLITE_Initialized;    sqliteCommitInternalChanges(db);  }  /* If the database is in formats 1 or 2, then upgrade it to  ** version 3.  This will reconstruct all indices.  If the  ** upgrade fails for any reason (ex: out of disk space, database  ** is read only, interrupt received, etc.) then fail the init.  */  if( rc==SQLITE_OK && db->file_format<3 ){    char *zErr = 0;    InitData initData;    int meta[SQLITE_N_BTREE_META];    db->magic = SQLITE_MAGIC_OPEN;    initData.db = db;    initData.pzErrMsg = &zErr;    db->file_format = 3;    rc = sqlite_exec(db,      "BEGIN; SELECT name FROM sqlite_master WHERE type='table';",      upgrade_3_callback,      &initData,      &zErr);    if( rc==SQLITE_OK ){      sqliteBtreeGetMeta(db->aDb[0].pBt, meta);      meta[2] = 4;      sqliteBtreeUpdateMeta(db->aDb[0].pBt, meta);      sqlite_exec(db, "COMMIT", 0, 0, 0);    }    if( rc!=SQLITE_OK ){      sqliteSetString(pzErrMsg,         "unable to upgrade database to the version 2.6 format",        zErr ? ": " : 0, zErr, (char*)0);    }    sqlite_freemem(zErr);  }  if( rc!=SQLITE_OK ){    db->flags &= ~SQLITE_Initialized;  }  return rc;}