sqliteBtreeClose(db->aDb[i].pBt); db->aDb[i].pBt = 0; sqliteFree(db->aDb[i].zName);
sqliteBtreeClose(pDb->pBt); pDb->pBt = 0; sqliteFree(pDb->zName);
void sqliteDetach(Parse *pParse, Token *pDbname){  int i;  sqlite *db;  Vdbe *v;  v = sqliteGetVdbe(pParse);  sqliteVdbeAddOp(v, OP_Halt, 0, 0);  if( pParse->explain ) return;  db = pParse->db;  for(i=0; i<db->nDb; i++){    if( db->aDb[i].pBt==0 || db->aDb[i].zName==0 ) continue;    if( strlen(db->aDb[i].zName)!=pDbname->n ) continue;    if( sqliteStrNICmp(db->aDb[i].zName, pDbname->z, pDbname->n)==0 ) break;  }  if( i>=db->nDb ){    sqliteErrorMsg(pParse, "no such database: %T", pDbname);    return;  }  if( i<2 ){    sqliteErrorMsg(pParse, "cannot detach database %T", pDbname);    return;  }#ifndef SQLITE_OMIT_AUTHORIZATION  if( sqliteAuthCheck(pParse,SQLITE_DETACH,db->aDb[i].zName,0,0)!=SQLITE_OK ){    return;  }#endif /* SQLITE_OMIT_AUTHORIZATION */  sqliteBtreeClose(db->aDb[i].pBt);  db->aDb[i].pBt = 0;  sqliteFree(db->aDb[i].zName);  sqliteResetInternalSchema(db, i);  db->nDb--;  if( i<db->nDb ){    db->aDb[i] = db->aDb[db->nDb];    memset(&db->aDb[db->nDb], 0, sizeof(db->aDb[0]));    sqliteResetInternalSchema(db, i);  }}