Add the SQLITE_ENABLE_EXPLAIN_COMMENTS compile-time option to enable extra

commentary in the EXPLAIN output.  Formerly, this was only available with
SQLITE_DEBUG.

FossilOrigin-Name: e1a89b56f7173166bb9224e2e360fd67ad3399c3
This commit is contained in:
drh 2013-10-30 02:28:23 +00:00
parent f63552b258
commit c7379ce442
7 changed files with 33 additions and 22 deletions

View File

@ -1,5 +1,5 @@
C Enhanced\sdisplay\sof\sregister\sranges\sin\sthe\sauxiliary\scomments\sadded\sto\sEXPLAIN.
D 2013-10-30T00:25:03.220
C Add\sthe\sSQLITE_ENABLE_EXPLAIN_COMMENTS\scompile-time\soption\sto\senable\sextra\ncommentary\sin\sthe\sEXPLAIN\soutput.\s\sFormerly,\sthis\swas\sonly\savailable\swith\nSQLITE_DEBUG.
D 2013-10-30T02:28:23.508
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 0522b53cdc1fcfc18f3a98e0246add129136c654
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -145,7 +145,7 @@ F main.mk c6a433cb334bbb019625c137ab5d5e7568b47cff
F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a
F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f
F mkextw.sh d2a981497b404d6498f5ff3e3b1f3816bdfcb338
F mkopcodec.awk 393b20a2a99557ca695f7e1261c32d087ff7c0b4
F mkopcodec.awk c2ff431854d702cdd2d779c9c0d1f58fa16fa4ea
F mkopcodeh.awk 987ee588ff3bb4043bed2185c1ee2bdc39b1e526
F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83
F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
@ -223,7 +223,7 @@ F src/shell.c d5eebdc6034014103de2b9d58e1d3f6f7de0fb50
F src/sqlite.h.in 547a44dd4ff4d975e92a645ea2d609e543a83d0f
F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e
F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
F src/sqliteInt.h 4dd81a25a919509ce94b1f8f120bbef14458d4b9
F src/sqliteInt.h 6eff1bbd7e687510c4d5a2aea915b50a51001eb2
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
@ -274,16 +274,16 @@ F src/test_vfs.c e72f555ef7a59080f898fcf1a233deb9eb704ea9
F src/test_vfstrace.c 34b544e80ba7fb77be15395a609c669df2e660a2
F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
F src/tokenize.c 70061085a51f2f4fc15ece94f32c03bcb78e63b2
F src/trigger.c ba0a883cd536b7dfdd4df3733001f5372a4299da
F src/trigger.c 53d6b5d50b3b23d4fcd0a36504feb5cff9aed716
F src/update.c f5182157f5d0d0a97bc5f5e3c9bdba0dfbe08f08
F src/utf.c 6fc6c88d50448c469c5c196acf21617a24f90269
F src/util.c 2fa6c821d28bbdbeec1b2a7b091a281c9ef8f918
F src/vacuum.c f313bc97123a4dd4bfd3f50a00c4d44c08a5b1b7
F src/vdbe.c de4018a314991d41f9b8fb68a17a04471076675d
F src/vdbe.h 4f554b5627f26710c4c36d919110a3fc611ca5c4
F src/vdbe.h 6bdee35c54d57fd52733d4c542781820009311dc
F src/vdbeInt.h ff57f67aee1ba26a3a47e786533dab155ab6dad6
F src/vdbeapi.c 93a22a9ba2abe292d5c2cf304d7eb2e894dde0ed
F src/vdbeaux.c 24deeaf02e8c654af95f83dad6bff79b8bfaf844
F src/vdbeaux.c 1cbff05cb4c6618d805b4d4efc15d31af0f47f0d
F src/vdbeblob.c 5dc79627775bd9a9b494dd956e26297946417d69
F src/vdbemem.c 649933bad3e922465b726eaf85c72a75acba2ab7
F src/vdbesort.c 3937e06b2a0e354500e17dc206ef4c35770a5017
@ -1126,7 +1126,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
P 5f310c6a22b8bb5f860296074aee130c14101681
R 56a9cac237ebc2d22a08882e57a2deb0
P d6b0c39281d0751ecec04d7c19d9d2931d133e8e
R 97e786a08b0a2c7a14cb84c2e159324e
U drh
Z 31acf4b64a31acd4cd8cd14b574bab97
Z 1b6acaf0339443874185cc93aaa66a02

View File

@ -1 +1 @@
d6b0c39281d0751ecec04d7c19d9d2931d133e8e
e1a89b56f7173166bb9224e2e360fd67ad3399c3

