Fossil SCM

Further enhance the 'sqlite3' command and make use of it in the json test.

mistachkin 2016-02-07 23:22 trunk
Commit f9c14d7d6d9d3f19db5802a36adb498570bb435a
2 files changed +18 -6 +1 -2
+18 -6
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -197,22 +197,21 @@
197197
**
198198
** CREATE VIRTUAL TABLE temp.foci USING files_of_checkin;
199199
** SELECT * FROM foci WHERE checkinID=symbolic_name_to_rid('trunk');
200200
*/
201201
void cmd_sqlite3(void){
202
+ int noRepository;
202203
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 ){
204206
db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
205
- db_close(1);
206207
}
208
+ fossil_close(1, noRepository);
207209
sqlite3_shutdown();
208210
sqlite3_shell(g.argc-1, g.argv+1);
209211
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);
214213
}
215214
216215
/*
217216
** This routine is called by the patched sqlite3 command-line shell in order
218217
** to load the name and database connection for the open Fossil database.
@@ -219,5 +218,18 @@
219218
*/
220219
void fossil_open(const char **pzRepoName){
221220
sqlite3_auto_extension((void(*)(void))sqlcmd_autoinit);
222221
*pzRepoName = g.zRepositoryName;
223222
}
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
+}
224236
--- 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 @@
750750
# Unknown error
751751
752752
write_file bad.sql {
753753
CREATE TABLE spam(a integer, b text);
754754
}
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
757756
#fossil_json HAI -R bad.fossil -expectError
758757
759758
# FOSSIL-1104 FSL_JSON_E_TIMEOUT
760759
# Timeout reached
761760
# FOSSIL-1105 FSL_JSON_E_ASSERT
762761
--- 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

Keyboard Shortcuts

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