/ Check-in [2f481b85]
Login

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

Overview
Comment:The schema name "main" is always an acceptable alias for the primary database even if the primary database is renamed using SQLITE_DBCONFIG_MAINDBNAME.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2f481b854f04bec546eb172d1b6dbc88067d3fda
User & Date: drh 2016-12-24 19:37:16
Context
2016-12-24
21:32
Combine the implementations of the ".tables" and ".indexes" commands in the command-line shell. The ".indexes" command now puts the indexes in multiple columns, just like ".tables" and shows all indexes in all attached databases. check-in: def29333 user: drh tags: trunk
19:37
The schema name "main" is always an acceptable alias for the primary database even if the primary database is renamed using SQLITE_DBCONFIG_MAINDBNAME. check-in: 2f481b85 user: drh tags: trunk
18:18
Change the output format of the ".databases" command in the command-line shell so that it shows the schema name, a colon, and the corresponding filename. check-in: 8558512e user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

   712    712   ** -1 if the named db cannot be found.
   713    713   */
   714    714   int sqlite3FindDbName(sqlite3 *db, const char *zName){
   715    715     int i = -1;         /* Database number */
   716    716     if( zName ){
   717    717       Db *pDb;
   718    718       for(i=(db->nDb-1), pDb=&db->aDb[i]; i>=0; i--, pDb--){
   719         -      if( 0==sqlite3StrICmp(pDb->zDbSName, zName) ) break;
          719  +      if( 0==sqlite3_stricmp(pDb->zDbSName, zName) ) break;
          720  +      /* "main" is always an acceptable alias for the primary database
          721  +      ** even if it has been renamed using SQLITE_DBCONFIG_MAINDBNAME. */
          722  +      if( i==0 && 0==sqlite3_stricmp("main", zName) ) break;
   720    723       }
   721    724     }
   722    725     return i;
   723    726   }
   724    727   
   725    728   /*
   726    729   ** The token *pName contains the name of a database (either "main" or

Changes to src/main.c.

  3922   3922     return bDflt;
  3923   3923   }
  3924   3924   
  3925   3925   /*
  3926   3926   ** Return the Btree pointer identified by zDbName.  Return NULL if not found.
  3927   3927   */
  3928   3928   Btree *sqlite3DbNameToBtree(sqlite3 *db, const char *zDbName){
  3929         -  int i;
  3930         -  for(i=0; i<db->nDb; i++){
  3931         -    if( db->aDb[i].pBt
  3932         -     && (zDbName==0 || sqlite3StrICmp(zDbName, db->aDb[i].zDbSName)==0)
  3933         -    ){
  3934         -      return db->aDb[i].pBt;
  3935         -    }
  3936         -  }
  3937         -  return 0;
         3929  +  int iDb = zDbName ? sqlite3FindDbName(db, zDbName) : 0;
         3930  +  return iDb<0 ? 0 : db->aDb[iDb].pBt;
  3938   3931   }
  3939   3932   
  3940   3933   /*
  3941   3934   ** Return the filename of the database associated with a database
  3942   3935   ** connection.
  3943   3936   */
  3944   3937   const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName){