From: drh Date: Wed, 30 Oct 2013 00:25:03 +0000 (+0000) Subject: Enhanced display of register ranges in the auxiliary comments added to EXPLAIN. X-Git-Tag: version-3.8.2~147 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f63552b258ec670f0080edc41367b45892554fc7;p=thirdparty%2Fsqlite.git Enhanced display of register ranges in the auxiliary comments added to EXPLAIN. FossilOrigin-Name: d6b0c39281d0751ecec04d7c19d9d2931d133e8e --- diff --git a/manifest b/manifest index 5cb15b2733..01c774851f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Automatically\sgenerated\scomments\son\smany\sVDBE\sopcodes\swhen\sin\sSQLITE_DEBUG\nmost.\s\sComments\sderive\sfrom\sthe\s"Synopsis:"\sfield\sadded\sto\seach\sopcode\ndefinition\sin\svdbe.c. -D 2013-10-29T20:40:47.279 +C Enhanced\sdisplay\sof\sregister\sranges\sin\sthe\sauxiliary\scomments\sadded\sto\sEXPLAIN. +D 2013-10-30T00:25:03.220 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 0522b53cdc1fcfc18f3a98e0246add129136c654 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -279,11 +279,11 @@ F src/update.c f5182157f5d0d0a97bc5f5e3c9bdba0dfbe08f08 F src/utf.c 6fc6c88d50448c469c5c196acf21617a24f90269 F src/util.c 2fa6c821d28bbdbeec1b2a7b091a281c9ef8f918 F src/vacuum.c f313bc97123a4dd4bfd3f50a00c4d44c08a5b1b7 -F src/vdbe.c 3d0bd1f8a3ebec1c253c5050c1008bffcbcb21eb +F src/vdbe.c de4018a314991d41f9b8fb68a17a04471076675d F src/vdbe.h 4f554b5627f26710c4c36d919110a3fc611ca5c4 F src/vdbeInt.h ff57f67aee1ba26a3a47e786533dab155ab6dad6 F src/vdbeapi.c 93a22a9ba2abe292d5c2cf304d7eb2e894dde0ed -F src/vdbeaux.c e670a2bd8bf7ba10fad63b9264c5d723c38f02d0 +F src/vdbeaux.c 24deeaf02e8c654af95f83dad6bff79b8bfaf844 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 3a9e3ed94bf617f00c48009b1a6d348a8f23a3cf -R cc5dfe91a476c5736a19ee6bb40f8034 +P 5f310c6a22b8bb5f860296074aee130c14101681 +R 56a9cac237ebc2d22a08882e57a2deb0 U drh -Z 873c3bf640fe9fcbf6a7225bea069855 +Z 31acf4b64a31acd4cd8cd14b574bab97 diff --git a/manifest.uuid b/manifest.uuid index f417371d33..e7f00ea803 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5f310c6a22b8bb5f860296074aee130c14101681 \ No newline at end of file +d6b0c39281d0751ecec04d7c19d9d2931d133e8e \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 0fd344c0c4..4b922ee73b 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -1035,7 +1035,7 @@ case OP_Variable: { /* out2-prerelease */ } /* Opcode: Move P1 P2 P3 * * -** Synopsis: r[P2]=r[P1] N=P3 +** Synopsis: r[P2@P3]=r[P1@P3] ** ** Move the values in register P1..P1+P3 over into ** registers P2..P2+P3. Registers P1..P1+P3 are @@ -1078,7 +1078,7 @@ case OP_Move: { } /* Opcode: Copy P1 P2 P3 * * -** Synopsis: r[P2]=r[P1] N=P3 +** Synopsis: r[P2@P3]=r[P1@P3] ** ** Make a copy of registers P1..P1+P3 into registers P2..P2+P3. ** @@ -1400,7 +1400,7 @@ case OP_CollSeq: { } /* Opcode: Function P1 P2 P3 P4 P5 -** Synopsis: r[P3]=func(r[P2]..) N=P5 +** Synopsis: r[P3]=func(r[P2@P5]) ** ** Invoke a user function (P4 is a pointer to a Function structure that ** defines the function) with P5 arguments taken from register P2 and @@ -2513,7 +2513,7 @@ op_column_out: } /* Opcode: Affinity P1 P2 * P4 * -** Synopsis: affinity(r[P1]) N=P2 +** Synopsis: affinity(r[P1@P2]) ** ** Apply affinities to a range of P2 registers starting with P1. ** @@ -2540,7 +2540,7 @@ case OP_Affinity: { } /* Opcode: MakeRecord P1 P2 P3 P4 * -** Synopsis: r[P3]=rec(r[P1]..) N=P2 +** Synopsis: r[P3]=mkrec(r[P1@P2]) ** ** Convert P2 registers beginning with P1 into the [record format] ** use as a data record in a database table or as a key @@ -3379,7 +3379,7 @@ case OP_SorterOpen: { } /* Opcode: OpenPseudo P1 P2 P3 * P5 -** Synopsis: content in r[P2].. N=P3 +** Synopsis: content in r[P2@P3] ** ** Open a new cursor that points to a fake table that contains a single ** row of data. The content of that one row in the content of memory @@ -3422,7 +3422,7 @@ case OP_Close: { } /* Opcode: SeekGe P1 P2 P3 P4 * -** Synopsis: key=r[P3].. N=P4 +** Synopsis: key=r[P3@P4] ** ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), ** use the value in register P3 as the key. If cursor P1 refers @@ -3436,7 +3436,7 @@ case OP_Close: { ** See also: Found, NotFound, Distinct, SeekLt, SeekGt, SeekLe */ /* Opcode: SeekGt P1 P2 P3 P4 * -** Synopsis: key=r[P3].. N=P4 +** Synopsis: key=r[P3@P4] ** ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), ** use the value in register P3 as a key. If cursor P1 refers @@ -3450,7 +3450,7 @@ case OP_Close: { ** See also: Found, NotFound, Distinct, SeekLt, SeekGe, SeekLe */ /* Opcode: SeekLt P1 P2 P3 P4 * -** Synopsis: key=r[P3].. N=P4 +** Synopsis: key=r[P3@P4] ** ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), ** use the value in register P3 as a key. If cursor P1 refers @@ -3464,7 +3464,7 @@ case OP_Close: { ** See also: Found, NotFound, Distinct, SeekGt, SeekGe, SeekLe */ /* Opcode: SeekLe P1 P2 P3 P4 * -** Synopsis: key=r[P3].. N=P4 +** Synopsis: key=r[P3@P4] ** ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), ** use the value in register P3 as a key. If cursor P1 refers @@ -3658,7 +3658,7 @@ case OP_Seek: { /* in2 */ /* Opcode: Found P1 P2 P3 P4 * -** Synopsis: key=r[P3].. N=P4 +** Synopsis: key=r[P3@P4] ** ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If ** P4>0 then register P3 is the first of P4 registers that form an unpacked @@ -3669,7 +3669,7 @@ case OP_Seek: { /* in2 */ ** P1 is left pointing at the matching entry. */ /* Opcode: NotFound P1 P2 P3 P4 * -** Synopsis: key=r[P3] N=P4 +** Synopsis: key=r[P3@P4] ** ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If ** P4>0 then register P3 is the first of P4 registers that form an unpacked @@ -4639,7 +4639,7 @@ case OP_IdxInsert: { /* in2 */ } /* Opcode: IdxDelete P1 P2 P3 * * -** Synopsis: key=r[P2].. +** Synopsis: key=r[P2@P3] ** ** The content of P3 registers starting at register P2 form ** an unpacked index key. This opcode removes that entry from the @@ -4712,7 +4712,7 @@ case OP_IdxRowid: { /* out2-prerelease */ } /* Opcode: IdxGE P1 P2 P3 P4 P5 -** Synopsis: key=r[P3] N=P4 +** Synopsis: key=r[P3@P4] ** ** The P4 register values beginning with P3 form an unpacked index ** key that omits the ROWID. Compare this key value against the index @@ -4727,7 +4727,7 @@ case OP_IdxRowid: { /* out2-prerelease */ ** the result is false whereas it would be true with IdxGT. */ /* Opcode: IdxLT P1 P2 P3 P4 P5 -** Synopsis: key=r[P3] N=P4 +** Synopsis: key=r[P3@P4] ** ** The P4 register values beginning with P3 form an unpacked index ** key that omits the ROWID. Compare this key value against the index @@ -5470,7 +5470,7 @@ case OP_IfZero: { /* jump, in1 */ } /* Opcode: AggStep * P2 P3 P4 P5 -** Synopsis: accum=r[P3] step(r[P2]..) N=P5 +** Synopsis: accum=r[P3] step(r[P2@P5]) ** ** Execute the step function for an aggregate. The ** function has P5 arguments. P4 is a pointer to the FuncDef @@ -6088,7 +6088,7 @@ case OP_VRename: { #ifndef SQLITE_OMIT_VIRTUALTABLE /* Opcode: VUpdate P1 P2 P3 P4 * -** Synopsis: data=r[P3] N=P2 +** Synopsis: data=r[P3@P2] ** ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. ** This opcode invokes the corresponding xUpdate method. P2 values diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 99caa70c6b..96f28ce800 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -855,10 +855,27 @@ VdbeOp *sqlite3VdbeGetOp(Vdbe *p, int addr){ } #if defined(SQLITE_DEBUG) +/* +** Return an integer value for one of the parameters to the opcode pOp +** determined by character c. +*/ +static int translateP(char c, const Op *pOp){ + if( c=='1' ) return pOp->p1; + if( c=='2' ) return pOp->p2; + if( c=='3' ) return pOp->p3; + if( c=='4' ) return pOp->p4.i; + return pOp->p5; +} + /* ** Compute a string for the "comment" field of a VDBE opcode listing */ -static int displayComment(Op *pOp, const char *zP4, char *zTemp, int nTemp){ +static int displayComment( + const Op *pOp, /* The opcode to be commented */ + const char *zP4, /* Previously obtained value for P4 */ + char *zTemp, /* Write result here */ + int nTemp /* Space available in zTemp[] */ +){ const char *zOpName; const char *zSynopsis; int nOpName; @@ -867,28 +884,32 @@ static int displayComment(Op *pOp, const char *zP4, char *zTemp, int nTemp){ nOpName = sqlite3Strlen30(zOpName); if( zOpName[nOpName+1] ){ int seenCom = 0; + char c; zSynopsis = zOpName += nOpName + 1; - for(ii=jj=0; jjp1; break; - case '2': v = pOp->p2; break; - case '3': v = pOp->p3; break; - case '5': v = pOp->p5; break; - case '4': zShow = zP4; break; - case 'X': zShow = pOp->zComment; seenCom = 1; break; - } - if( zShow ){ - sqlite3_snprintf(nTemp-jj, zTemp+jj, "%s", zShow); + for(ii=jj=0; jjzComment); + seenCom = 1; }else{ - sqlite3_snprintf(nTemp-jj, zTemp+jj, "%d", v); + int v1 = translateP(c, pOp); + int v2; + sqlite3_snprintf(nTemp-jj, zTemp+jj, "%d", v1); + if( strncmp(zSynopsis+ii+1, "@P", 2)==0 ){ + ii += 3; + jj += sqlite3Strlen30(zTemp+jj); + v2 = translateP(zSynopsis[ii], pOp); + if( v2>1 ) sqlite3_snprintf(nTemp-jj, zTemp+jj, "..%d", v1+v2-1); + }else if( strncmp(zSynopsis+ii+1, "..P3", 4)==0 && pOp->p3==0 ){ + ii += 4; + } } jj += sqlite3Strlen30(zTemp+jj); }else{ - zTemp[jj++] = zSynopsis[ii]; + zTemp[jj++] = c; } } if( !seenCom && jjzComment ){