Fossil

Check-in [02fa325a]
Login

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

Overview
Comment:Since the db_database_slot() function is called during database error processing, it must use db_prepare_ignore_error() and then check the return code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 02fa325a59dc50e78ed1c81f8a800734baa86fac
User & Date: mistachkin 2017-01-09 23:37:49
Context
2017-01-10
04:49
Fix dirent.h related compile errors when building for WINXP platform. check-in: 3dddf767 user: ashepilko tags: trunk
2017-01-09
23:37
Since the db_database_slot() function is called during database error processing, it must use db_prepare_ignore_error() and then check the return code. check-in: 02fa325a user: mistachkin tags: trunk
2017-01-07
18:54
Clarification of the W card in the file-format document. check-in: 5e9e7673 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/db.c.

1134
1135
1136
1137
1138
1139
1140

1141
1142
1143

1144
1145
1146
1147
1148
1149
1150
** opened is slot 0.  The "temp" database is slot 1.  Attached databases
** are slots 2 and higher.
**
** Return -1 if zLabel does not match any open database.
*/
int db_database_slot(const char *zLabel){
  int iSlot = -1;

  Stmt q;
  if( g.db==0 ) return iSlot;
  db_prepare(&q, "PRAGMA database_list");

  while( db_step(&q)==SQLITE_ROW ){
    if( fossil_strcmp(db_column_text(&q,1),zLabel)==0 ){
      iSlot = db_column_int(&q, 0);
      break;
    }
  }
  db_finalize(&q);







>


|
>







1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
** opened is slot 0.  The "temp" database is slot 1.  Attached databases
** are slots 2 and higher.
**
** Return -1 if zLabel does not match any open database.
*/
int db_database_slot(const char *zLabel){
  int iSlot = -1;
  int rc;
  Stmt q;
  if( g.db==0 ) return iSlot;
  rc = db_prepare_ignore_error(&q, "PRAGMA database_list");
  if( rc!=SQLITE_OK ) return iSlot;
  while( db_step(&q)==SQLITE_ROW ){
    if( fossil_strcmp(db_column_text(&q,1),zLabel)==0 ){
      iSlot = db_column_int(&q, 0);
      break;
    }
  }
  db_finalize(&q);