Fossil SCM

Make the default vfs survive after a sqlite3_shutdown (for "fossil sqlite" command).

jan.nijtmans 2013-12-10 14:22 trunk
Commit aa22b1b46285a9fe0bd5fc2e4036e60060818752
1 file changed +4
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -124,10 +124,11 @@
124124
g.repositoryOpen = 1;
125125
g.db = db;
126126
return SQLITE_OK;
127127
}
128128
129
+static sqlite3_vfs *pDefaultVfs = 0;
129130
130131
/*
131132
** COMMAND: sqlite3
132133
**
133134
** Usage: %fossil sqlite3 ?DATABASE? ?OPTIONS?
@@ -142,10 +143,12 @@
142143
*/
143144
void sqlite3_cmd(void){
144145
extern int sqlite3_shell(int, char**);
145146
db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
146147
db_close(1);
148
+ /* Determine default VFS and keep it after shutdown */
149
+ pDefaultVfs = sqlite3_vfs_find(0);
147150
sqlite3_shutdown();
148151
sqlite3_shell(g.argc-1, g.argv+1);
149152
g.db = 0;
150153
}
151154
@@ -152,8 +155,9 @@
152155
/*
153156
** This routine is called by the patched sqlite3 command-line shell in order
154157
** to load the name and database connection for the open Fossil database.
155158
*/
156159
void fossil_open(const char **pzRepoName){
160
+ sqlite3_vfs_register(pDefaultVfs, 1);
157161
sqlite3_auto_extension((void(*)(void))sqlcmd_autoinit);
158162
*pzRepoName = g.zRepositoryName;
159163
}
160164
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -124,10 +124,11 @@
124 g.repositoryOpen = 1;
125 g.db = db;
126 return SQLITE_OK;
127 }
128
 
129
130 /*
131 ** COMMAND: sqlite3
132 **
133 ** Usage: %fossil sqlite3 ?DATABASE? ?OPTIONS?
@@ -142,10 +143,12 @@
142 */
143 void sqlite3_cmd(void){
144 extern int sqlite3_shell(int, char**);
145 db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
146 db_close(1);
 
 
147 sqlite3_shutdown();
148 sqlite3_shell(g.argc-1, g.argv+1);
149 g.db = 0;
150 }
151
@@ -152,8 +155,9 @@
152 /*
153 ** This routine is called by the patched sqlite3 command-line shell in order
154 ** to load the name and database connection for the open Fossil database.
155 */
156 void fossil_open(const char **pzRepoName){
 
157 sqlite3_auto_extension((void(*)(void))sqlcmd_autoinit);
158 *pzRepoName = g.zRepositoryName;
159 }
160
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -124,10 +124,11 @@
124 g.repositoryOpen = 1;
125 g.db = db;
126 return SQLITE_OK;
127 }
128
129 static sqlite3_vfs *pDefaultVfs = 0;
130
131 /*
132 ** COMMAND: sqlite3
133 **
134 ** Usage: %fossil sqlite3 ?DATABASE? ?OPTIONS?
@@ -142,10 +143,12 @@
143 */
144 void sqlite3_cmd(void){
145 extern int sqlite3_shell(int, char**);
146 db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
147 db_close(1);
148 /* Determine default VFS and keep it after shutdown */
149 pDefaultVfs = sqlite3_vfs_find(0);
150 sqlite3_shutdown();
151 sqlite3_shell(g.argc-1, g.argv+1);
152 g.db = 0;
153 }
154
@@ -152,8 +155,9 @@
155 /*
156 ** This routine is called by the patched sqlite3 command-line shell in order
157 ** to load the name and database connection for the open Fossil database.
158 */
159 void fossil_open(const char **pzRepoName){
160 sqlite3_vfs_register(pDefaultVfs, 1);
161 sqlite3_auto_extension((void(*)(void))sqlcmd_autoinit);
162 *pzRepoName = g.zRepositoryName;
163 }
164

Keyboard Shortcuts

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