diff options
author | drh <drh@noemail.net> | 2017-06-29 12:49:18 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2017-06-29 12:49:18 +0000 |
commit | 00d11d400b05e40fd9a2d52033bebc369f07ba04 (patch) | |
tree | 5c313165e38569725deaaba4d8a4947166b7e258 /src | |
parent | f00f530b7d4b87c894fd1968fc3334c50a160595 (diff) | |
download | sqlite-00d11d400b05e40fd9a2d52033bebc369f07ba04.tar.gz sqlite-00d11d400b05e40fd9a2d52033bebc369f07ba04.zip |
Add the SQLITE_STMTSTATUS_REPREPARE and SQLITE_STMTSTATUS_RUN options to
sqlite3_stmt_status(). Use this for two new columns in the stmts virtual
table.
FossilOrigin-Name: b0b0c8f8d548ef78584ab714ab120b01c1b83fc0d8ae2fd7626b970bab9fca58
Diffstat (limited to 'src')
-rw-r--r-- | src/sqlite.h.in | 16 | ||||
-rw-r--r-- | src/test1.c | 3 | ||||
-rw-r--r-- | src/vdbe.c | 1 | ||||
-rw-r--r-- | src/vdbeInt.h | 2 | ||||
-rw-r--r-- | src/vdbeaux.c | 3 |
5 files changed, 23 insertions, 2 deletions
diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 2f72f83f5..76d644c31 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -7148,6 +7148,18 @@ int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); ** If the number of virtual machine operations exceeds 2147483647 ** then the value returned by this statement status code is undefined. ** +** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt> +** <dd>^This is the number of times that the prepare statement has been +** automatically regenerated due to schema changes or change to +** [bound parameters] that might affect the query plan. +** +** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt> +** <dd>^This is the number of times that the prepared statement has +** been run. A single "run" for the purposes of this counter is one +** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()]. +** The counter is incremented on the first [sqlite3_step()] call of each +** cycle. +** ** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt> ** <dd>^This is the approximate number of bytes of heap memory ** used to store the prepared statement. ^This value is not actually @@ -7160,7 +7172,9 @@ int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); #define SQLITE_STMTSTATUS_SORT 2 #define SQLITE_STMTSTATUS_AUTOINDEX 3 #define SQLITE_STMTSTATUS_VM_STEP 4 -#define SQLITE_STMTSTATUS_MEMUSED 5 +#define SQLITE_STMTSTATUS_REPREPARE 5 +#define SQLITE_STMTSTATUS_RUN 6 +#define SQLITE_STMTSTATUS_MEMUSED 99 /* ** CAPI3REF: Custom Page Cache Object diff --git a/src/test1.c b/src/test1.c index eaafd8775..4b97f2c22 100644 --- a/src/test1.c +++ b/src/test1.c @@ -2139,6 +2139,9 @@ static int SQLITE_TCLAPI test_stmt_status( { "SQLITE_STMTSTATUS_SORT", SQLITE_STMTSTATUS_SORT }, { "SQLITE_STMTSTATUS_AUTOINDEX", SQLITE_STMTSTATUS_AUTOINDEX }, { "SQLITE_STMTSTATUS_VM_STEP", SQLITE_STMTSTATUS_VM_STEP }, + { "SQLITE_STMTSTATUS_REPREPARE", SQLITE_STMTSTATUS_REPREPARE }, + { "SQLITE_STMTSTATUS_RUN", SQLITE_STMTSTATUS_RUN }, + { "SQLITE_STMTSTATUS_MEMUSED", SQLITE_STMTSTATUS_MEMUSED }, }; if( objc!=4 ){ Tcl_WrongNumArgs(interp, 1, objv, "STMT PARAMETER RESETFLAG"); diff --git a/src/vdbe.c b/src/vdbe.c index ecdd92be9..e76b09f18 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -7079,6 +7079,7 @@ case OP_Init: { /* jump */ pOp->p1 = 0; } pOp->p1++; + p->aCounter[SQLITE_STMTSTATUS_RUN]++; goto jump_to_p2; } diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 93a6fcda5..0efacfbdd 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -393,7 +393,7 @@ struct Vdbe { bft isPrepareV2:1; /* True if prepared with prepare_v2() */ yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */ yDbMask lockMask; /* Subset of btreeMask that requires a lock */ - u32 aCounter[5]; /* Counters used by sqlite3_stmt_status() */ + u32 aCounter[7]; /* Counters used by sqlite3_stmt_status() */ char *zSql; /* Text of the SQL statement that generated this */ void *pFree; /* Free this when deleting the vdbe */ VdbeFrame *pFrame; /* Parent frame */ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index aabc13275..51622d8a2 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -87,6 +87,9 @@ void sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){ pB->zSql = zTmp; pB->isPrepareV2 = pA->isPrepareV2; pB->expmask = pA->expmask; + memcpy(pB->aCounter, pA->aCounter, sizeof(pB->aCounter)); + pB->aCounter[SQLITE_STMTSTATUS_REPREPARE]++; + } /* |