diff options
author | dan <Dan Kennedy> | 2023-06-30 19:14:35 +0000 |
---|---|---|
committer | dan <Dan Kennedy> | 2023-06-30 19:14:35 +0000 |
commit | f8be243fefc5459355f4febd82f9b75004c4746f (patch) | |
tree | a9ba433066e541016f57217462be0d670e0e5e91 /src | |
parent | e6d7ae24e3682a8f98d1a34bdfdab3caf0f85371 (diff) | |
download | sqlite-f8be243fefc5459355f4febd82f9b75004c4746f.tar.gz sqlite-f8be243fefc5459355f4febd82f9b75004c4746f.zip |
Add experimental ".scanstats vm" command to the shell tool.
FossilOrigin-Name: e727640fb5c17d23b8e27972065b4acbf169c9240298d3ff7aed092b727d052d
Diffstat (limited to 'src')
-rw-r--r-- | src/shell.c.in | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/src/shell.c.in b/src/shell.c.in index 2b0884e1c..04407e54a 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -3332,17 +3332,11 @@ static int scanStatsHeight(sqlite3_stmt *p, int iEntry){ } #endif -/* -** Display scan stats. -*/ -static void display_scanstats( +#ifdef SQLITE_ENABLE_STMT_SCANSTATUS +static void display_explain_scanstats( sqlite3 *db, /* Database to query */ ShellState *pArg /* Pointer to ShellState */ ){ -#ifndef SQLITE_ENABLE_STMT_SCANSTATUS - UNUSED_PARAMETER(db); - UNUSED_PARAMETER(pArg); -#else static const int f = SQLITE_SCANSTAT_COMPLEX; sqlite3_stmt *p = pArg->pStmt; int ii = 0; @@ -3414,6 +3408,37 @@ static void display_scanstats( } eqp_render(pArg, nTotal); +} +#endif + +static void exec_prepared_stmt(ShellState*, sqlite3_stmt*); + +/* +** Display scan stats. +*/ +static void display_scanstats( + sqlite3 *db, /* Database to query */ + ShellState *pArg /* Pointer to ShellState */ +){ +#ifndef SQLITE_ENABLE_STMT_SCANSTATUS + UNUSED_PARAMETER(db); + UNUSED_PARAMETER(pArg); +#else + if( pArg->scanstatsOn==3 ){ + int rc = SQLITE_OK; + sqlite3_stmt *pStmt = 0; + rc = sqlite3_prepare_v2(db, "SELECT * FROM bytecode(?)", -1, &pStmt, 0); + if( rc==SQLITE_OK ){ + sqlite3_stmt *pSave = pArg->pStmt; + pArg->pStmt = pStmt; + sqlite3_bind_pointer(pStmt, 1, pSave, "stmt-pointer", 0); + exec_prepared_stmt(pArg, pStmt); + sqlite3_finalize(pStmt); + pArg->pStmt = pSave; + } + }else{ + display_explain_scanstats(db, pArg); + } #endif } @@ -9933,6 +9958,9 @@ static int do_meta_command(char *zLine, ShellState *p){ if( c=='s' && cli_strncmp(azArg[0], "scanstats", n)==0 ){ if( nArg==2 ){ + if( cli_strcmp(azArg[1], "vm")==0 ){ + p->scanstatsOn = 3; + }else if( cli_strcmp(azArg[1], "est")==0 ){ p->scanstatsOn = 2; }else{ |