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
This commit is contained in:
parent
f00f530b7d
commit
00d11d400b
@ -101,11 +101,14 @@ static int stmtsConnect(
|
||||
#define STMTS_COLUMN_NSORT 6 /* SQLITE_STMTSTATUS_SORT */
|
||||
#define STMTS_COLUMN_NAIDX 7 /* SQLITE_STMTSTATUS_AUTOINDEX */
|
||||
#define STMTS_COLUMN_NSTEP 8 /* SQLITE_STMTSTATUS_VM_STEP */
|
||||
#define STMTS_COLUMN_MEM 9 /* SQLITE_STMTSTATUS_MEMUSED */
|
||||
#define STMTS_COLUMN_REPREP 9 /* SQLITE_STMTSTATUS_REPREPARE */
|
||||
#define STMTS_COLUMN_RUN 10 /* SQLITE_STMTSTATUS_RUN */
|
||||
#define STMTS_COLUMN_MEM 11 /* SQLITE_STMTSTATUS_MEMUSED */
|
||||
|
||||
|
||||
rc = sqlite3_declare_vtab(db,
|
||||
"CREATE TABLE x(ptr,sql,ncol,ro,busy,nscan,nsort,naidx,nstep,mem)");
|
||||
"CREATE TABLE x(ptr,sql,ncol,ro,busy,nscan,nsort,naidx,nstep,"
|
||||
"reprep,run,mem)");
|
||||
if( rc==SQLITE_OK ){
|
||||
pNew = sqlite3_malloc( sizeof(*pNew) );
|
||||
*ppVtab = (sqlite3_vtab*)pNew;
|
||||
@ -187,11 +190,17 @@ static int stmtsColumn(
|
||||
sqlite3_result_int(ctx, sqlite3_stmt_busy(pCur->pStmt));
|
||||
break;
|
||||
}
|
||||
case STMTS_COLUMN_MEM: {
|
||||
i = SQLITE_STMTSTATUS_MEMUSED +
|
||||
STMTS_COLUMN_NSCAN - SQLITE_STMTSTATUS_FULLSCAN_STEP;
|
||||
/* Fall thru */
|
||||
}
|
||||
case STMTS_COLUMN_NSCAN:
|
||||
case STMTS_COLUMN_NSORT:
|
||||
case STMTS_COLUMN_NAIDX:
|
||||
case STMTS_COLUMN_NSTEP:
|
||||
case STMTS_COLUMN_MEM: {
|
||||
case STMTS_COLUMN_REPREP:
|
||||
case STMTS_COLUMN_RUN: {
|
||||
sqlite3_result_int(ctx, sqlite3_stmt_status(pCur->pStmt,
|
||||
i-STMTS_COLUMN_NSCAN+SQLITE_STMTSTATUS_FULLSCAN_STEP, 0));
|
||||
break;
|
||||
|
25
manifest
25
manifest
@ -1,5 +1,5 @@
|
||||
C Build\sthe\s"stmts"\svirtual\stable\sinto\sthe\samalgamation.\s\sIt\sis\sactive\sonly\nwhen\scompiled\susing\sSQLITE_ENABLE_STMTSVTAB.\s\sThat\soption\sis\ssupplied\sto\sthe\ncommand-line\sshell.
|
||||
D 2017-06-28T15:47:29.587
|
||||
C Add\sthe\sSQLITE_STMTSTATUS_REPREPARE\sand\sSQLITE_STMTSTATUS_RUN\soptions\sto\nsqlite3_stmt_status().\s\sUse\sthis\sfor\stwo\snew\scolumns\sin\sthe\sstmts\svirtual\ntable.
|
||||
D 2017-06-29T12:49:18.757
|
||||
F Makefile.in 8b27c128f319083e71cbe27695db058b4ff96970d380ecdf15b19bb8b650e6d9
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc aec853b75178fe8ce79a7dcd3f897b557f3aa6274481254de4db7c029c7e4073
|
||||
@ -234,7 +234,7 @@ F ext/misc/sha1.c 0b9e9b855354910d3ca467bf39099d570e73db56
|
||||
F ext/misc/shathree.c fa185d7aee0ad0aca5e091b4a2db7baff11796170e5793b5de99e511a13af448
|
||||
F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52
|
||||
F ext/misc/spellfix.c a4723b6aff748a417b5091b68a46443265c40f0d
|
||||
F ext/misc/stmts.c c96f66005174cb2b43bf8cbb3c33257635ea2f683c9713aadd5209c27930586f
|
||||
F ext/misc/stmts.c a537a976bb901ebfb0f5e3bfe72f3e6d76f30186d4b29fb9c9bc68f145a33050
|
||||
F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512
|
||||
F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95
|
||||
F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178
|
||||
@ -408,7 +408,7 @@ F src/resolve.c adf3ef9843135b1383321ad751f16f5a40c3f37925154555a3e61653d2a954e8
|
||||
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
|
||||
F src/select.c 35ccfae64cecfa843d54a5898c4ab7d6595ce03d147267fa5eecdc8eab39cd6a
|
||||
F src/shell.c 227b86f2bdd707d0a177a4805a5c0b0378ef8337ab1ad04f5d79dc479568735a
|
||||
F src/sqlite.h.in 2555ff1b79a1aadeb4eb761740351dc3027fa08120bf84511633ba75a630e7a8
|
||||
F src/sqlite.h.in 40c70d4c9c39f69c4de6704428eaacc3e0ae939af49bdb7bc6b272efe2d61516
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28
|
||||
F src/sqliteInt.h 620093497e54998c6b2a01ad98aed9b561716c3db4bde0cc37c8bf2416200bed
|
||||
@ -416,7 +416,7 @@ F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6
|
||||
F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1
|
||||
F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34
|
||||
F src/tclsqlite.c cbf6313f86400acdf7dbf55fcd218cd28d43110a1210967efbc4f250646f81c0
|
||||
F src/test1.c 735f7711e787f30ad4e0001220c580ce456d9f731e22e0e5f86dd5c7e41ccd4d
|
||||
F src/test1.c 1c0726cdf7389ed053a9b9aa0dc3c63f3b9bbc607a25decae6549682008510b3
|
||||
F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5
|
||||
F src/test3.c b8434949dfb8aff8dfa082c8b592109e77844c2135ed3c492113839b6956255b
|
||||
F src/test4.c 18ec393bb4d0ad1de729f0b94da7267270f3d8e6
|
||||
@ -473,11 +473,11 @@ F src/update.c c443935c652af9365e033f756550b5032d02e1b06eb2cb890ed7511ae0c051dc
|
||||
F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c
|
||||
F src/util.c fc081ec6f63448dcd80d3dfad35baecfa104823254a815b081a4d9fe76e1db23
|
||||
F src/vacuum.c 874c0f2f15ab2908748297d587d22d485ea96d55aaec91d4775dddb2e24d2ecf
|
||||
F src/vdbe.c 50f4f47bb190099b61fe87e239de17ad00636a522a271dd9b28329053091401d
|
||||
F src/vdbe.c adc8a378710ec2376101483cc8a5f499539ee9bbebfb2a784f3370704d5d44ad
|
||||
F src/vdbe.h 70a409d171d4e51b962f0d53abf15c33c404c6aa4c9d62fb3a931b5a62ba9615
|
||||
F src/vdbeInt.h cdcdabad4f5d6bf7a3beb826a7f33ee6f8f1cb220042bedd5b7d4bf2ea1d179f
|
||||
F src/vdbeInt.h a2d03f8b4dd8fc2f80c93b408d54c7c28f696b7156ed6fe2691ae2b58828b72e
|
||||
F src/vdbeapi.c c961d8d9e0f52e2df60a6ddbbccd7d99dc4d00103db7e53f77fcef44fbd23178
|
||||
F src/vdbeaux.c d7c7a57f59dc22c05e9a16177615f604fe73588b0ebdc84b540ba5efe3ada430
|
||||
F src/vdbeaux.c 09aaf89ef0fd9455ba5f814891e708f66705c9b3b5218fd89b087de59f2e5fb4
|
||||
F src/vdbeblob.c 359891617358deefc85bef7bcf787fa6b77facb9
|
||||
F src/vdbemem.c 8d78df62becfd2dce3c317f64b32a94ecaff8346d814bc8b0b877b38a1ad3718
|
||||
F src/vdbesort.c f512c68d0bf7e0105316a5594c4329358c8ee9cae3b25138df041d97516c0372
|
||||
@ -1584,10 +1584,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P f02a54599de7620438aecd3753199fc52ce8919d7503bb8b2f5592b0e51dbf8c
|
||||
R 71e0a5250c5819c46c7a10d34cbfc101
|
||||
T *branch * stmts-vtab
|
||||
T *sym-stmts-vtab *
|
||||
T -sym-trunk *
|
||||
P 0ff057d86e42e518fda22bfbf5f1977ab6bd0a74a9211ff259ee7e8a7ce98b58
|
||||
R f6e469b6c6dbd53dda3bdf4437d3f4e3
|
||||
U drh
|
||||
Z 219a446101d8dd42aec8900ee9301107
|
||||
Z a55a86cd1b770fee93742b0b716003d2
|
||||
|
@ -1 +1 @@
|
||||
0ff057d86e42e518fda22bfbf5f1977ab6bd0a74a9211ff259ee7e8a7ce98b58
|
||||
b0b0c8f8d548ef78584ab714ab120b01c1b83fc0d8ae2fd7626b970bab9fca58
|
@ -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
|
||||
|
@ -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");
|
||||
|
@ -7079,6 +7079,7 @@ case OP_Init: { /* jump */
|
||||
pOp->p1 = 0;
|
||||
}
|
||||
pOp->p1++;
|
||||
p->aCounter[SQLITE_STMTSTATUS_RUN]++;
|
||||
goto jump_to_p2;
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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]++;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user