Fossil SCM

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.

mistachkin 2017-01-09 23:37 trunk
Commit 02fa325a59dc50e78ed1c81f8a800734baa86fac
1 file changed +3 -1
+3 -1
--- src/db.c
+++ src/db.c
@@ -1136,13 +1136,15 @@
11361136
**
11371137
** Return -1 if zLabel does not match any open database.
11381138
*/
11391139
int db_database_slot(const char *zLabel){
11401140
int iSlot = -1;
1141
+ int rc;
11411142
Stmt q;
11421143
if( g.db==0 ) return iSlot;
1143
- db_prepare(&q, "PRAGMA database_list");
1144
+ rc = db_prepare_ignore_error(&q, "PRAGMA database_list");
1145
+ if( rc!=SQLITE_OK ) return iSlot;
11441146
while( db_step(&q)==SQLITE_ROW ){
11451147
if( fossil_strcmp(db_column_text(&q,1),zLabel)==0 ){
11461148
iSlot = db_column_int(&q, 0);
11471149
break;
11481150
}
11491151
--- src/db.c
+++ src/db.c
@@ -1136,13 +1136,15 @@
1136 **
1137 ** Return -1 if zLabel does not match any open database.
1138 */
1139 int db_database_slot(const char *zLabel){
1140 int iSlot = -1;
 
1141 Stmt q;
1142 if( g.db==0 ) return iSlot;
1143 db_prepare(&q, "PRAGMA database_list");
 
1144 while( db_step(&q)==SQLITE_ROW ){
1145 if( fossil_strcmp(db_column_text(&q,1),zLabel)==0 ){
1146 iSlot = db_column_int(&q, 0);
1147 break;
1148 }
1149
--- src/db.c
+++ src/db.c
@@ -1136,13 +1136,15 @@
1136 **
1137 ** Return -1 if zLabel does not match any open database.
1138 */
1139 int db_database_slot(const char *zLabel){
1140 int iSlot = -1;
1141 int rc;
1142 Stmt q;
1143 if( g.db==0 ) return iSlot;
1144 rc = db_prepare_ignore_error(&q, "PRAGMA database_list");
1145 if( rc!=SQLITE_OK ) return iSlot;
1146 while( db_step(&q)==SQLITE_ROW ){
1147 if( fossil_strcmp(db_column_text(&q,1),zLabel)==0 ){
1148 iSlot = db_column_int(&q, 0);
1149 break;
1150 }
1151

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button