Fossil SCM
Further enhance the 'sqlite3' command and make use of it in the json test.
Commit
f9c14d7d6d9d3f19db5802a36adb498570bb435a
Parent
938122da85336d1…
2 files changed
+18
-6
+1
-2
+18
-6
| --- src/sqlcmd.c | ||
| +++ src/sqlcmd.c | ||
| @@ -197,22 +197,21 @@ | ||
| 197 | 197 | ** |
| 198 | 198 | ** CREATE VIRTUAL TABLE temp.foci USING files_of_checkin; |
| 199 | 199 | ** SELECT * FROM foci WHERE checkinID=symbolic_name_to_rid('trunk'); |
| 200 | 200 | */ |
| 201 | 201 | void cmd_sqlite3(void){ |
| 202 | + int noRepository; | |
| 202 | 203 | extern int sqlite3_shell(int, char**); |
| 203 | - if( find_option("no-repository", 0, 0)==0 ){ | |
| 204 | + noRepository = find_option("no-repository", 0, 0)!=0; | |
| 205 | + if( !noRepository ){ | |
| 204 | 206 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); |
| 205 | - db_close(1); | |
| 206 | 207 | } |
| 208 | + fossil_close(1, noRepository); | |
| 207 | 209 | sqlite3_shutdown(); |
| 208 | 210 | sqlite3_shell(g.argc-1, g.argv+1); |
| 209 | 211 | sqlite3_cancel_auto_extension((void(*)(void))sqlcmd_autoinit); |
| 210 | - g.db = 0; | |
| 211 | - g.zMainDbType = 0; | |
| 212 | - g.repositoryOpen = 0; | |
| 213 | - g.localOpen = 0; | |
| 212 | + fossil_close(0, noRepository); | |
| 214 | 213 | } |
| 215 | 214 | |
| 216 | 215 | /* |
| 217 | 216 | ** This routine is called by the patched sqlite3 command-line shell in order |
| 218 | 217 | ** to load the name and database connection for the open Fossil database. |
| @@ -219,5 +218,18 @@ | ||
| 219 | 218 | */ |
| 220 | 219 | void fossil_open(const char **pzRepoName){ |
| 221 | 220 | sqlite3_auto_extension((void(*)(void))sqlcmd_autoinit); |
| 222 | 221 | *pzRepoName = g.zRepositoryName; |
| 223 | 222 | } |
| 223 | + | |
| 224 | +/* | |
| 225 | +** This routine closes the Fossil databases and/or invalidates the global | |
| 226 | +** state variables that keep track of them. | |
| 227 | +*/ | |
| 228 | +void fossil_close(int bDb, int noRepository){ | |
| 229 | + if( bDb ) db_close(1); | |
| 230 | + if( noRepository ) g.zRepositoryName = 0; | |
| 231 | + g.db = 0; | |
| 232 | + g.zMainDbType = 0; | |
| 233 | + g.repositoryOpen = 0; | |
| 234 | + g.localOpen = 0; | |
| 235 | +} | |
| 224 | 236 |
| --- src/sqlcmd.c | |
| +++ src/sqlcmd.c | |
| @@ -197,22 +197,21 @@ | |
| 197 | ** |
| 198 | ** CREATE VIRTUAL TABLE temp.foci USING files_of_checkin; |
| 199 | ** SELECT * FROM foci WHERE checkinID=symbolic_name_to_rid('trunk'); |
| 200 | */ |
| 201 | void cmd_sqlite3(void){ |
| 202 | extern int sqlite3_shell(int, char**); |
| 203 | if( find_option("no-repository", 0, 0)==0 ){ |
| 204 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); |
| 205 | db_close(1); |
| 206 | } |
| 207 | sqlite3_shutdown(); |
| 208 | sqlite3_shell(g.argc-1, g.argv+1); |
| 209 | sqlite3_cancel_auto_extension((void(*)(void))sqlcmd_autoinit); |
| 210 | g.db = 0; |
| 211 | g.zMainDbType = 0; |
| 212 | g.repositoryOpen = 0; |
| 213 | g.localOpen = 0; |
| 214 | } |
| 215 | |
| 216 | /* |
| 217 | ** This routine is called by the patched sqlite3 command-line shell in order |
| 218 | ** to load the name and database connection for the open Fossil database. |
| @@ -219,5 +218,18 @@ | |
| 219 | */ |
| 220 | void fossil_open(const char **pzRepoName){ |
| 221 | sqlite3_auto_extension((void(*)(void))sqlcmd_autoinit); |
| 222 | *pzRepoName = g.zRepositoryName; |
| 223 | } |
| 224 |
| --- src/sqlcmd.c | |
| +++ src/sqlcmd.c | |
| @@ -197,22 +197,21 @@ | |
| 197 | ** |
| 198 | ** CREATE VIRTUAL TABLE temp.foci USING files_of_checkin; |
| 199 | ** SELECT * FROM foci WHERE checkinID=symbolic_name_to_rid('trunk'); |
| 200 | */ |
| 201 | void cmd_sqlite3(void){ |
| 202 | int noRepository; |
| 203 | extern int sqlite3_shell(int, char**); |
| 204 | noRepository = find_option("no-repository", 0, 0)!=0; |
| 205 | if( !noRepository ){ |
| 206 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); |
| 207 | } |
| 208 | fossil_close(1, noRepository); |
| 209 | sqlite3_shutdown(); |
| 210 | sqlite3_shell(g.argc-1, g.argv+1); |
| 211 | sqlite3_cancel_auto_extension((void(*)(void))sqlcmd_autoinit); |
| 212 | fossil_close(0, noRepository); |
| 213 | } |
| 214 | |
| 215 | /* |
| 216 | ** This routine is called by the patched sqlite3 command-line shell in order |
| 217 | ** to load the name and database connection for the open Fossil database. |
| @@ -219,5 +218,18 @@ | |
| 218 | */ |
| 219 | void fossil_open(const char **pzRepoName){ |
| 220 | sqlite3_auto_extension((void(*)(void))sqlcmd_autoinit); |
| 221 | *pzRepoName = g.zRepositoryName; |
| 222 | } |
| 223 | |
| 224 | /* |
| 225 | ** This routine closes the Fossil databases and/or invalidates the global |
| 226 | ** state variables that keep track of them. |
| 227 | */ |
| 228 | void fossil_close(int bDb, int noRepository){ |
| 229 | if( bDb ) db_close(1); |
| 230 | if( noRepository ) g.zRepositoryName = 0; |
| 231 | g.db = 0; |
| 232 | g.zMainDbType = 0; |
| 233 | g.repositoryOpen = 0; |
| 234 | g.localOpen = 0; |
| 235 | } |
| 236 |
+1
-2
| --- test/json.test | ||
| +++ test/json.test | ||
| @@ -750,12 +750,11 @@ | ||
| 750 | 750 | # Unknown error |
| 751 | 751 | |
| 752 | 752 | write_file bad.sql { |
| 753 | 753 | CREATE TABLE spam(a integer, b text); |
| 754 | 754 | } |
| 755 | -exec sqlite3 bad.fossil <bad.sql | |
| 756 | -#exec $::fossilexe sqlite3 --no-repository bad.fossil <bad.sql | |
| 755 | +exec $::fossilexe sqlite3 --no-repository bad.fossil <bad.sql | |
| 757 | 756 | #fossil_json HAI -R bad.fossil -expectError |
| 758 | 757 | |
| 759 | 758 | # FOSSIL-1104 FSL_JSON_E_TIMEOUT |
| 760 | 759 | # Timeout reached |
| 761 | 760 | # FOSSIL-1105 FSL_JSON_E_ASSERT |
| 762 | 761 |
| --- test/json.test | |
| +++ test/json.test | |
| @@ -750,12 +750,11 @@ | |
| 750 | # Unknown error |
| 751 | |
| 752 | write_file bad.sql { |
| 753 | CREATE TABLE spam(a integer, b text); |
| 754 | } |
| 755 | exec sqlite3 bad.fossil <bad.sql |
| 756 | #exec $::fossilexe sqlite3 --no-repository bad.fossil <bad.sql |
| 757 | #fossil_json HAI -R bad.fossil -expectError |
| 758 | |
| 759 | # FOSSIL-1104 FSL_JSON_E_TIMEOUT |
| 760 | # Timeout reached |
| 761 | # FOSSIL-1105 FSL_JSON_E_ASSERT |
| 762 |
| --- test/json.test | |
| +++ test/json.test | |
| @@ -750,12 +750,11 @@ | |
| 750 | # Unknown error |
| 751 | |
| 752 | write_file bad.sql { |
| 753 | CREATE TABLE spam(a integer, b text); |
| 754 | } |
| 755 | exec $::fossilexe sqlite3 --no-repository bad.fossil <bad.sql |
| 756 | #fossil_json HAI -R bad.fossil -expectError |
| 757 | |
| 758 | # FOSSIL-1104 FSL_JSON_E_TIMEOUT |
| 759 | # Timeout reached |
| 760 | # FOSSIL-1105 FSL_JSON_E_ASSERT |
| 761 |