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.
Commit
02fa325a59dc50e78ed1c81f8a800734baa86fac
Parent
5e9e76733a68c15…
1 file changed
+3
-1
M
src/db.c
+3
-1
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1136,13 +1136,15 @@ | ||
| 1136 | 1136 | ** |
| 1137 | 1137 | ** Return -1 if zLabel does not match any open database. |
| 1138 | 1138 | */ |
| 1139 | 1139 | int db_database_slot(const char *zLabel){ |
| 1140 | 1140 | int iSlot = -1; |
| 1141 | + int rc; | |
| 1141 | 1142 | Stmt q; |
| 1142 | 1143 | 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; | |
| 1144 | 1146 | while( db_step(&q)==SQLITE_ROW ){ |
| 1145 | 1147 | if( fossil_strcmp(db_column_text(&q,1),zLabel)==0 ){ |
| 1146 | 1148 | iSlot = db_column_int(&q, 0); |
| 1147 | 1149 | break; |
| 1148 | 1150 | } |
| 1149 | 1151 |
| --- 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 |