From e48d8ab3faac733d51a3e6613da62f2f9c0814e8 Mon Sep 17 00:00:00 2001 From: "D. Richard Hipp" Date: Wed, 18 Apr 2018 10:44:58 +0000 Subject: [PATCH] Add checks to the CLI that issue a warning if SQLite gets initialized prior to the last sqlite3_config() call. --- src/shell.c.in | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/shell.c.in b/src/shell.c.in index db21340c0a..87087ed45f 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -8098,6 +8098,17 @@ static void usage(int showDetail){ } /* +** Internal check: Verify that the SQLite is uninitialized. Print a +** error message if it is initialized. +*/ +static void verify_uninitialized(void){ + if( sqlite3_config(-1)==SQLITE_MISUSE ){ + utf8_printf(stdout, "WARNING: attempt to configuration SQLite after" + " initialization.\n"); + } +} + +/* ** Initialize the state information in data */ static void main_init(ShellState *data) { @@ -8108,6 +8119,7 @@ static void main_init(ShellState *data) { memcpy(data->rowSeparator,SEP_Row, 2); data->showHeader = 0; data->shellFlgs = SHFLG_Lookaside; + verify_uninitialized(); sqlite3_config(SQLITE_CONFIG_URI, 1); sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data); sqlite3_config(SQLITE_CONFIG_MULTITHREAD); @@ -8248,6 +8260,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ ** the size of the alternative malloc heap, ** and the first command to execute. */ + verify_uninitialized(); for(i=1; i