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

Add an sqlite3_db_config() option - SQLITE_DBCONFIG_STMT_SCANSTATS - for enabling and disabling the collection of sqlite3_stmt_scanstats() statistics in SQLITE_ENABLE_STMT_SCANSTATUS builds. Collection of statistics is disabled by default.

FossilOrigin-Name: 0f5579bef27b84ee855065cfe87703c51e1f9773906a9e0d4e4dafc90bd0e553
This commit is contained in:
dan
2023-02-28 19:39:59 +00:00
parent 4990fc84f1
commit 45163fc45e
14 changed files with 155 additions and 95 deletions

View File

@@ -736,6 +736,7 @@ int sqlite3VdbeExec(
Mem *pOut = 0; /* Output operand */
#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || defined(VDBE_PROFILE)
u64 *pnCycle = 0;
int bStmtScanStatus = IS_STMT_SCANSTATUS(db)!=0;
#endif
/*** INSERT STACK UNION HERE ***/
@@ -800,13 +801,17 @@ int sqlite3VdbeExec(
assert( pOp>=aOp && pOp<&aOp[p->nOp]);
nVmStep++;
#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || defined(VDBE_PROFILE)
#if defined(VDBE_PROFILE)
pOp->nExec++;
pnCycle = &pOp->nCycle;
# ifdef VDBE_PROFILE
if( sqlite3NProfileCnt==0 )
# endif
if( sqlite3NProfileCnt==0 ) *pnCycle -= sqlite3Hwtime();
#elif defined(SQLITE_ENABLE_STMT_SCANSTATUS)
if( bStmtScanStatus ){
pOp->nExec++;
pnCycle = &pOp->nCycle;
*pnCycle -= sqlite3Hwtime();
}
#endif
/* Only allow tracing if SQLITE_DEBUG is defined.
@@ -8758,8 +8763,10 @@ default: { /* This is really OP_Noop, OP_Explain */
*pnCycle += sqlite3NProfileCnt ? sqlite3NProfileCnt : sqlite3Hwtime();
pnCycle = 0;
#elif defined(SQLITE_ENABLE_STMT_SCANSTATUS)
*pnCycle += sqlite3Hwtime();
pnCycle = 0;
if( pnCycle ){
*pnCycle += sqlite3Hwtime();
pnCycle = 0;
}
#endif
/* The following code adds nothing to the actual functionality