1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

/fiddle: before resetting a db, roll back any transactions (resolves problem reported in [forum:0b41a25d65|forum post 0b41a25d65]) and remove an obsolete/broken reference to a long-gone API which could cause initialization to fail prematurely.

FossilOrigin-Name: ee164ca73cf4151b1a1bf351729afa9b0ec95bd5004a5d5bfce3ed46268bfbf3
This commit is contained in:
stephan
2024-03-05 06:31:37 +00:00
parent 18281494a2
commit 2c3973fdff
4 changed files with 25 additions and 16 deletions

View File

@@ -12838,7 +12838,7 @@ sqlite3_vfs * fiddle_db_vfs(const char *zDbName){
/* Only for emcc experimentation purposes. */
sqlite3 * fiddle_db_arg(sqlite3 *arg){
printf("fiddle_db_arg(%p)\n", (const void*)arg);
oputf("fiddle_db_arg(%p)\n", (const void*)arg);
return arg;
}
@@ -12864,12 +12864,22 @@ const char * fiddle_db_filename(const char * zDbName){
/*
** Completely wipes out the contents of the currently-opened database
** but leaves its storage intact for reuse.
** but leaves its storage intact for reuse. If any transactions are
** active, they are forcibly rolled back.
*/
void fiddle_reset_db(void){
if( globalDb ){
int rc = sqlite3_db_config(globalDb, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
if( 0==rc ) rc = sqlite3_exec(globalDb, "VACUUM", 0, 0, 0);
int rc;
while( sqlite3_txn_state(globalDb,0)>0 ){
/*
** Resolve problem reported in
** https://sqlite.org/forum/forumpost/0b41a25d65
*/
oputz("Rolling back in-progress transaction.\n");
sqlite3_exec(globalDb,"ROLLBACK", 0, 0, 0);
}
rc = sqlite3_db_config(globalDb, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
if( 0==rc ) sqlite3_exec(globalDb, "VACUUM", 0, 0, 0);
sqlite3_db_config(globalDb, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
}
}