View File

@ -14,7 +14,7 @@ BEGIN {
printf "#if !defined(SQLITE_OMIT_EXPLAIN)"
printf " || defined(VDBE_PROFILE)"
print " || defined(SQLITE_DEBUG)"
print "#if defined(SQLITE_DEBUG)"
print "#if defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) || defined(SQLITE_DEBUG)"
print "# define OpHelp(X) \"\\0\" X"
print "#else"
print "# define OpHelp(X)"

View File

@ -217,6 +217,13 @@
# undef NDEBUG
#endif
/*
** Enable SQLITE_ENABLE_EXPLAIN_COMMENTS if SQLITE_DEBUG is turned on.
*/
#if !defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) && defined(SQLITE_DEBUG)
# define SQLITE_ENABLE_EXPLAIN_COMMENTS 1
#endif
/*
** The testcase() macro is used to aid in coverage testing. When
** doing coverage testing, the condition inside the argument to

View File

@ -784,7 +784,7 @@ static int codeTriggerProgram(
return 0;
}
#ifdef SQLITE_DEBUG
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
/*
** This function is used to add VdbeComment() annotations to a VDBE
** program. It is not used in production code, only for debugging.

View File

@ -61,7 +61,7 @@ struct VdbeOp {
SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */
int (*xAdvance)(BtCursor *, int *);
} p4;
#ifdef SQLITE_DEBUG
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
char *zComment; /* Comment to improve readability */
#endif
#ifdef VDBE_PROFILE
@ -219,7 +219,7 @@ void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);
#endif
#ifndef NDEBUG
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
void sqlite3VdbeComment(Vdbe*, const char*, ...);
# define VdbeComment(X) sqlite3VdbeComment X
void sqlite3VdbeNoopComment(Vdbe*, const char*, ...);

View File

@ -144,8 +144,10 @@ int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){
pOp->p3 = p3;
pOp->p4.p = 0;
pOp->p4type = P4_NOTUSED;
#ifdef SQLITE_DEBUG
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
pOp->zComment = 0;
#endif
#ifdef SQLITE_DEBUG
if( p->db->flags & SQLITE_VdbeAddopTrace ){
sqlite3VdbePrintOp(0, i, &p->aOp[i]);
}
@ -532,8 +534,10 @@ int sqlite3VdbeAddOpList(Vdbe *p, int nOp, VdbeOpList const *aOp){
pOut->p4type = P4_NOTUSED;
pOut->p4.p = 0;
pOut->p5 = 0;
#ifdef SQLITE_DEBUG
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
pOut->zComment = 0;
#endif
#ifdef SQLITE_DEBUG
if( p->db->flags & SQLITE_VdbeAddopTrace ){
sqlite3VdbePrintOp(0, i+addr, &p->aOp[i+addr]);
}
@ -663,7 +667,7 @@ static void vdbeFreeOpArray(sqlite3 *db, Op *aOp, int nOp){
Op *pOp;
for(pOp=aOp; pOp<&aOp[nOp]; pOp++){
freeP4(db, pOp->p4type, pOp->p4.p);
#ifdef SQLITE_DEBUG
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
sqlite3DbFree(db, pOp->zComment);
#endif
}
@ -779,7 +783,7 @@ void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){
}
}
#ifndef NDEBUG
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
/*
** Change the comment on the most recently coded instruction. Or
** insert a No-op and add the comment to that new instruction. This
@ -854,7 +858,7 @@ VdbeOp *sqlite3VdbeGetOp(Vdbe *p, int addr){
}
}
#if defined(SQLITE_DEBUG)
#if defined(SQLITE_ENABLE_EXPLAIN_COMMENTS)
/*
** Return an integer value for one of the parameters to the opcode pOp
** determined by character c.
@ -1126,7 +1130,7 @@ void sqlite3VdbePrintOp(FILE *pOut, int pc, Op *pOp){
static const char *zFormat1 = "%4d %-13s %4d %4d %4d %-4s %.2X %s\n";
if( pOut==0 ) pOut = stdout;
zP4 = displayP4(pOp, zPtr, sizeof(zPtr));
#ifdef SQLITE_DEBUG
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
displayComment(pOp, zP4, zCom, sizeof(zCom));
#else
zCom[0] = 0
@ -1372,7 +1376,7 @@ int sqlite3VdbeList(
pMem->enc = SQLITE_UTF8;
pMem++;
#ifdef SQLITE_DEBUG
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
if( sqlite3VdbeMemGrow(pMem, 500, 0) ){
assert( p->db->mallocFailed );
return SQLITE_ERROR;