Fossil SCM
Fix the db_database_slot() routine so that it works ever if the g.db database has been closed.
Commit
0c1f876e78e8f86b3beb803d434d920c3e0af3a2
Parent
5031cb08964f479…
1 file changed
+1
M
src/db.c
+1
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -987,10 +987,11 @@ | ||
| 987 | 987 | ** Return -1 if zLabel does not match any open database. |
| 988 | 988 | */ |
| 989 | 989 | int db_database_slot(const char *zLabel){ |
| 990 | 990 | int iSlot = -1; |
| 991 | 991 | Stmt q; |
| 992 | + if( g.db==0 ) return -1; | |
| 992 | 993 | db_prepare(&q, "PRAGMA database_list"); |
| 993 | 994 | while( db_step(&q)==SQLITE_ROW ){ |
| 994 | 995 | if( fossil_strcmp(db_column_text(&q,1),zLabel)==0 ){ |
| 995 | 996 | iSlot = db_column_int(&q, 0); |
| 996 | 997 | break; |
| 997 | 998 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -987,10 +987,11 @@ | |
| 987 | ** Return -1 if zLabel does not match any open database. |
| 988 | */ |
| 989 | int db_database_slot(const char *zLabel){ |
| 990 | int iSlot = -1; |
| 991 | Stmt q; |
| 992 | db_prepare(&q, "PRAGMA database_list"); |
| 993 | while( db_step(&q)==SQLITE_ROW ){ |
| 994 | if( fossil_strcmp(db_column_text(&q,1),zLabel)==0 ){ |
| 995 | iSlot = db_column_int(&q, 0); |
| 996 | break; |
| 997 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -987,10 +987,11 @@ | |
| 987 | ** Return -1 if zLabel does not match any open database. |
| 988 | */ |
| 989 | int db_database_slot(const char *zLabel){ |
| 990 | int iSlot = -1; |
| 991 | Stmt q; |
| 992 | if( g.db==0 ) return -1; |
| 993 | db_prepare(&q, "PRAGMA database_list"); |
| 994 | while( db_step(&q)==SQLITE_ROW ){ |
| 995 | if( fossil_strcmp(db_column_text(&q,1),zLabel)==0 ){ |
| 996 | iSlot = db_column_int(&q, 0); |
| 997 | break; |
| 998 |