From: drh Date: Tue, 29 Oct 2013 20:40:47 +0000 (+0000) Subject: Automatically generated comments on many VDBE opcodes when in SQLITE_DEBUG X-Git-Tag: version-3.8.2~148 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=81316f890862f83a2d6d07407d4a4f03736272cf;p=thirdparty%2Fsqlite.git Automatically generated comments on many VDBE opcodes when in SQLITE_DEBUG most. Comments derive from the "Synopsis:" field added to each opcode definition in vdbe.c. FossilOrigin-Name: 5f310c6a22b8bb5f860296074aee130c14101681 --- diff --git a/manifest b/manifest index f66ec4132d..5cb15b2733 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Formatting\simprovements\sto\sthe\sWHERE-clause\sconstraint\sdisplay\sin\sthe\nwheretrace\sdebugging\slogic. -D 2013-10-28T22:33:36.558 +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 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 0522b53cdc1fcfc18f3a98e0246add129136c654 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -145,8 +145,8 @@ F main.mk c6a433cb334bbb019625c137ab5d5e7568b47cff F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f F mkextw.sh d2a981497b404d6498f5ff3e3b1f3816bdfcb338 -F mkopcodec.awk f6fccee29e68493bfd90a2e0466ede5fa94dd2fc -F mkopcodeh.awk e7334b45c023b5ee2efc6e8f479560c2026fa34a +F mkopcodec.awk 393b20a2a99557ca695f7e1261c32d087ff7c0b4 +F mkopcodeh.awk 987ee588ff3bb4043bed2185c1ee2bdc39b1e526 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -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 3d960c844cee53830f33717b4f5d23d7ee56685f +F src/vdbe.c 3d0bd1f8a3ebec1c253c5050c1008bffcbcb21eb F src/vdbe.h 4f554b5627f26710c4c36d919110a3fc611ca5c4 F src/vdbeInt.h ff57f67aee1ba26a3a47e786533dab155ab6dad6 F src/vdbeapi.c 93a22a9ba2abe292d5c2cf304d7eb2e894dde0ed -F src/vdbeaux.c 55f4858fe6abd84bd7311acbf30a75a28903ec25 +F src/vdbeaux.c e670a2bd8bf7ba10fad63b9264c5d723c38f02d0 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 05a35b09b140fed0898afd36bc641e275545a35f -R ff7bb3f8071649882bf49e664fcf0a45 +P 3a9e3ed94bf617f00c48009b1a6d348a8f23a3cf +R cc5dfe91a476c5736a19ee6bb40f8034 U drh -Z 9d63edd4f24f764673ec22cc76454487 +Z 873c3bf640fe9fcbf6a7225bea069855 diff --git a/manifest.uuid b/manifest.uuid index 9f87ae481e..f417371d33 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3a9e3ed94bf617f00c48009b1a6d348a8f23a3cf \ No newline at end of file +5f310c6a22b8bb5f860296074aee130c14101681 \ No newline at end of file diff --git a/mkopcodec.awk b/mkopcodec.awk index 2ef77d4cca..f4a09bf3e5 100644 --- a/mkopcodec.awk +++ b/mkopcodec.awk @@ -12,22 +12,36 @@ BEGIN { print "/* Automatically generated. Do not edit */" print "/* See the mkopcodec.awk script for details. */" printf "#if !defined(SQLITE_OMIT_EXPLAIN)" - printf " || !defined(NDEBUG)" printf " || defined(VDBE_PROFILE)" print " || defined(SQLITE_DEBUG)" + print "#if defined(SQLITE_DEBUG)" + print "# define OpHelp(X) \"\\0\" X" + print "#else" + print "# define OpHelp(X)" + print "#endif" print "const char *sqlite3OpcodeName(int i){" print " static const char *const azName[] = { \"?\"," mx = 0 } -/define OP_/ { +/^.define OP_/ { sub("OP_","",$2) i = $3+0 label[i] = $2 if( mxz, pIn2->z, pIn2->n); } memcpy(&pOut->z[pIn2->n], pIn1->z, pIn1->n); - pOut->z[nByte] = 0; + pOut->z[nByte]=0; pOut->z[nByte+1] = 0; pOut->flags |= MEM_Term; pOut->n = (int)nByte; @@ -1238,12 +1252,14 @@ case OP_Concat: { /* same as TK_CONCAT, in1, in2, out3 */ } /* Opcode: Add P1 P2 P3 * * +** Synopsis: r[P3]=r[P1]+r[P2] ** ** Add the value in register P1 to the value in register P2 ** and store the result in register P3. ** If either input is NULL, the result is NULL. */ /* Opcode: Multiply P1 P2 P3 * * +** Synopsis: r[P3]=r[P1]*r[P2] ** ** ** Multiply the value in register P1 by the value in register P2 @@ -1251,12 +1267,14 @@ case OP_Concat: { /* same as TK_CONCAT, in1, in2, out3 */ ** If either input is NULL, the result is NULL. */ /* Opcode: Subtract P1 P2 P3 * * +** Synopsis: r[P3]=r[P2]-r[P1] ** ** Subtract the value in register P1 from the value in register P2 ** and store the result in register P3. ** If either input is NULL, the result is NULL. */ /* Opcode: Divide P1 P2 P3 * * +** Synopsis: r[P3]=r[P1]/r[P2] ** ** Divide the value in register P1 by the value in register P2 ** and store the result in register P3 (P3=P2/P1). If the value in @@ -1264,6 +1282,7 @@ case OP_Concat: { /* same as TK_CONCAT, in1, in2, out3 */ ** NULL, the result is NULL. */ /* Opcode: Remainder P1 P2 P3 * * +** Synopsis: r[P3]=r[P1]%r[P2] ** ** Compute the remainder after integer division of the value in ** register P1 by the value in register P2 and store the result in P3. @@ -1381,6 +1400,7 @@ case OP_CollSeq: { } /* Opcode: Function P1 P2 P3 P4 P5 +** Synopsis: r[P3]=func(r[P2]..) N=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 @@ -1488,18 +1508,21 @@ case OP_Function: { } /* Opcode: BitAnd P1 P2 P3 * * +** Synopsis: r[P3]=r[P1]&r[P2] ** ** Take the bit-wise AND of the values in register P1 and P2 and ** store the result in register P3. ** If either input is NULL, the result is NULL. */ /* Opcode: BitOr P1 P2 P3 * * +** Synopsis: r[P3]=r[P1]|r[P2] ** ** Take the bit-wise OR of the values in register P1 and P2 and ** store the result in register P3. ** If either input is NULL, the result is NULL. */ /* Opcode: ShiftLeft P1 P2 P3 * * +** Synopsis: r[P3]=r[P2]<>r[P1] ** ** Shift the integer value in register P2 to the right by the ** number of bits specified by the integer in register P1. @@ -1566,6 +1590,7 @@ case OP_ShiftRight: { /* same as TK_RSHIFT, in1, in2, out3 */ } /* Opcode: AddImm P1 P2 * * * +** Synopsis: r[P1]=r[P1]+P2 ** ** Add the constant P2 to the value in register P1. ** The result is always an integer. @@ -1724,6 +1749,7 @@ case OP_ToReal: { /* same as TK_TO_REAL, in1 */ #endif /* !defined(SQLITE_OMIT_CAST) && !defined(SQLITE_OMIT_FLOATING_POINT) */ /* Opcode: Lt P1 P2 P3 P4 P5 +** Synopsis: r[P1] < r[P3] ** ** Compare the values in register P1 and P3. If reg(P3) r[P3] ** ** This works just like the Lt opcode except that the jump is taken if ** the content of register P3 is greater than the content of ** register P1. See the Lt opcode for additional information. */ /* Opcode: Ge P1 P2 P3 P4 P5 +** Synopsis: r[P1] >= r[P3] ** ** This works just like the Lt opcode except that the jump is taken if ** the content of register P3 is greater than or equal to the content of @@ -1984,6 +2015,7 @@ case OP_Jump: { /* jump */ } /* Opcode: And P1 P2 P3 * * +** Synopsis: r[P3]=(r[P1] && r[P2]) ** ** Take the logical AND of the values in registers P1 and P2 and ** write the result into register P3. @@ -1993,6 +2025,7 @@ case OP_Jump: { /* jump */ ** a NULL output. */ /* Opcode: Or P1 P2 P3 * * +** Synopsis: r[P3]=(r[P1] || r[P2]) ** ** Take the logical OR of the values in register P1 and P2 and ** store the answer in register P3. @@ -2036,6 +2069,7 @@ case OP_Or: { /* same as TK_OR, in1, in2, out3 */ } /* Opcode: Not P1 P2 * * * +** Synopsis: r[P2]= !r[P1] ** ** Interpret the value in register P1 as a boolean value. Store the ** boolean complement in register P2. If the value in register P1 is @@ -2053,6 +2087,7 @@ case OP_Not: { /* same as TK_NOT, in1, out2 */ } /* Opcode: BitNot P1 P2 * * * +** Synopsis: r[P1]= ~r[P1] ** ** Interpret the content of register P1 as an integer. Store the ** ones-complement of the P1 value into register P2. If P1 holds @@ -2141,6 +2176,7 @@ case OP_NotNull: { /* same as TK_NOTNULL, jump, in1 */ } /* Opcode: Column P1 P2 P3 P4 P5 +** Synopsis: r[P3]=PX ** ** Interpret the data that cursor P1 points to as a structure built using ** the MakeRecord instruction. (See the MakeRecord opcode for additional @@ -2477,6 +2513,7 @@ op_column_out: } /* Opcode: Affinity P1 P2 * P4 * +** Synopsis: affinity(r[P1]) N=P2 ** ** Apply affinities to a range of P2 registers starting with P1. ** @@ -2503,6 +2540,7 @@ case OP_Affinity: { } /* Opcode: MakeRecord P1 P2 P3 P4 * +** Synopsis: r[P3]=rec(r[P1]..) N=P2 ** ** Convert P2 registers beginning with P1 into the [record format] ** use as a data record in a database table or as a key @@ -2635,6 +2673,7 @@ case OP_MakeRecord: { } /* Opcode: Count P1 P2 * * * +** Synopsis: r[P2]=count() ** ** Store the number of entries (an integer value) in the table or index ** opened by cursor P1 in register P2 @@ -3111,6 +3150,7 @@ case OP_VerifyCookie: { } /* Opcode: OpenRead P1 P2 P3 P4 P5 +** Synopsis: root=P2 iDb=P3 ** ** Open a read-only cursor for the database table whose root page is ** P2 in a database file. The database file is determined by P3. @@ -3141,6 +3181,7 @@ case OP_VerifyCookie: { ** See also OpenWrite. */ /* Opcode: OpenWrite P1 P2 P3 P4 P5 +** Synopsis: root=P2 iDb=P3 ** ** Open a read/write cursor named P1 on the table or index whose root ** page is P2. Or if P5!=0 use the content of register P2 to find the @@ -3246,6 +3287,7 @@ case OP_OpenWrite: { } /* Opcode: OpenEphemeral P1 P2 * P4 P5 +** Synopsis: nColumn=P2 ** ** Open a new cursor P1 to a transient table. ** The cursor is always opened read/write even if @@ -3257,18 +3299,13 @@ case OP_OpenWrite: { ** if P4 is not 0. If P4 is not NULL, it points to a KeyInfo structure ** that defines the format of keys in the index. ** -** This opcode was once called OpenTemp. But that created -** confusion because the term "temp table", might refer either -** to a TEMP table at the SQL level, or to a table opened by -** this opcode. Then this opcode was call OpenVirtual. But -** that created confusion with the whole virtual-table idea. -** ** The P5 parameter can be a mask of the BTREE_* flags defined ** in btree.h. These flags control aspects of the operation of ** the btree. The BTREE_OMIT_JOURNAL and BTREE_SINGLE flags are ** added automatically. */ /* Opcode: OpenAutoindex P1 P2 * P4 * +** Synopsis: nColumn=P2 ** ** This opcode works the same as OP_OpenEphemeral. It has a ** different name to distinguish its use. Tables created using @@ -3323,6 +3360,7 @@ case OP_OpenEphemeral: { } /* Opcode: SorterOpen P1 P2 * P4 * +** Synopsis: nColumn=P2 ** ** This opcode works like OP_OpenEphemeral except that it opens ** a transient index that is specifically designed to sort large @@ -3341,6 +3379,7 @@ case OP_SorterOpen: { } /* Opcode: OpenPseudo P1 P2 P3 * P5 +** Synopsis: content in r[P2].. N=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 @@ -3383,6 +3422,7 @@ case OP_Close: { } /* Opcode: SeekGe P1 P2 P3 P4 * +** Synopsis: key=r[P3].. N=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 @@ -3396,6 +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 ** ** 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 @@ -3409,6 +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 ** ** 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 @@ -3422,6 +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 ** ** 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 @@ -3587,6 +3630,7 @@ case OP_SeekGt: { /* jump, in3 */ } /* Opcode: Seek P1 P2 * * * +** Synopsis: intkey=r[P2] ** ** P1 is an open table cursor and P2 is a rowid integer. Arrange ** for P1 to move so that it points to the rowid given by P2. @@ -3614,6 +3658,7 @@ case OP_Seek: { /* in2 */ /* Opcode: Found P1 P2 P3 P4 * +** Synopsis: key=r[P3].. N=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 @@ -3624,6 +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 ** ** 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 @@ -3786,6 +3832,7 @@ case OP_IsUnique: { /* jump, in3 */ } /* Opcode: NotExists P1 P2 P3 * * +** Synopsis: intkey=r[P3] ** ** Use the content of register P3 as an integer key. If a record ** with that key does not exist in table of P1, then jump to P2. @@ -3839,6 +3886,7 @@ case OP_NotExists: { /* jump, in3 */ } /* Opcode: Sequence P1 P2 * * * +** Synopsis: r[P2]=rowid ** ** Find the next available sequence number for cursor P1. ** Write the sequence number into register P2. @@ -3854,6 +3902,7 @@ case OP_Sequence: { /* out2-prerelease */ /* Opcode: NewRowid P1 P2 P3 * * +** Synopsis: r[P2]=rowid ** ** Get a new integer record number (a.k.a "rowid") used as the key to a table. ** The record number is not previously used as a key in the database @@ -4003,6 +4052,7 @@ case OP_NewRowid: { /* out2-prerelease */ } /* Opcode: Insert P1 P2 P3 P4 P5 +** Synopsis: intkey=r[P3] data=r[P2] ** ** Write an entry into the table of cursor P1. A new entry is ** created if it doesn't already exist or the data for an existing @@ -4042,6 +4092,7 @@ case OP_NewRowid: { /* out2-prerelease */ ** for indices is OP_IdxInsert. */ /* Opcode: InsertInt P1 P2 P3 P4 P5 +** Synopsis: intkey=P3 data=r[P2] ** ** This works exactly like OP_Insert except that the key is the ** integer value P3, not the value of the integer stored in register P3. @@ -4192,6 +4243,7 @@ case OP_ResetCount: { } /* Opcode: SorterCompare P1 P2 P3 +** Synopsis: if key(P1)!=r[P3] goto P2 ** ** P1 is a sorter cursor. This instruction compares the record blob in ** register P3 with the entry that the sorter cursor currently points to. @@ -4213,6 +4265,7 @@ case OP_SorterCompare: { }; /* Opcode: SorterData P1 P2 * * * +** Synopsis: r[P2]=data ** ** Write into register P2 the current sorter data for sorter cursor P1. */ @@ -4227,6 +4280,7 @@ case OP_SorterData: { } /* Opcode: RowData P1 P2 * * * +** Synopsis: r[P2]=data ** ** Write into register P2 the complete row data for cursor P1. ** There is no interpretation of the data. @@ -4237,6 +4291,7 @@ case OP_SorterData: { ** of a real table, not a pseudo-table. */ /* Opcode: RowKey P1 P2 * * * +** Synopsis: r[P2]=key ** ** Write into register P2 the complete row key for cursor P1. ** There is no interpretation of the data. @@ -4309,6 +4364,7 @@ case OP_RowData: { } /* Opcode: Rowid P1 P2 * * * +** Synopsis: r[P2]=rowid ** ** Store in register P2 an integer which is the key of the table entry that ** P1 is currently point to. @@ -4466,7 +4522,7 @@ case OP_Rewind: { /* jump */ break; } -/* Opcode: Next P1 P2 * P4 P5 +/* Opcode: Next P1 P2 * * P5 ** ** Advance cursor P1 so that it points to the next key/data pair in its ** table or index. If there are no more key/value pairs then fall through @@ -4536,6 +4592,7 @@ case OP_Next: { /* jump */ } /* Opcode: IdxInsert P1 P2 P3 * P5 +** Synopsis: key=r[P2] ** ** Register P2 holds an SQL index key made using the ** MakeRecord instructions. This opcode writes that key @@ -4582,6 +4639,7 @@ case OP_IdxInsert: { /* in2 */ } /* Opcode: IdxDelete P1 P2 P3 * * +** Synopsis: key=r[P2].. ** ** The content of P3 registers starting at register P2 form ** an unpacked index key. This opcode removes that entry from the @@ -4618,6 +4676,7 @@ case OP_IdxDelete: { } /* Opcode: IdxRowid P1 P2 * * * +** Synopsis: r[P2]=rowid ** ** Write into register P2 an integer which is the last entry in the record at ** the end of the index key pointed to by cursor P1. This integer should be @@ -4653,6 +4712,7 @@ case OP_IdxRowid: { /* out2-prerelease */ } /* Opcode: IdxGE P1 P2 P3 P4 P5 +** Synopsis: key=r[P3] N=P4 ** ** The P4 register values beginning with P3 form an unpacked index ** key that omits the ROWID. Compare this key value against the index @@ -4667,6 +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 ** ** The P4 register values beginning with P3 form an unpacked index ** key that omits the ROWID. Compare this key value against the index @@ -4819,6 +4880,7 @@ case OP_Clear: { } /* Opcode: CreateTable P1 P2 * * * +** Synopsis: r[P2]=root iDb=P1 ** ** Allocate a new table in the main database file if P1==0 or in the ** auxiliary database file if P1==1 or in an attached database if @@ -4832,6 +4894,7 @@ case OP_Clear: { ** See also: CreateIndex */ /* Opcode: CreateIndex P1 P2 * * * +** Synopsis: r[P2]=root iDb=P1 ** ** Allocate a new index in the main database file if P1==0 or in the ** auxiliary database file if P1==1 or in an attached database if @@ -5033,6 +5096,7 @@ case OP_IntegrityCk: { #endif /* SQLITE_OMIT_INTEGRITY_CHECK */ /* Opcode: RowSetAdd P1 P2 * * * +** Synopsis: rowset(P1)=r[P2] ** ** Insert the integer value held by register P2 into a boolean index ** held in register P1. @@ -5052,6 +5116,7 @@ case OP_RowSetAdd: { /* in1, in2 */ } /* Opcode: RowSetRead P1 P2 P3 * * +** Synopsis: r[P3]=rowset(P1) ** ** Extract the smallest value from boolean index P1 and put that value into ** register P3. Or, if boolean index P1 is initially empty, leave P3 @@ -5075,6 +5140,7 @@ case OP_RowSetRead: { /* jump, in1, out3 */ } /* Opcode: RowSetTest P1 P2 P3 P4 +** Synopsis: if r[P3] in rowset(P1) goto P2 ** ** Register P3 is assumed to hold a 64-bit integer value. If register P1 ** contains a RowSet object and that RowSet object contains @@ -5278,6 +5344,7 @@ case OP_Param: { /* out2-prerelease */ #ifndef SQLITE_OMIT_FOREIGN_KEY /* Opcode: FkCounter P1 P2 * * * +** Synopsis: fkctr[P1]+=P2 ** ** Increment a "constraint counter" by P2 (P2 may be negative or positive). ** If P1 is non-zero, the database constraint counter is incremented @@ -5296,6 +5363,7 @@ case OP_FkCounter: { } /* Opcode: FkIfZero P1 P2 * * * +** Synopsis: if fkctr[P1]==0 goto P2 ** ** This opcode tests if a foreign key constraint-counter is currently zero. ** If so, jump to instruction P2. Otherwise, fall through to the next @@ -5318,6 +5386,7 @@ case OP_FkIfZero: { /* jump */ #ifndef SQLITE_OMIT_AUTOINCREMENT /* Opcode: MemMax P1 P2 * * * +** Synopsis: r[P1]=max(r[P1],r[P2]) ** ** P1 is a register in the root frame of this VM (the root frame is ** different from the current frame if this instruction is being executed @@ -5348,6 +5417,7 @@ case OP_MemMax: { /* in2 */ #endif /* SQLITE_OMIT_AUTOINCREMENT */ /* Opcode: IfPos P1 P2 * * * +** Synopsis: if r[P1]>0 goto P2 ** ** If the value of register P1 is 1 or greater, jump to P2. ** @@ -5364,6 +5434,7 @@ case OP_IfPos: { /* jump, in1 */ } /* Opcode: IfNeg P1 P2 * * * +** Synopsis: if r[P1]<0 goto P2 ** ** If the value of register P1 is less than zero, jump to P2. ** @@ -5380,6 +5451,7 @@ case OP_IfNeg: { /* jump, in1 */ } /* Opcode: IfZero P1 P2 P3 * * +** Synopsis: r[P1]+=P3, if r[P1]==0 goto P2 ** ** The register P1 must contain an integer. Add literal P3 to the ** value in register P1. If the result is exactly 0, jump to P2. @@ -5398,6 +5470,7 @@ case OP_IfZero: { /* jump, in1 */ } /* Opcode: AggStep * P2 P3 P4 P5 +** Synopsis: accum=r[P3] step(r[P2]..) N=P5 ** ** Execute the step function for an aggregate. The ** function has P5 arguments. P4 is a pointer to the FuncDef @@ -5461,6 +5534,7 @@ case OP_AggStep: { } /* Opcode: AggFinal P1 P2 * P4 * +** Synopsis: accum=r[P1] N=P2 ** ** Execute the finalizer function for an aggregate. P1 is ** the memory location that is the accumulator for the aggregate. @@ -5688,6 +5762,7 @@ case OP_Expire: { #ifndef SQLITE_OMIT_SHARED_CACHE /* Opcode: TableLock P1 P2 P3 P4 * +** Synopsis: iDb=P1 root=P2 write=P3 ** ** Obtain a lock on a particular table. This instruction is only used when ** the shared-cache feature is enabled. @@ -5804,6 +5879,7 @@ case OP_VOpen: { #ifndef SQLITE_OMIT_VIRTUALTABLE /* Opcode: VFilter P1 P2 P3 P4 * +** Synopsis: iPlan=r[P3] zPlan='P4' ** ** P1 is a cursor opened using VOpen. P2 is an address to jump to if ** the filtered result set is empty. @@ -5878,6 +5954,7 @@ case OP_VFilter: { /* jump */ #ifndef SQLITE_OMIT_VIRTUALTABLE /* Opcode: VColumn P1 P2 P3 * * +** Synopsis: r[P3]=vcolumn(P2) ** ** Store the value of the P2-th column of ** the row of the virtual-table that the @@ -6011,6 +6088,7 @@ case OP_VRename: { #ifndef SQLITE_OMIT_VIRTUALTABLE /* Opcode: VUpdate P1 P2 P3 P4 * +** Synopsis: data=r[P3] N=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 d2e495ea14..99caa70c6b 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -854,6 +854,60 @@ VdbeOp *sqlite3VdbeGetOp(Vdbe *p, int addr){ } } +#if defined(SQLITE_DEBUG) +/* +** Compute a string for the "comment" field of a VDBE opcode listing +*/ +static int displayComment(Op *pOp, const char *zP4, char *zTemp, int nTemp){ + const char *zOpName; + const char *zSynopsis; + int nOpName; + int ii, jj; + zOpName = sqlite3OpcodeName(pOp->opcode); + nOpName = sqlite3Strlen30(zOpName); + if( zOpName[nOpName+1] ){ + int seenCom = 0; + 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); + }else{ + sqlite3_snprintf(nTemp-jj, zTemp+jj, "%d", v); + } + jj += sqlite3Strlen30(zTemp+jj); + }else{ + zTemp[jj++] = zSynopsis[ii]; + } + } + if( !seenCom && jjzComment ){ + sqlite3_snprintf(nTemp-jj, zTemp+jj, "; %s", pOp->zComment); + jj += sqlite3Strlen30(zTemp+jj); + } + if( jjzComment ){ + sqlite3_snprintf(nTemp, zTemp, "%s", pOp->zComment); + jj = sqlite3Strlen30(zTemp); + }else{ + zTemp[0] = 0; + jj = 0; + } + return jj; +} +#endif /* SQLITE_DEBUG */ + + #if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) \ || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG) /* @@ -1047,16 +1101,18 @@ void sqlite3VdbeLeave(Vdbe *p){ void sqlite3VdbePrintOp(FILE *pOut, int pc, Op *pOp){ char *zP4; char zPtr[50]; + char zCom[100]; static const char *zFormat1 = "%4d %-13s %4d %4d %4d %-4s %.2X %s\n"; if( pOut==0 ) pOut = stdout; zP4 = displayP4(pOp, zPtr, sizeof(zPtr)); - fprintf(pOut, zFormat1, pc, - sqlite3OpcodeName(pOp->opcode), pOp->p1, pOp->p2, pOp->p3, zP4, pOp->p5, #ifdef SQLITE_DEBUG - pOp->zComment ? pOp->zComment : "" + displayComment(pOp, zP4, zCom, sizeof(zCom)); #else - "" + zCom[0] = 0 #endif + fprintf(pOut, zFormat1, pc, + sqlite3OpcodeName(pOp->opcode), pOp->p1, pOp->p2, pOp->p3, zP4, pOp->p5, + zCom ); fflush(pOut); } @@ -1202,7 +1258,7 @@ int sqlite3VdbeList( rc = SQLITE_ERROR; sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3ErrStr(p->rc)); }else{ - char *z; + char *zP4; Op *pOp; if( inOp ){ /* The output line number is small enough that we are still in the @@ -1225,7 +1281,7 @@ int sqlite3VdbeList( pMem++; pMem->flags = MEM_Static|MEM_Str|MEM_Term; - pMem->z = (char*)sqlite3OpcodeName(pOp->opcode); /* Opcode */ + pMem->z = (char*)sqlite3OpcodeName(pOp->opcode); /* Opcode */ assert( pMem->z!=0 ); pMem->n = sqlite3Strlen30(pMem->z); pMem->type = SQLITE_TEXT; @@ -1272,9 +1328,9 @@ int sqlite3VdbeList( return SQLITE_ERROR; } pMem->flags = MEM_Dyn|MEM_Str|MEM_Term; - z = displayP4(pOp, pMem->z, 32); - if( z!=pMem->z ){ - sqlite3VdbeMemSetStr(pMem, z, -1, SQLITE_UTF8, 0); + zP4 = displayP4(pOp, pMem->z, 32); + if( zP4!=pMem->z ){ + sqlite3VdbeMemSetStr(pMem, zP4, -1, SQLITE_UTF8, 0); }else{ assert( pMem->z!=0 ); pMem->n = sqlite3Strlen30(pMem->z); @@ -1296,18 +1352,18 @@ int sqlite3VdbeList( pMem++; #ifdef SQLITE_DEBUG - if( pOp->zComment ){ - pMem->flags = MEM_Str|MEM_Term; - pMem->z = pOp->zComment; - pMem->n = sqlite3Strlen30(pMem->z); - pMem->enc = SQLITE_UTF8; - pMem->type = SQLITE_TEXT; - }else -#endif - { - pMem->flags = MEM_Null; /* Comment */ - pMem->type = SQLITE_NULL; + if( sqlite3VdbeMemGrow(pMem, 500, 0) ){ + assert( p->db->mallocFailed ); + return SQLITE_ERROR; } + pMem->flags = MEM_Dyn|MEM_Str|MEM_Term; + pMem->n = displayComment(pOp, zP4, pMem->z, 500); + pMem->type = SQLITE_TEXT; + pMem->enc = SQLITE_UTF8; +#else + pMem->flags = MEM_Null; /* Comment */ + pMem->type = SQLITE_NULL; +#endif } p->nResColumn = 8 - 4*(p->explain-1);