diff options
author | stephan <stephan@noemail.net> | 2024-03-05 06:31:37 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2024-03-05 06:31:37 +0000 |
commit | 2c3973fdff6f3ffa6f8aac63a2c5d3fa02b66a24 (patch) | |
tree | 8573e90b2c893df078e243608219739cd39a2129 /src | |
parent | 18281494a27095687cb136783878fbbde8286f51 (diff) | |
download | sqlite-2c3973fdff6f3ffa6f8aac63a2c5d3fa02b66a24.tar.gz sqlite-2c3973fdff6f3ffa6f8aac63a2c5d3fa02b66a24.zip |
/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
Diffstat (limited to 'src')
-rw-r--r-- | src/shell.c.in | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/shell.c.in b/src/shell.c.in index 05583b2f3..36bbb93ec 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -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); } } |