Lines Matching refs:iDb
8948 int iDb; /* When back is being initialized */
9380 ** database file. If Table.iDb is the index of the database table backend
10227 int iDb; /* Index in sqlite3.aDb[] of database holding pTab */
10521 int iDb; /* 0 for main database. 1 for TEMP, 2.. for ATTACHed */
10839 SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
11089 SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3*,int iDB);
12013 int iDb; /* Index of cursor database in db->aDb[] (or -1) */
47135 int iDb;
47136 for(iDb=db->nDb-1; iDb>=0; iDb--){
47137 Btree *pExisting = db->aDb[iDb].pBt;
60107 int iDb, /* When database the cursor belongs to, or -1 */
60145 pCx->iDb = iDb;
60713 int iDb;
60727 int iDb;
60852 int iDb;
60863 int iDb;
63265 int iDb;
63269 u.at.iDb = pOp->p1;
63272 assert( u.at.iDb>=0 && u.at.iDb<db->nDb );
63273 assert( db->aDb[u.at.iDb].pBt!=0 );
63274 assert( (p->btreeMask & (1<<u.at.iDb))!=0 );
63276 sqlite3BtreeGetMeta(db->aDb[u.at.iDb].pBt, u.at.iCookie, (u32 *)&u.at.iMeta);
63431 int iDb;
63446 u.aw.iDb = pOp->p3;
63447 assert( u.aw.iDb>=0 && u.aw.iDb<db->nDb );
63448 assert( (p->btreeMask & (1<<u.aw.iDb))!=0 );
63449 u.aw.pDb = &db->aDb[u.aw.iDb];
63485 u.aw.pCur = allocateCursor(p, pOp->p1, u.aw.nField, u.aw.iDb, 1);
64363 u.bf.zDb = db->aDb[u.bf.pC->iDb].zName;
64368 assert( u.bf.pC->iDb>=0 );
64431 const char *zDb = db->aDb[u.bg.pC->iDb].zName;
64434 assert( u.bg.pC->iDb>=0 );
64967 int iDb;
64984 u.br.iDb = pOp->p3;
64986 assert( (p->btreeMask & (1<<u.br.iDb))!=0 );
64987 rc = sqlite3BtreeDropTable(db->aDb[u.br.iDb].pBt, pOp->p1, &u.br.iMoved);
64992 sqlite3RootPageMoved(&db->aDb[u.br.iDb], u.br.iMoved, pOp->p1);
65099 int iDb;
65105 u.bu.iDb = pOp->p1;
65106 assert( u.bu.iDb>=0 && u.bu.iDb<db->nDb );
65116 ** database u.bu.iDb (the database containing the sqlite_master table
65119 ** the schema of u.bu.iDb is loaded. This is because, at the start of
65122 ** u.bu.iDb mutex may be temporarily released to avoid deadlock. If
65124 ** schema of database u.bu.iDb before the SQL statement runs. The schema
65129 assert( sqlite3BtreeHoldsMutex(db->aDb[u.bu.iDb].pBt) );
65131 if( pOp->p2 || DbHasProperty(db, u.bu.iDb, DB_SchemaLoaded) ){
65132 u.bu.zMaster = SCHEMA_TABLE(u.bu.iDb);
65134 u.bu.initData.iDb = pOp->p1;
65138 db->aDb[u.bu.iDb].zName, u.bu.zMaster, pOp->p4.z);
65779 ** iDb index of the database as a parameter, and the database has not
66749 int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
66755 sqlite3VdbeChangeP1(v, 0, iDb);
66759 sqlite3VdbeChangeP1(v, 1, iDb);
66763 sqlite3VdbeUsesBtree(v, iDb);
66769 sqlite3VdbeChangeP1(v, 2, iDb);
66779 sqlite3VdbeChangeP3(v, 3 + flags, iDb);
67701 ** pExpr->iDb Set the index in db->aDb[] of the database X
67757 int iDb;
67762 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
67773 if( zDb!=0 && sqlite3StrICmp(db->aDb[iDb].zName, zDb)!=0 ){
70250 int iDb; /* Database idx for pTab */
70253 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
70254 sqlite3CodeVerifySchema(pParse, iDb);
70255 sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
70269 sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
70301 sqlite3VdbeAddOp4(v, OP_OpenRead, iTab, pIdx->tnum, iDb,
72890 int iDb; /* Index of database containing pTab */
72898 iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
72899 assert( iDb>=0 );
72905 assert( iTrigDb==iDb || iTrigDb==1 );
72911 sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);
72916 sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 0, 0, zWhere, P4_DYNAMIC);
72937 int iDb; /* Database that contains the table */
72938 char *zDb; /* Name of database iDb */
72958 iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
72959 zDb = db->aDb[iDb].zName;
72967 ** in database iDb. If so, this is an error.
73014 /* Begin a transaction and code the VerifyCookie for database iDb.
73023 sqlite3BeginWriteOperation(pParse, pVTab!=0, iDb);
73024 sqlite3ChangeCookie(pParse, iDb);
73053 "WHERE %s;", zDb, SCHEMA_TABLE(iDb), zTabName, zName, zWhere);
73077 zDb, SCHEMA_TABLE(iDb), zName, zName, zName,
73136 SQLITE_PRIVATE void sqlite3MinimumFileFormat(Parse *pParse, int iDb, int minFormat){
73146 sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT);
73147 sqlite3VdbeUsesBtree(v, iDb);
73150 sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, r2);
73168 int iDb; /* Database number */
73182 iDb = sqlite3SchemaToIndex(db, pNew->pSchema);
73183 zDb = db->aDb[iDb].zName;
73257 zDb, SCHEMA_TABLE(iDb), pNew->addColOffset, zCol, pNew->addColOffset+1,
73268 sqlite3MinimumFileFormat(pParse, iDb, pDflt ? 3 : 2);
73293 int iDb;
73319 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
73351 pNew->pSchema = db->aDb[iDb].pSchema;
73356 sqlite3BeginWriteOperation(pParse, 0, iDb);
73359 sqlite3ChangeCookie(pParse, iDb);
73402 int iDb, /* The database we are looking in */
73426 pDb = &db->aDb[iDb];
73446 sqlite3TableLock(pParse, iDb, aRoot[i], 1, zTab);
73453 sqlite3VdbeAddOp2(v, OP_Clear, aRoot[i], iDb);
73460 sqlite3VdbeAddOp3(v, OP_OpenWrite, iStatCur+i, aRoot[i], iDb);
73485 int iDb; /* Index of database containing pTab */
73515 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
73516 assert( iDb>=0 );
73519 db->aDb[iDb].zName ) ){
73525 sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
73538 assert( iDb==sqlite3SchemaToIndex(db, pIdx->pSchema) );
73539 sqlite3VdbeAddOp4(v, OP_OpenRead, iIdxCur, pIdx->tnum, iDb,
73701 sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pTab->tnum, iDb);
73725 static void loadAnalysis(Parse *pParse, int iDb){
73728 sqlite3VdbeAddOp1(v, OP_LoadAnalysis, iDb);
73735 static void analyzeDatabase(Parse *pParse, int iDb){
73737 Schema *pSchema = db->aDb[iDb].pSchema; /* Schema of database iDb */
73742 sqlite3BeginWriteOperation(pParse, 0, iDb);
73745 openStatTable(pParse, iDb, iStatCur, 0);
73751 loadAnalysis(pParse, iDb);
73759 int iDb;
73764 iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
73765 sqlite3BeginWriteOperation(pParse, 0, iDb);
73768 openStatTable(pParse, iDb, iStatCur, pTab->zName);
73770 loadAnalysis(pParse, iDb);
73787 int iDb;
73809 iDb = sqlite3FindDb(db, pName1);
73810 if( iDb>=0 ){
73811 analyzeDatabase(pParse, iDb);
73824 iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pTableName);
73825 if( iDb>=0 ){
73826 zDb = db->aDb[iDb].zName;
73941 SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
73947 assert( iDb>=0 && iDb<db->nDb );
73948 assert( db->aDb[iDb].pBt!=0 );
73949 assert( sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) );
73952 for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){
73961 sInfo.zDatabase = db->aDb[iDb].zName;
74254 int iDb = db->nDb - 1;
74255 assert( iDb>=2 );
74256 if( db->aDb[iDb].pBt ){
74257 sqlite3BtreeClose(db->aDb[iDb].pBt);
74258 db->aDb[iDb].pBt = 0;
74259 db->aDb[iDb].pSchema = 0;
74262 db->nDb = iDb;
74466 int iDb, /* This is the database that must be used */
74472 if( NEVER(iDb<0) || iDb==1 ) return 0;
74474 assert( db->nDb>iDb );
74476 pFix->zDb = db->aDb[iDb].zName;
74704 int iDb
74707 char *zDb = db->aDb[iDb].zName; /* Name of attached database */
74712 if( db->nDb>2 || iDb!=0 ){
74743 int iDb; /* The index of the database the expression refers to */
74747 iDb = sqlite3SchemaToIndex(pParse->db, pSchema);
74748 if( iDb<0 ){
74778 assert( iDb>=0 && iDb<db->nDb );
74779 if( SQLITE_IGNORE==sqlite3AuthReadCol(pParse, pTab->zName, zCol, iDb) ){
74892 int iDb; /* The database containing the table to be locked */
74901 ** The table to be locked has root page iTab and is found in database iDb.
74910 int iDb, /* Index of the database containing the table to lock */
74919 assert( iDb>=0 );
74923 if( p->iDb==iDb && p->iTab==iTab ){
74934 p->iDb = iDb;
74957 int p1 = p->iDb;
75002 int iDb;
75004 for(iDb=0, mask=1; iDb<db->nDb; mask<<=1, iDb++){
75006 sqlite3VdbeUsesBtree(v, iDb);
75007 sqlite3VdbeAddOp2(v,OP_Transaction, iDb, (mask & pParse->writeMask)!=0);
75009 sqlite3VdbeAddOp2(v,OP_VerifyCookie, iDb, pParse->cookieValue[iDb]);
75207 ** For the index called zIdxName which is found in the database iDb,
75212 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3 *db, int iDb, const char *zIdxName){
75215 Hash *pHash = &db->aDb[iDb].pSchema->idxHash;
75244 ** If iDb==0 then reset the internal schema tables for all database
75245 ** files. If iDb>=1 then reset the internal schema for only the
75248 SQLITE_PRIVATE void sqlite3ResetInternalSchema(sqlite3 *db, int iDb){
75250 assert( iDb>=0 && iDb<db->nDb );
75252 if( iDb==0 ){
75255 for(i=iDb; i<db->nDb; i++){
75261 if( iDb>0 ) return;
75263 assert( iDb==0 );
75376 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3 *db, int iDb, const char *zTabName){
75381 assert( iDb>=0 && iDb<db->nDb );
75384 pDb = &db->aDb[iDb];
75416 ** Open the sqlite_master table stored in database number iDb for
75419 SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *p, int iDb){
75421 sqlite3TableLock(p, iDb, MASTER_ROOT, 1, SCHEMA_TABLE(iDb));
75422 sqlite3VdbeAddOp3(v, OP_OpenWrite, 0, MASTER_ROOT, iDb);
75487 int iDb; /* Database holding the object */
75497 iDb = sqlite3FindDb(db, pName1);
75498 if( iDb<0 ){
75504 assert( db->init.iDb==0 || db->init.busy );
75505 iDb = db->init.iDb;
75508 return iDb;
75557 int iDb; /* Database number to create the table in */
75573 ** pName2) that stores the unqualified table name. The variable iDb is
75577 iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);
75578 if( iDb<0 ) return;
75579 if( !OMIT_TEMPDB && isTemp && pName2->n>0 && iDb!=1 ){
75585 if( !OMIT_TEMPDB && isTemp ) iDb = 1;
75593 if( db->init.iDb==1 ) isTemp = 1;
75598 char *zDb = db->aDb[iDb].zName;
75629 char *zDb = db->aDb[iDb].zName;
75655 pTable->pSchema = db->aDb[iDb].pSchema;
75683 sqlite3BeginWriteOperation(pParse, 0, iDb);
75697 sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, reg3, BTREE_FILE_FORMAT);
75698 sqlite3VdbeUsesBtree(v, iDb);
75703 sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, reg3);
75705 iDb, BTREE_TEXT_ENCODING, reg3);
75723 sqlite3VdbeAddOp2(v, OP_CreateTable, iDb, reg2);
75725 sqlite3OpenMasterTable(pParse, iDb);
76123 SQLITE_PRIVATE void sqlite3ChangeCookie(Parse *pParse, int iDb){
76127 sqlite3VdbeAddOp2(v, OP_Integer, db->aDb[iDb].pSchema->schema_cookie+1, r1);
76128 sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_SCHEMA_VERSION, r1);
76281 int iDb;
76291 iDb = sqlite3SchemaToIndex(db, p->pSchema);
76376 sqlite3VdbeAddOp3(v, OP_OpenWrite, 1, pParse->regRoot, iDb);
76412 db->aDb[iDb].zName, SCHEMA_TABLE(iDb),
76421 sqlite3ChangeCookie(pParse, iDb);
76428 Db *pDb = &db->aDb[iDb];
76439 sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 0, 0,
76494 int iDb;
76509 iDb = sqlite3SchemaToIndex(db, p->pSchema);
76510 if( sqlite3FixInit(&sFix, pParse, iDb, "view", pName)
76671 ** root-page of a table or index in database iDb has changed from iFrom
76708 ** Write code to erase the table with root-page iTable from database iDb.
76713 iDb){
76716 sqlite3VdbeAddOp3(v, OP_Destroy, iTable, r1, iDb);
76730 pParse->db->aDb[iDb].zName, SCHEMA_TABLE(iDb), iTable, r1, r1);
76744 int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
76745 destroyRootPage(pParse, pTab->tnum, iDb);
76747 destroyRootPage(pParse, pIdx->tnum, iDb);
76786 int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
76787 destroyRootPage(pParse, iLargest, iDb);
76802 int iDb;
76817 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
76818 assert( iDb>=0 && iDb<db->nDb );
76829 const char *zTab = SCHEMA_TABLE(iDb);
76830 const char *zDb = db->aDb[iDb].zName;
76836 if( !OMIT_TEMPDB && iDb==1 ){
76847 if( !OMIT_TEMPDB && iDb==1 ){
76886 Db *pDb = &db->aDb[iDb];
76887 sqlite3BeginWriteOperation(pParse, 1, iDb);
76931 pDb->zName, SCHEMA_TABLE(iDb), pTab->zName);
76934 if( sqlite3FindTable(db, "sqlite_stat1", db->aDb[iDb].zName) ){
76948 sqlite3VdbeAddOp4(v, OP_VDestroy, iDb, 0, 0, pTab->zName, 0);
76950 sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);
76951 sqlite3ChangeCookie(pParse, iDb);
76953 sqliteViewResetAll(db, iDb);
77127 int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);
77131 db->aDb[iDb].zName ) ){
77137 sqlite3TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName);
77145 sqlite3VdbeAddOp2(v, OP_Clear, tnum, iDb);
77148 sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, iDb,
77153 sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
77223 int iDb; /* Index of the database that is being written */
77249 iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);
77250 if( iDb<0 ) goto exit_create_index;
77260 iDb = 1;
77265 if( sqlite3FixInit(&sFix, pParse, iDb, "index", pName) &&
77275 assert( db->aDb[iDb].pSchema==pTab->pSchema );
77280 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
77282 pDb = &db->aDb[iDb];
77350 if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(iDb), 0, zDb) ){
77354 if( !OMIT_TEMPDB && iDb==1 ) i = SQLITE_CREATE_TEMP_INDEX;
77417 pIndex->pSchema = db->aDb[iDb].pSchema;
77587 sqlite3BeginWriteOperation(pParse, 1, iDb);
77588 sqlite3VdbeAddOp2(v, OP_CreateIndex, iDb, iMem);
77610 db->aDb[iDb].zName, SCHEMA_TABLE(iDb),
77623 sqlite3ChangeCookie(pParse, iDb);
77624 sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 0, 0,
77709 int iDb;
77732 iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);
77737 const char *zDb = db->aDb[iDb].zName;
77738 const char *zTab = SCHEMA_TABLE(iDb);
77742 if( !OMIT_TEMPDB && iDb ) code = SQLITE_DROP_TEMP_INDEX;
77752 sqlite3BeginWriteOperation(pParse, 1, iDb);
77755 db->aDb[iDb].zName, SCHEMA_TABLE(iDb),
77758 if( sqlite3FindTable(db, "sqlite_stat1", db->aDb[iDb].zName) ){
77761 db->aDb[iDb].zName, pIndex->zName
77764 sqlite3ChangeCookie(pParse, iDb);
77765 destroyRootPage(pParse, pIndex->tnum, iDb);
77766 sqlite3VdbeAddOp4(v, OP_DropIndex, iDb, 0, 0, pIndex->zName, 0);
78281 ** If iDb<0 then code the OP_Goto only - don't set flag to verify the
78285 SQLITE_PRIVATE void sqlite3CodeVerifySchema(Parse *pParse, int iDb){
78293 if( iDb>=0 ){
78297 assert( iDb<db->nDb );
78298 assert( db->aDb[iDb].pBt!=0 || iDb==1 );
78299 assert( iDb<SQLITE_MAX_ATTACHED+2 );
78300 mask = 1<<iDb;
78303 pToplevel->cookieValue[iDb] = db->aDb[iDb].pSchema->schema_cookie;
78304 if( !OMIT_TEMPDB && iDb==1 ){
78324 SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse *pParse, int setStatement, int iDb){
78326 sqlite3CodeVerifySchema(pParse, iDb);
78327 pToplevel->writeMask |= 1<<iDb;
78406 int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
78407 sqlite3BeginWriteOperation(pParse, 0, iDb);
78422 int iDb; /* The database index number */
78427 for(iDb=0, pDb=db->aDb; iDb<db->nDb; iDb++, pDb++){
78457 int iDb; /* The database index number */
78483 iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pObjName);
78484 if( iDb<0 ) return;
78487 zDb = db->aDb[iDb].zName;
78497 sqlite3BeginWriteOperation(pParse, 0, iDb);
79228 int iDb; /* Database number */
79276 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
79277 assert( iDb<db->nDb );
79278 zDb = db->aDb[iDb].zName;
79307 sqlite3BeginWriteOperation(pParse, 1, iDb);
79344 sqlite3VdbeAddOp4(v, OP_Clear, pTab->tnum, iDb, memCnt,
79348 sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb);
81545 int iDb, /* Index of database housing pTab */
81597 sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenRead);
81609 sqlite3VdbeAddOp3(v, OP_OpenRead, iCur, pIdx->tnum, iDb);
81921 int iDb; /* Index of database containing pTab */
81932 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
81933 zDb = db->aDb[iDb].zName;
81978 rcauth = sqlite3AuthReadCol(pParse, pTo->zName, zCol, iDb);
81987 sqlite3TableLock(pParse, iDb, pTo->tnum, 0, pTo->zName);
81994 fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regOld, -1,isIgnore);
81999 fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regNew, +1,isIgnore);
82444 int iDb, /* The database index in sqlite3.aDb[] */
82452 sqlite3TableLock(p, iDb, pTab->tnum, (opcode==OP_OpenWrite)?1:0, pTab->zName);
82453 sqlite3VdbeAddOp3(v, opcode, iCur, pTab->tnum, iDb);
82551 ** Return non-zero if the table pTab in database iDb or any of its indices
82554 ** a statement of the form "INSERT INTO <iDb, pTab> SELECT ..." can
82557 static int readsTable(Parse *p, int iStartAddr, int iDb, Table *pTab){
82568 if( pOp->opcode==OP_OpenRead && pOp->p3==iDb ){
82594 ** which is in database iDb. Return the register number for the register
82614 int iDb, /* Index of the database holding pTab */
82630 pInfo->iDb = iDb;
82659 pDb = &db->aDb[p->iDb];
82661 sqlite3OpenTable(pParse, 0, p->iDb, pDb->pSchema->pSeqTab, OP_OpenRead);
82705 Db *pDb = &db->aDb[p->iDb];
82711 sqlite3OpenTable(pParse, 0, p->iDb, pDb->pSchema->pSeqTab, OP_OpenWrite);
82878 int iDb; /* Index of database holding TABLE */
82914 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
82915 assert( iDb<db->nDb );
82916 pDb = &db->aDb[iDb];
82960 sqlite3BeginWriteOperation(pParse, pSelect || pTrigger, iDb);
82972 if( pColumn==0 && xferOptimization(pParse, pTab, pSelect, onError, iDb) ){
82982 regAutoinc = autoIncBegin(pParse, iDb, pTab);
83049 if( pTrigger || readsTable(pParse, addrSelect, iDb, pTab) ){
83911 int iDb;
83916 iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
83919 sqlite3OpenTable(pParse, baseCur, iDb, pTab, op);
83923 sqlite3VdbeAddOp4(v, op, i+baseCur, pIdx->tnum, iDb,
85781 int iDb; /* Database index for <database> */
85789 /* Interpret the [database.] part of the pragma statement. iDb is the
85791 iDb = sqlite3TwoPartName(pParse, pId1, pId2, &pId);
85792 if( iDb<0 ) return;
85793 pDb = &db->aDb[iDb];
85798 if( iDb==1 && sqlite3OpenTempDatabase(pParse) ){
85846 sqlite3VdbeUsesBtree(v, iDb);
85852 sqlite3VdbeChangeP1(v, addr, iDb);
85853 sqlite3VdbeChangeP1(v, addr+1, iDb);
85858 sqlite3BeginWriteOperation(pParse, 0, iDb);
85860 sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_DEFAULT_CACHE_SIZE, 1);
85935 sqlite3CodeVerifySchema(pParse, iDb);
85938 sqlite3VdbeAddOp2(v, OP_Pagecount, iDb, iReg);
85940 sqlite3VdbeAddOp3(v, OP_MaxPgcnt, iDb, iReg, sqlite3Atoi(zRight));
86030 iDb = 0;
86034 if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){
86110 sqlite3VdbeChangeP1(v, iAddr, iDb);
86111 sqlite3VdbeChangeP1(v, iAddr+1, iDb);
86114 sqlite3VdbeChangeP1(v, iAddr+5, iDb);
86115 sqlite3VdbeUsesBtree(v, iDb);
86136 sqlite3BeginWriteOperation(pParse, 0, iDb);
86138 addr = sqlite3VdbeAddOp1(v, OP_IncrVacuum, iDb);
86794 sqlite3VdbeUsesBtree(v, iDb);
86815 sqlite3VdbeChangeP1(v, addr, iDb);
86817 sqlite3VdbeChangeP1(v, addr+2, iDb);
86827 sqlite3VdbeChangeP1(v, addr, iDb);
86828 sqlite3VdbeChangeP1(v, addr+1, iDb);
86864 sqlite3VdbeAddOp3(v, OP_Checkpoint, pId2->z?iDb:SQLITE_MAX_ATTACHED, 0, 0);
87033 int iDb = pData->iDb;
87038 DbClearProperty(db, iDb, DB_Empty);
87044 assert( iDb>=0 && iDb<db->nDb );
87059 db->init.iDb = iDb;
87065 db->init.iDb = 0;
87068 assert( iDb==1 );
87089 pIndex = sqlite3FindIndex(db, argv[0], db->aDb[iDb].zName);
87107 ** database file is given by iDb. iDb==0 is used for the main
87108 ** database. iDb==1 should never be used. iDb>=2 is used for
87112 static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){
87122 char const *zMasterName = SCHEMA_TABLE(iDb);
87151 assert( iDb>=0 && iDb<db->nDb );
87152 assert( db->aDb[iDb].pSchema );
87154 assert( iDb==1 || sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) );
87160 if( !OMIT_TEMPDB && iDb==1 ){
87165 zMasterName = SCHEMA_TABLE(iDb);
87173 initData.iDb = iDb;
87181 pTab = sqlite3FindTable(db, zMasterName, db->aDb[iDb].zName);
87188 pDb = &db->aDb[iDb];
87190 if( !OMIT_TEMPDB && ALWAYS(iDb==1) ){
87237 if( iDb==0 ){
87254 DbSetProperty(db, iDb, DB_Empty);
87287 if( iDb==0 && meta[BTREE_FILE_FORMAT-1]>=4 ){
87298 db->aDb[iDb].zName, zMasterName);
87314 sqlite3AnalysisLoad(db, iDb);
87331 DbSetProperty(db, iDb, DB_SchemaLoaded);
87425 int iDb;
87431 for(iDb=0; iDb<db->nDb; iDb++){
87433 Btree *pBt = db->aDb[iDb].pBt; /* Btree database to read cookie from */
87452 if( cookie!=db->aDb[iDb].pSchema->schema_cookie ){
87464 ** Convert a schema pointer into the iDb index that indicates
88902 int iDb = sqlite3SchemaToIndex(pNC->pParse->db, pTab->pSchema);
88903 zOriginDb = pNC->pParse->db->aDb[iDb].zName;
92028 const int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
92035 sqlite3CodeVerifySchema(pParse, iDb);
92036 sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
92060 sqlite3VdbeAddOp3(v, OP_OpenRead, iCsr, iRoot, iDb);
92562 int iDb; /* The database to store the trigger in */
92577 iDb = 1;
92581 iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);
92582 if( iDb<0 ){
92588 ** then set iDb to 1 to create the trigger in the temporary database.
92598 iDb = 1;
92604 if( sqlite3FixInit(&sFix, pParse, iDb, "trigger", pName) &&
92611 if( db->init.iDb==1 ){
92635 if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash),
92695 pTrigger->pSchema = db->aDb[iDb].pSchema;
92729 int iDb; /* Database containing the trigger */
92736 iDb = sqlite3SchemaToIndex(pParse->db, pTrig->pSchema);
92744 if( sqlite3FixInit(&sFix, pParse, iDb, "trigger", &nameToken)
92759 sqlite3BeginWriteOperation(pParse, 0, iDb);
92763 db->aDb[iDb].zName, SCHEMA_TABLE(iDb), zName,
92766 sqlite3ChangeCookie(pParse, iDb);
92767 sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 0, 0, sqlite3MPrintf(
92774 Hash *pHash = &db->aDb[iDb].pSchema->trigHash;
92992 int iDb;
92994 iDb = sqlite3SchemaToIndex(pParse->db, pTrigger->pSchema);
92995 assert( iDb>=0 && iDb<db->nDb );
92998 assert( pTable->pSchema==pTrigger->pSchema || iDb==1 );
93002 const char *zDb = db->aDb[iDb].zName;
93003 const char *zTab = SCHEMA_TABLE(iDb);
93004 if( iDb==1 ) code = SQLITE_DROP_TEMP_TRIGGER;
93029 sqlite3BeginWriteOperation(pParse, 0, iDb);
93030 sqlite3OpenMasterTable(pParse, iDb);
93034 sqlite3ChangeCookie(pParse, iDb);
93036 sqlite3VdbeAddOp4(v, OP_DropTrigger, iDb, 0, 0, pTrigger->zName, 0);
93046 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTrigger(sqlite3 *db, int iDb, const char *zName){
93047 Hash *pHash = &(db->aDb[iDb].pSchema->trigHash);
93122 int iDb; /* Index of the database to use */
93129 iDb = sqlite3SchemaToIndex(pParse->db, pStep->pTrig->pSchema);
93130 if( iDb==0 || iDb>=2 ){
93132 assert( iDb<pParse->db->nDb );
93133 pSrc->a[pSrc->nSrc-1].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zName);
93677 int iDb; /* Database containing the table being updated */
93708 iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
93787 pTab->aCol[j].zName, db->aDb[iDb].zName);
93829 sqlite3BeginWriteOperation(pParse, 1, iDb);
93909 if( !okOnePass ) sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenWrite);
93924 sqlite3VdbeAddOp4(v, OP_OpenWrite, iCur+i+1, pIdx->tnum, iDb,
94848 int iDb; /* The database the table is being created in */
94858 iDb = sqlite3SchemaToIndex(db, pTable->pSchema);
94859 assert( iDb>=0 );
94864 addModuleArgument(db, pTable, sqlite3DbStrDup(db, db->aDb[iDb].zName));
94876 pTable->azModuleArg[0], pParse->db->aDb[iDb].zName);
94917 int iDb;
94934 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
94939 db->aDb[iDb].zName, SCHEMA_TABLE(iDb),
94947 sqlite3ChangeCookie(pParse, iDb);
94951 sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 1, 0, zWhere, P4_DYNAMIC);
94952 sqlite3VdbeAddOp4(v, OP_VCreate, iDb, 0, 0,
95169 ** of the virtual table named zTab in database iDb.
95175 SQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){
95181 pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);
95272 ** of the virtual table named zTab in database iDb. This occurs
95277 SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){
95281 pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);
99946 int iDb; /* Index of database containing table/index */
99952 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
99966 sqlite3OpenTable(pParse, pTabItem->iCursor, iDb, pTab, op);
99978 sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
99991 sqlite3VdbeAddOp4(v, OP_OpenRead, iIdxCur, pIx->tnum, iDb,
99995 sqlite3CodeVerifySchema(pParse, iDb);
106161 int iDb = SQLITE_MAX_ATTACHED; /* sqlite3.aDb[] index of db to checkpoint */
106165 iDb = sqlite3FindDbName(db, zDb);
106167 if( iDb<0 ){
106171 rc = sqlite3Checkpoint(db, iDb);
106182 ** Run a checkpoint on database iDb. This is a no-op if database iDb is
106194 ** If iDb is passed SQLITE_MAX_ATTACHED, then all attached databases are
106198 SQLITE_PRIVATE int sqlite3Checkpoint(sqlite3 *db, int iDb){
106205 if( i==iDb || iDb==SQLITE_MAX_ATTACHED ){
107147 int iDb;
107150 iDb = 0;
107152 for(iDb=0; iDb<db->nDb; iDb++){
107153 if( strcmp(db->aDb[iDb].zName, zDbName)==0 ) break;
107156 if( iDb<db->nDb ){
107157 Btree *pBtree = db->aDb[iDb].pBt;