diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/shell.c | 2 | ||||
-rw-r--r-- | src/sqlite.h.in | 10 | ||||
-rw-r--r-- | src/test1.c | 1 | ||||
-rw-r--r-- | src/vdbe.c | 5 | ||||
-rw-r--r-- | src/vdbeInt.h | 2 |
5 files changed, 18 insertions, 2 deletions
diff --git a/src/shell.c b/src/shell.c index 9f2f46bd1..9a8a90694 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1109,6 +1109,8 @@ static int display_stats( fprintf(pArg->out, "Sort Operations: %d\n", iCur); iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX, bReset); fprintf(pArg->out, "Autoindex Inserts: %d\n", iCur); + iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset); + fprintf(pArg->out, "Virtual Machine Steps: %d\n", iCur); } return 0; diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 0d23f3894..0921d23a0 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -6303,11 +6303,21 @@ int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); ** A non-zero value in this counter may indicate an opportunity to ** improvement performance by adding permanent indices that do not ** need to be reinitialized each time the statement is run.</dd> +** +** [[SQLITE_STMTSTATUS_VM_STEP]] <dt>SQLITE_STMTSTATUS_VM_STEP</dt> +** <dd>^This is the number of virtual machine operations executed +** by the prepared statement if that number is less than or equal +** to 2147483647. The number of virtual machine operations can be +** used as a proxy for the total work done by the prepared statement. +** If the number of virtual machine operations exceeds 2147483647 +** then the value returned by this statement status code is undefined. +** </dd> ** </dl> */ #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 #define SQLITE_STMTSTATUS_SORT 2 #define SQLITE_STMTSTATUS_AUTOINDEX 3 +#define SQLITE_STMTSTATUS_VM_STEP 4 /* ** CAPI3REF: Custom Page Cache Object diff --git a/src/test1.c b/src/test1.c index bd6d4a4cf..a4df0e764 100644 --- a/src/test1.c +++ b/src/test1.c @@ -2218,6 +2218,7 @@ static int test_stmt_status( { "SQLITE_STMTSTATUS_FULLSCAN_STEP", SQLITE_STMTSTATUS_FULLSCAN_STEP }, { "SQLITE_STMTSTATUS_SORT", SQLITE_STMTSTATUS_SORT }, { "SQLITE_STMTSTATUS_AUTOINDEX", SQLITE_STMTSTATUS_AUTOINDEX }, + { "SQLITE_STMTSTATUS_VM_STEP", SQLITE_STMTSTATUS_VM_STEP }, }; if( objc!=4 ){ Tcl_WrongNumArgs(interp, 1, objv, "STMT PARAMETER RESETFLAG"); diff --git a/src/vdbe.c b/src/vdbe.c index 7abc2889d..81b40628e 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -556,12 +556,13 @@ int sqlite3VdbeExec( int checkProgress; /* True if progress callbacks are enabled */ int nProgressOps = 0; /* Opcodes executed since progress callback. */ #endif + int iCompare = 0; /* Result of last OP_Compare operation */ + unsigned nVmStep = 0; /* Number of virtual machine steps */ Mem *aMem = p->aMem; /* Copy of p->aMem */ Mem *pIn1 = 0; /* 1st input operand */ Mem *pIn2 = 0; /* 2nd input operand */ Mem *pIn3 = 0; /* 3rd input operand */ Mem *pOut = 0; /* Output operand */ - int iCompare = 0; /* Result of last OP_Compare operation */ int *aPermute = 0; /* Permutation of columns for OP_Compare */ i64 lastRowid = db->lastRowid; /* Saved value of the last insert ROWID */ #ifdef VDBE_PROFILE @@ -606,6 +607,7 @@ int sqlite3VdbeExec( origPc = pc; start = sqlite3Hwtime(); #endif + nVmStep++; pOp = &aOp[pc]; /* Only allow tracing if SQLITE_DEBUG is defined. @@ -6200,6 +6202,7 @@ vdbe_error_halt: ** top. */ vdbe_return: db->lastRowid = lastRowid; + p->aCounter[SQLITE_STMTSTATUS_VM_STEP-1] += (int)nVmStep; sqlite3VdbeLeave(p); return rc; diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 3a5b4028b..dc42187f0 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -344,7 +344,7 @@ struct Vdbe { yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */ yDbMask lockMask; /* Subset of btreeMask that requires a lock */ int iStatement; /* Statement number (or 0 if has not opened stmt) */ - int aCounter[3]; /* Counters used by sqlite3_stmt_status() */ + int aCounter[4]; /* Counters used by sqlite3_stmt_status() */ #ifndef SQLITE_OMIT_TRACE i64 startTime; /* Time when query started - used for profiling */ #endif |