/ Check-in [5f310c6a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Automatically generated comments on many VDBE opcodes when in SQLITE_DEBUG mode. Comments derive from the "Synopsis:" field added to each opcode definition in vdbe.c.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:5f310c6a22b8bb5f860296074aee130c14101681
User & Date: drh 2013-10-29 20:40:47
Original Comment: 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.
Context
2013-10-30
00:25
Enhanced display of register ranges in the auxiliary comments added to EXPLAIN. check-in: d6b0c392 user: drh tags: trunk
2013-10-29
20:47
Import the automatic comment generating changes from trunk. check-in: 8bb51da1 user: drh tags: omit-rowid
20:40
Automatically generated comments on many VDBE opcodes when in SQLITE_DEBUG mode. Comments derive from the "Synopsis:" field added to each opcode definition in vdbe.c. check-in: 5f310c6a user: drh tags: trunk
2013-10-28
22:33
Formatting improvements to the WHERE-clause constraint display in the wheretrace debugging logic. check-in: 3a9e3ed9 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to mkopcodec.awk.

     8      8   # opcodes used by the VDBE.  These strings are used when disassembling a
     9      9   # VDBE program during tracing or as a result of the EXPLAIN keyword.
    10     10   #
    11     11   BEGIN {
    12     12     print "/* Automatically generated.  Do not edit */"
    13     13     print "/* See the mkopcodec.awk script for details. */"
    14     14     printf "#if !defined(SQLITE_OMIT_EXPLAIN)"
    15         -  printf    " || !defined(NDEBUG)"
    16     15     printf    " || defined(VDBE_PROFILE)"
    17     16     print     " || defined(SQLITE_DEBUG)"
           17  +  print "#if defined(SQLITE_DEBUG)"
           18  +  print "# define OpHelp(X) \"\\0\" X"
           19  +  print "#else"
           20  +  print "# define OpHelp(X)"
           21  +  print "#endif"
    18     22     print "const char *sqlite3OpcodeName(int i){"
    19     23     print " static const char *const azName[] = { \"?\","
    20     24     mx = 0
    21     25   }
    22         -/define OP_/ {
           26  +/^.define OP_/ {
    23     27     sub("OP_","",$2)
    24     28     i = $3+0
    25     29     label[i] = $2
    26     30     if( mx<i ) mx = i
           31  +  for(j=5; j<NF; j++) if( $j=="synopsis:" ) break
           32  +  if( j<NF ){
           33  +    j++
           34  +    x = $j
           35  +    for(j=j+1; j<NF; j++) x = x " " $j
           36  +    synopsis[i] = x
           37  +  }else{
           38  +    synopsis[i] = ""
           39  +  }
    27     40   }
    28     41   END {
    29     42     for(i=1; i<=mx; i++){
    30         -    printf "     /* %3d */ \"%s\",\n", i, label[i]
           43  +    printf "     /* %3d */ %-18s OpHelp(\"%s\"),\n", i, \
           44  +        "\"" label[i] "\"", synopsis[i]
    31     45     }
    32     46     print "  };"
    33     47     print "  return azName[i];"
    34     48     print "}"
    35     49     print "#endif"
    36     50   }

Changes to mkopcodeh.awk.

    33     33   #
    34     34   
    35     35   
    36     36   # Remember the TK_ values from the parse.h file
    37     37   /^#define TK_/ {
    38     38     tk[$2] = 0+$3    # tk[x] holds the numeric value for TK symbol X
    39     39   }
           40  +
           41  +# Find "/* Opcode: " lines in the vdbe.c file.  Each one introduces
           42  +# a new opcode.  Remember which parameters are used.
           43  +/^.. Opcode: / {
           44  +  currentOp = "OP_" $3
           45  +  m = 0
           46  +  for(i=4; i<=NF; i++){
           47  +    x = $i
           48  +    if( x=="P1" ) m += 1
           49  +    if( x=="P2" ) m += 2
           50  +    if( x=="P3" ) m += 4
           51  +    if( x=="P4" ) m += 8
           52  +    if( x=="P5" ) m += 16
           53  +  }
           54  +  paramused[currentOp] = m
           55  +}
           56  +
           57  +# Find "** Synopsis: " lines that follow Opcode:
           58  +/^.. Synopsis: / {
           59  +  if( currentOp ){
           60  +    x = $3
           61  +    for(i=4; i<=NF; i++){
           62  +      x = x " " $i
           63  +    }
           64  +    synopsis[currentOp] = x
           65  +  }
           66  +}
    40     67   
    41     68   # Scan for "case OP_aaaa:" lines in the vdbe.c file
    42     69   /^case OP_/ {
    43     70     name = $2
    44     71     sub(/:/,"",name)
    45     72     sub("\r","",name)
    46     73     op[name] = -1       # op[x] holds the numeric value for OP symbol x
................................................................................
   132    159       }
   133    160     }
   134    161     max = cnt
   135    162     for(i=1; i<=max; i++){
   136    163       if( !used[i] ){
   137    164         def[i] = "OP_NotUsed_" i 
   138    165       }
   139         -    printf "#define %-25s %15d", def[i], i
          166  +    printf "#define %-16s %3d", def[i], i
          167  +    com = ""
   140    168       if( sameas[i] ){
   141         -      printf "   /* same as %-12s*/", sameas[i]
   142         -    } 
          169  +      com = "same as " sameas[i]
          170  +    }
          171  +    x = synopsis[def[i]]
          172  +    if( x ){
          173  +      if( com=="" ){
          174  +        com = "synopsis: " x
          175  +      } else {
          176  +        com = com ", synopsis: " x
          177  +      }
          178  +    }
          179  +    if( com!="" ){
          180  +      printf " /* %-42s */", com
          181  +    }
   143    182       printf "\n"
   144    183     }
   145    184   
   146    185     # Generate the bitvectors:
   147    186     #
   148    187     #  bit 0:     jump
   149    188     #  bit 1:     pushes a result onto stack
................................................................................
   176    215     print "#define OPFLG_INITIALIZER {\\"
   177    216     for(i=0; i<=max; i++){
   178    217       if( i%8==0 ) printf("/* %3d */",i)
   179    218       printf " 0x%02x,", bv[i]
   180    219       if( i%8==7 ) printf("\\\n");
   181    220     }
   182    221     print "}"
          222  +  if( 0 ){
          223  +    print "\n/* Bitmask to indicate which fields (P1..P5) of each opcode are"
          224  +    print "** actually used.\n*/"
          225  +    print "#define OP_PARAM_USED_INITIALIZER {\\"
          226  +    for(i=0; i<=max; i++){
          227  +      if( i%8==0 ) printf("/* %3d */",i)
          228  +      printf " 0x%02x,", paramused[def[i]]
          229  +      if( i%8==7 ) printf("\\\n");
          230  +    }
          231  +    print "}"
          232  +  }
   183    233   }

Changes to src/vdbe.c.

   801    801     pIn1->u.i = pc;
   802    802     REGISTER_TRACE(pOp->p1, pIn1);
   803    803     pc = pcDest;
   804    804     break;
   805    805   }
   806    806   
   807    807   /* Opcode:  HaltIfNull  P1 P2 P3 P4 *
          808  +** Synopsis:  if r[P3] null then halt
   808    809   **
   809    810   ** Check the value in register P3.  If it is NULL then Halt using
   810    811   ** parameter P1, P2, and P4 as if this were a Halt instruction.  If the
   811    812   ** value in register P3 is not NULL, then this routine is a no-op.
   812    813   */
   813    814   case OP_HaltIfNull: {      /* in3 */
   814    815     pIn3 = &aMem[pOp->p3];
................................................................................
   878    879       assert( rc==SQLITE_OK || db->nDeferredCons>0 || db->nDeferredImmCons>0 );
   879    880       rc = p->rc ? SQLITE_ERROR : SQLITE_DONE;
   880    881     }
   881    882     goto vdbe_return;
   882    883   }
   883    884   
   884    885   /* Opcode: Integer P1 P2 * * *
          886  +** Synopsis: r[P2]=P1
   885    887   **
   886    888   ** The 32-bit integer value P1 is written into register P2.
   887    889   */
   888    890   case OP_Integer: {         /* out2-prerelease */
   889    891     pOut->u.i = pOp->p1;
   890    892     break;
   891    893   }
   892    894   
   893    895   /* Opcode: Int64 * P2 * P4 *
          896  +** Synopsis: r[P2]=P4
   894    897   **
   895    898   ** P4 is a pointer to a 64-bit integer value.
   896    899   ** Write that value into register P2.
   897    900   */
   898    901   case OP_Int64: {           /* out2-prerelease */
   899    902     assert( pOp->p4.pI64!=0 );
   900    903     pOut->u.i = *pOp->p4.pI64;
   901    904     break;
   902    905   }
   903    906   
   904    907   #ifndef SQLITE_OMIT_FLOATING_POINT
   905    908   /* Opcode: Real * P2 * P4 *
          909  +** Synopsis: r[P2]=P4
   906    910   **
   907    911   ** P4 is a pointer to a 64-bit floating point value.
   908    912   ** Write that value into register P2.
   909    913   */
   910    914   case OP_Real: {            /* same as TK_FLOAT, out2-prerelease */
   911    915     pOut->flags = MEM_Real;
   912    916     assert( !sqlite3IsNaN(*pOp->p4.pReal) );
   913    917     pOut->r = *pOp->p4.pReal;
   914    918     break;
   915    919   }
   916    920   #endif
   917    921   
   918    922   /* Opcode: String8 * P2 * P4 *
          923  +** Synopsis: r[P2]='P4'
   919    924   **
   920    925   ** P4 points to a nul terminated UTF-8 string. This opcode is transformed 
   921    926   ** into an OP_String before it is executed for the first time.
   922    927   */
   923    928   case OP_String8: {         /* same as TK_STRING, out2-prerelease */
   924    929     assert( pOp->p4.z!=0 );
   925    930     pOp->opcode = OP_String;
................................................................................
   946    951     if( pOp->p1>db->aLimit[SQLITE_LIMIT_LENGTH] ){
   947    952       goto too_big;
   948    953     }
   949    954     /* Fall through to the next case, OP_String */
   950    955   }
   951    956     
   952    957   /* Opcode: String P1 P2 * P4 *
          958  +** Synopsis: r[P2]='P4' (len=P1)
   953    959   **
   954    960   ** The string value P4 of length P1 (bytes) is stored in register P2.
   955    961   */
   956    962   case OP_String: {          /* out2-prerelease */
   957    963     assert( pOp->p4.z!=0 );
   958    964     pOut->flags = MEM_Str|MEM_Static|MEM_Term;
   959    965     pOut->z = pOp->p4.z;
................................................................................
   960    966     pOut->n = pOp->p1;
   961    967     pOut->enc = encoding;
   962    968     UPDATE_MAX_BLOBSIZE(pOut);
   963    969     break;
   964    970   }
   965    971   
   966    972   /* Opcode: Null P1 P2 P3 * *
          973  +** Synopsis:  r[P2..P3]=NULL
   967    974   **
   968    975   ** Write a NULL into registers P2.  If P3 greater than P2, then also write
   969    976   ** NULL into register P3 and every register in between P2 and P3.  If P3
   970    977   ** is less than P2 (typically P3 is zero) then only register P2 is
   971    978   ** set to NULL.
   972    979   **
   973    980   ** If the P1 value is non-zero, then also set the MEM_Cleared flag so that
................................................................................
   988    995       cnt--;
   989    996     }
   990    997     break;
   991    998   }
   992    999   
   993   1000   
   994   1001   /* Opcode: Blob P1 P2 * P4
         1002  +** Synopsis: r[P2]=P4 (len=P1)
   995   1003   **
   996   1004   ** P4 points to a blob of data P1 bytes long.  Store this
   997   1005   ** blob in register P2.
   998   1006   */
   999   1007   case OP_Blob: {                /* out2-prerelease */
  1000   1008     assert( pOp->p1 <= SQLITE_MAX_LENGTH );
  1001   1009     sqlite3VdbeMemSetStr(pOut, pOp->p4.z, pOp->p1, 0, 0);
  1002   1010     pOut->enc = encoding;
  1003   1011     UPDATE_MAX_BLOBSIZE(pOut);
  1004   1012     break;
  1005   1013   }
  1006   1014   
  1007   1015   /* Opcode: Variable P1 P2 * P4 *
         1016  +** Synopsis: r[P2]=parameter(P1,P4)
  1008   1017   **
  1009   1018   ** Transfer the values of bound parameter P1 into register P2
  1010   1019   **
  1011   1020   ** If the parameter is named, then its name appears in P4 and P3==1.
  1012   1021   ** The P4 value is used by sqlite3_bind_parameter_name().
  1013   1022   */
  1014   1023   case OP_Variable: {            /* out2-prerelease */
................................................................................
  1022   1031     }
  1023   1032     sqlite3VdbeMemShallowCopy(pOut, pVar, MEM_Static);
  1024   1033     UPDATE_MAX_BLOBSIZE(pOut);
  1025   1034     break;
  1026   1035   }
  1027   1036   
  1028   1037   /* Opcode: Move P1 P2 P3 * *
         1038  +** Synopsis:  r[P2]=r[P1] N=P3
  1029   1039   **
  1030   1040   ** Move the values in register P1..P1+P3 over into
  1031   1041   ** registers P2..P2+P3.  Registers P1..P1+P3 are
  1032   1042   ** left holding a NULL.  It is an error for register ranges
  1033   1043   ** P1..P1+P3 and P2..P2+P3 to overlap.
  1034   1044   */
  1035   1045   case OP_Move: {
................................................................................
  1064   1074       pIn1++;
  1065   1075       pOut++;
  1066   1076     }
  1067   1077     break;
  1068   1078   }
  1069   1079   
  1070   1080   /* Opcode: Copy P1 P2 P3 * *
         1081  +** Synopsis: r[P2]=r[P1] N=P3
  1071   1082   **
  1072   1083   ** Make a copy of registers P1..P1+P3 into registers P2..P2+P3.
  1073   1084   **
  1074   1085   ** This instruction makes a deep copy of the value.  A duplicate
  1075   1086   ** is made of any string or blob constant.  See also OP_SCopy.
  1076   1087   */
  1077   1088   case OP_Copy: {
................................................................................
  1092   1103       pOut++;
  1093   1104       pIn1++;
  1094   1105     }
  1095   1106     break;
  1096   1107   }
  1097   1108   
  1098   1109   /* Opcode: SCopy P1 P2 * * *
         1110  +** Synopsis: r[P2]=r[P1]
  1099   1111   **
  1100   1112   ** Make a shallow copy of register P1 into register P2.
  1101   1113   **
  1102   1114   ** This instruction makes a shallow copy of the value.  If the value
  1103   1115   ** is a string or blob, then the copy is only a pointer to the
  1104   1116   ** original and hence if the original changes so will the copy.
  1105   1117   ** Worse, if the original is deallocated, the copy becomes invalid.
................................................................................
  1116   1128     if( pOut->pScopyFrom==0 ) pOut->pScopyFrom = pIn1;
  1117   1129   #endif
  1118   1130     REGISTER_TRACE(pOp->p2, pOut);
  1119   1131     break;
  1120   1132   }
  1121   1133   
  1122   1134   /* Opcode: ResultRow P1 P2 * * *
         1135  +** Synopsis:  output=r[P1].. columns=P1
  1123   1136   **
  1124   1137   ** The registers P1 through P1+P2-1 contain a single row of
  1125   1138   ** results. This opcode causes the sqlite3_step() call to terminate
  1126   1139   ** with an SQLITE_ROW return code and it sets up the sqlite3_stmt
  1127   1140   ** structure to provide access to the top P1 values as the result
  1128   1141   ** row.
  1129   1142   */
................................................................................
  1187   1200     */
  1188   1201     p->pc = pc + 1;
  1189   1202     rc = SQLITE_ROW;
  1190   1203     goto vdbe_return;
  1191   1204   }
  1192   1205   
  1193   1206   /* Opcode: Concat P1 P2 P3 * *
         1207  +** Synopsis: r[P3]=r[P2]+r[P3]
  1194   1208   **
  1195   1209   ** Add the text in register P1 onto the end of the text in
  1196   1210   ** register P2 and store the result in register P3.
  1197   1211   ** If either the P1 or P2 text are NULL then store NULL in P3.
  1198   1212   **
  1199   1213   **   P3 = P2 || P1
  1200   1214   **
................................................................................
  1224   1238     if( sqlite3VdbeMemGrow(pOut, (int)nByte+2, pOut==pIn2) ){
  1225   1239       goto no_mem;
  1226   1240     }
  1227   1241     if( pOut!=pIn2 ){
  1228   1242       memcpy(pOut->z, pIn2->z, pIn2->n);
  1229   1243     }
  1230   1244     memcpy(&pOut->z[pIn2->n], pIn1->z, pIn1->n);
  1231         -  pOut->z[nByte] = 0;
         1245  +  pOut->z[nByte]=0;
  1232   1246     pOut->z[nByte+1] = 0;
  1233   1247     pOut->flags |= MEM_Term;
  1234   1248     pOut->n = (int)nByte;
  1235   1249     pOut->enc = encoding;
  1236   1250     UPDATE_MAX_BLOBSIZE(pOut);
  1237   1251     break;
  1238   1252   }
  1239   1253   
  1240   1254   /* Opcode: Add P1 P2 P3 * *
         1255  +** Synopsis:  r[P3]=r[P1]+r[P2]
  1241   1256   **
  1242   1257   ** Add the value in register P1 to the value in register P2
  1243   1258   ** and store the result in register P3.
  1244   1259   ** If either input is NULL, the result is NULL.
  1245   1260   */
  1246   1261   /* Opcode: Multiply P1 P2 P3 * *
         1262  +** Synopsis:  r[P3]=r[P1]*r[P2]
  1247   1263   **
  1248   1264   **
  1249   1265   ** Multiply the value in register P1 by the value in register P2
  1250   1266   ** and store the result in register P3.
  1251   1267   ** If either input is NULL, the result is NULL.
  1252   1268   */
  1253   1269   /* Opcode: Subtract P1 P2 P3 * *
         1270  +** Synopsis:  r[P3]=r[P2]-r[P1]
  1254   1271   **
  1255   1272   ** Subtract the value in register P1 from the value in register P2
  1256   1273   ** and store the result in register P3.
  1257   1274   ** If either input is NULL, the result is NULL.
  1258   1275   */
  1259   1276   /* Opcode: Divide P1 P2 P3 * *
         1277  +** Synopsis:  r[P3]=r[P1]/r[P2]
  1260   1278   **
  1261   1279   ** Divide the value in register P1 by the value in register P2
  1262   1280   ** and store the result in register P3 (P3=P2/P1). If the value in 
  1263   1281   ** register P1 is zero, then the result is NULL. If either input is 
  1264   1282   ** NULL, the result is NULL.
  1265   1283   */
  1266   1284   /* Opcode: Remainder P1 P2 P3 * *
         1285  +** Synopsis:  r[P3]=r[P1]%r[P2]
  1267   1286   **
  1268   1287   ** Compute the remainder after integer division of the value in
  1269   1288   ** register P1 by the value in register P2 and store the result in P3. 
  1270   1289   ** If the value in register P2 is zero the result is NULL.
  1271   1290   ** If either operand is NULL, the result is NULL.
  1272   1291   */
  1273   1292   case OP_Add:                   /* same as TK_PLUS, in1, in2, out3 */
................................................................................
  1377   1396     if( pOp->p1 ){
  1378   1397       sqlite3VdbeMemSetInt64(&aMem[pOp->p1], 0);
  1379   1398     }
  1380   1399     break;
  1381   1400   }
  1382   1401   
  1383   1402   /* Opcode: Function P1 P2 P3 P4 P5
         1403  +** Synopsis: r[P3]=func(r[P2]..) N=P5
  1384   1404   **
  1385   1405   ** Invoke a user function (P4 is a pointer to a Function structure that
  1386   1406   ** defines the function) with P5 arguments taken from register P2 and
  1387   1407   ** successors.  The result of the function is stored in register P3.
  1388   1408   ** Register P3 must not be one of the function inputs.
  1389   1409   **
  1390   1410   ** P1 is a 32-bit bitmask indicating whether or not each argument to the 
................................................................................
  1484   1504   
  1485   1505     REGISTER_TRACE(pOp->p3, pOut);
  1486   1506     UPDATE_MAX_BLOBSIZE(pOut);
  1487   1507     break;
  1488   1508   }
  1489   1509   
  1490   1510   /* Opcode: BitAnd P1 P2 P3 * *
         1511  +** Synopsis:  r[P3]=r[P1]&r[P2]
  1491   1512   **
  1492   1513   ** Take the bit-wise AND of the values in register P1 and P2 and
  1493   1514   ** store the result in register P3.
  1494   1515   ** If either input is NULL, the result is NULL.
  1495   1516   */
  1496   1517   /* Opcode: BitOr P1 P2 P3 * *
         1518  +** Synopsis:  r[P3]=r[P1]|r[P2]
  1497   1519   **
  1498   1520   ** Take the bit-wise OR of the values in register P1 and P2 and
  1499   1521   ** store the result in register P3.
  1500   1522   ** If either input is NULL, the result is NULL.
  1501   1523   */
  1502   1524   /* Opcode: ShiftLeft P1 P2 P3 * *
         1525  +** Synopsis:  r[P3]=r[P2]<<r[P1]
  1503   1526   **
  1504   1527   ** Shift the integer value in register P2 to the left by the
  1505   1528   ** number of bits specified by the integer in register P1.
  1506   1529   ** Store the result in register P3.
  1507   1530   ** If either input is NULL, the result is NULL.
  1508   1531   */
  1509   1532   /* Opcode: ShiftRight P1 P2 P3 * *
         1533  +** Synopsis:  r[P3]=r[P2]>>r[P1]
  1510   1534   **
  1511   1535   ** Shift the integer value in register P2 to the right by the
  1512   1536   ** number of bits specified by the integer in register P1.
  1513   1537   ** Store the result in register P3.
  1514   1538   ** If either input is NULL, the result is NULL.
  1515   1539   */
  1516   1540   case OP_BitAnd:                 /* same as TK_BITAND, in1, in2, out3 */
................................................................................
  1562   1586     }
  1563   1587     pOut->u.i = iA;
  1564   1588     MemSetTypeFlag(pOut, MEM_Int);
  1565   1589     break;
  1566   1590   }
  1567   1591   
  1568   1592   /* Opcode: AddImm  P1 P2 * * *
         1593  +** Synopsis:  r[P1]=r[P1]+P2
  1569   1594   ** 
  1570   1595   ** Add the constant P2 to the value in register P1.
  1571   1596   ** The result is always an integer.
  1572   1597   **
  1573   1598   ** To force any register to be an integer, just add 0.
  1574   1599   */
  1575   1600   case OP_AddImm: {            /* in1 */
................................................................................
  1720   1745       sqlite3VdbeMemRealify(pIn1);
  1721   1746     }
  1722   1747     break;
  1723   1748   }
  1724   1749   #endif /* !defined(SQLITE_OMIT_CAST) && !defined(SQLITE_OMIT_FLOATING_POINT) */
  1725   1750   
  1726   1751   /* Opcode: Lt P1 P2 P3 P4 P5
         1752  +** Synopsis: r[P1] < r[P3]
  1727   1753   **
  1728   1754   ** Compare the values in register P1 and P3.  If reg(P3)<reg(P1) then
  1729   1755   ** jump to address P2.  
  1730   1756   **
  1731   1757   ** If the SQLITE_JUMPIFNULL bit of P5 is set and either reg(P1) or
  1732   1758   ** reg(P3) is NULL then take the jump.  If the SQLITE_JUMPIFNULL 
  1733   1759   ** bit is clear then fall through if either operand is NULL.
................................................................................
  1754   1780   ** store a boolean result (either 0, or 1, or NULL) in register P2.
  1755   1781   **
  1756   1782   ** If the SQLITE_NULLEQ bit is set in P5, then NULL values are considered
  1757   1783   ** equal to one another, provided that they do not have their MEM_Cleared
  1758   1784   ** bit set.
  1759   1785   */
  1760   1786   /* Opcode: Ne P1 P2 P3 P4 P5
         1787  +** Synopsis: r[P1] != r[P3]
  1761   1788   **
  1762   1789   ** This works just like the Lt opcode except that the jump is taken if
  1763   1790   ** the operands in registers P1 and P3 are not equal.  See the Lt opcode for
  1764   1791   ** additional information.
  1765   1792   **
  1766   1793   ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either
  1767   1794   ** true or false and is never NULL.  If both operands are NULL then the result
  1768   1795   ** of comparison is false.  If either operand is NULL then the result is true.
  1769   1796   ** If neither operand is NULL the result is the same as it would be if
  1770   1797   ** the SQLITE_NULLEQ flag were omitted from P5.
  1771   1798   */
  1772   1799   /* Opcode: Eq P1 P2 P3 P4 P5
         1800  +** Synopsis: r[P1] == r[P3]
  1773   1801   **
  1774   1802   ** This works just like the Lt opcode except that the jump is taken if
  1775   1803   ** the operands in registers P1 and P3 are equal.
  1776   1804   ** See the Lt opcode for additional information.
  1777   1805   **
  1778   1806   ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either
  1779   1807   ** true or false and is never NULL.  If both operands are NULL then the result
  1780   1808   ** of comparison is true.  If either operand is NULL then the result is false.
  1781   1809   ** If neither operand is NULL the result is the same as it would be if
  1782   1810   ** the SQLITE_NULLEQ flag were omitted from P5.
  1783   1811   */
  1784   1812   /* Opcode: Le P1 P2 P3 P4 P5
         1813  +** Synopsis: r[P1] <= r[P3]
  1785   1814   **
  1786   1815   ** This works just like the Lt opcode except that the jump is taken if
  1787   1816   ** the content of register P3 is less than or equal to the content of
  1788   1817   ** register P1.  See the Lt opcode for additional information.
  1789   1818   */
  1790   1819   /* Opcode: Gt P1 P2 P3 P4 P5
         1820  +** Synopsis: r[P1] > r[P3]
  1791   1821   **
  1792   1822   ** This works just like the Lt opcode except that the jump is taken if
  1793   1823   ** the content of register P3 is greater than the content of
  1794   1824   ** register P1.  See the Lt opcode for additional information.
  1795   1825   */
  1796   1826   /* Opcode: Ge P1 P2 P3 P4 P5
         1827  +** Synopsis: r[P1] >= r[P3]
  1797   1828   **
  1798   1829   ** This works just like the Lt opcode except that the jump is taken if
  1799   1830   ** the content of register P3 is greater than or equal to the content of
  1800   1831   ** register P1.  See the Lt opcode for additional information.
  1801   1832   */
  1802   1833   case OP_Eq:               /* same as TK_EQ, jump, in1, in3 */
  1803   1834   case OP_Ne:               /* same as TK_NE, jump, in1, in3 */
................................................................................
  1980   2011     }else{
  1981   2012       pc = pOp->p3 - 1;
  1982   2013     }
  1983   2014     break;
  1984   2015   }
  1985   2016   
  1986   2017   /* Opcode: And P1 P2 P3 * *
         2018  +** Synopsis: r[P3]=(r[P1] && r[P2])
  1987   2019   **
  1988   2020   ** Take the logical AND of the values in registers P1 and P2 and
  1989   2021   ** write the result into register P3.
  1990   2022   **
  1991   2023   ** If either P1 or P2 is 0 (false) then the result is 0 even if
  1992   2024   ** the other input is NULL.  A NULL and true or two NULLs give
  1993   2025   ** a NULL output.
  1994   2026   */
  1995   2027   /* Opcode: Or P1 P2 P3 * *
         2028  +** Synopsis: r[P3]=(r[P1] || r[P2])
  1996   2029   **
  1997   2030   ** Take the logical OR of the values in register P1 and P2 and
  1998   2031   ** store the answer in register P3.
  1999   2032   **
  2000   2033   ** If either P1 or P2 is nonzero (true) then the result is 1 (true)
  2001   2034   ** even if the other input is NULL.  A NULL and false or two NULLs
  2002   2035   ** give a NULL output.
................................................................................
  2032   2065       pOut->u.i = v1;
  2033   2066       MemSetTypeFlag(pOut, MEM_Int);
  2034   2067     }
  2035   2068     break;
  2036   2069   }
  2037   2070   
  2038   2071   /* Opcode: Not P1 P2 * * *
         2072  +** Synopsis: r[P2]= !r[P1]
  2039   2073   **
  2040   2074   ** Interpret the value in register P1 as a boolean value.  Store the
  2041   2075   ** boolean complement in register P2.  If the value in register P1 is 
  2042   2076   ** NULL, then a NULL is stored in P2.
  2043   2077   */
  2044   2078   case OP_Not: {                /* same as TK_NOT, in1, out2 */
  2045   2079     pIn1 = &aMem[pOp->p1];
................................................................................
  2049   2083     }else{
  2050   2084       sqlite3VdbeMemSetInt64(pOut, !sqlite3VdbeIntValue(pIn1));
  2051   2085     }
  2052   2086     break;
  2053   2087   }
  2054   2088   
  2055   2089   /* Opcode: BitNot P1 P2 * * *
         2090  +** Synopsis: r[P1]= ~r[P1]
  2056   2091   **
  2057   2092   ** Interpret the content of register P1 as an integer.  Store the
  2058   2093   ** ones-complement of the P1 value into register P2.  If P1 holds
  2059   2094   ** a NULL then store a NULL in P2.
  2060   2095   */
  2061   2096   case OP_BitNot: {             /* same as TK_BITNOT, in1, out2 */
  2062   2097     pIn1 = &aMem[pOp->p1];
................................................................................
  2137   2172     if( (pIn1->flags & MEM_Null)==0 ){
  2138   2173       pc = pOp->p2 - 1;
  2139   2174     }
  2140   2175     break;
  2141   2176   }
  2142   2177   
  2143   2178   /* Opcode: Column P1 P2 P3 P4 P5
         2179  +** Synopsis:  r[P3]=PX
  2144   2180   **
  2145   2181   ** Interpret the data that cursor P1 points to as a structure built using
  2146   2182   ** the MakeRecord instruction.  (See the MakeRecord opcode for additional
  2147   2183   ** information about the format of the data.)  Extract the P2-th column
  2148   2184   ** from this record.  If there are less that (P2+1) 
  2149   2185   ** values in the record, extract a NULL.
  2150   2186   **
................................................................................
  2473   2509   op_column_out:
  2474   2510     UPDATE_MAX_BLOBSIZE(pDest);
  2475   2511     REGISTER_TRACE(pOp->p3, pDest);
  2476   2512     break;
  2477   2513   }
  2478   2514   
  2479   2515   /* Opcode: Affinity P1 P2 * P4 *
         2516  +** Synopsis: affinity(r[P1]) N=P2
  2480   2517   **
  2481   2518   ** Apply affinities to a range of P2 registers starting with P1.
  2482   2519   **
  2483   2520   ** P4 is a string that is P2 characters long. The nth character of the
  2484   2521   ** string indicates the column affinity that should be used for the nth
  2485   2522   ** memory cell in the range.
  2486   2523   */
................................................................................
  2499   2536       applyAffinity(pIn1, cAff, encoding);
  2500   2537       pIn1++;
  2501   2538     }
  2502   2539     break;
  2503   2540   }
  2504   2541   
  2505   2542   /* Opcode: MakeRecord P1 P2 P3 P4 *
         2543  +** Synopsis: r[P3]=rec(r[P1]..) N=P2
  2506   2544   **
  2507   2545   ** Convert P2 registers beginning with P1 into the [record format]
  2508   2546   ** use as a data record in a database table or as a key
  2509   2547   ** in an index.  The OP_Column opcode can decode the record later.
  2510   2548   **
  2511   2549   ** P4 may be a string that is P2 characters long.  The nth character of the
  2512   2550   ** string indicates the column affinity that should be used for the nth
................................................................................
  2631   2669     pOut->enc = SQLITE_UTF8;  /* In case the blob is ever converted to text */
  2632   2670     REGISTER_TRACE(pOp->p3, pOut);
  2633   2671     UPDATE_MAX_BLOBSIZE(pOut);
  2634   2672     break;
  2635   2673   }
  2636   2674   
  2637   2675   /* Opcode: Count P1 P2 * * *
         2676  +** Synopsis: r[P2]=count()
  2638   2677   **
  2639   2678   ** Store the number of entries (an integer value) in the table or index 
  2640   2679   ** opened by cursor P1 in register P2
  2641   2680   */
  2642   2681   #ifndef SQLITE_OMIT_BTREECOUNT
  2643   2682   case OP_Count: {         /* out2-prerelease */
  2644   2683     i64 nEntry;
................................................................................
  3107   3146       p->expired = 1;
  3108   3147       rc = SQLITE_SCHEMA;
  3109   3148     }
  3110   3149     break;
  3111   3150   }
  3112   3151   
  3113   3152   /* Opcode: OpenRead P1 P2 P3 P4 P5
         3153  +** Synopsis: root=P2 iDb=P3
  3114   3154   **
  3115   3155   ** Open a read-only cursor for the database table whose root page is
  3116   3156   ** P2 in a database file.  The database file is determined by P3. 
  3117   3157   ** P3==0 means the main database, P3==1 means the database used for 
  3118   3158   ** temporary tables, and P3>1 means used the corresponding attached
  3119   3159   ** database.  Give the new cursor an identifier of P1.  The P1
  3120   3160   ** values need not be contiguous but all P1 values should be small integers.
................................................................................
  3137   3177   ** structure, then said structure defines the content and collating 
  3138   3178   ** sequence of the index being opened. Otherwise, if P4 is an integer 
  3139   3179   ** value, it is set to the number of columns in the table.
  3140   3180   **
  3141   3181   ** See also OpenWrite.
  3142   3182   */
  3143   3183   /* Opcode: OpenWrite P1 P2 P3 P4 P5
         3184  +** Synopsis: root=P2 iDb=P3
  3144   3185   **
  3145   3186   ** Open a read/write cursor named P1 on the table or index whose root
  3146   3187   ** page is P2.  Or if P5!=0 use the content of register P2 to find the
  3147   3188   ** root page.
  3148   3189   **
  3149   3190   ** The P4 value may be either an integer (P4_INT32) or a pointer to
  3150   3191   ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo 
................................................................................
  3242   3283     ** since moved into the btree layer.  */  
  3243   3284     pCur->isTable = pOp->p4type!=P4_KEYINFO;
  3244   3285     pCur->isIndex = !pCur->isTable;
  3245   3286     break;
  3246   3287   }
  3247   3288   
  3248   3289   /* Opcode: OpenEphemeral P1 P2 * P4 P5
         3290  +** Synopsis: nColumn=P2
  3249   3291   **
  3250   3292   ** Open a new cursor P1 to a transient table.
  3251   3293   ** The cursor is always opened read/write even if 
  3252   3294   ** the main database is read-only.  The ephemeral
  3253   3295   ** table is deleted automatically when the cursor is closed.
  3254   3296   **
  3255   3297   ** P2 is the number of columns in the ephemeral table.
  3256   3298   ** The cursor points to a BTree table if P4==0 and to a BTree index
  3257   3299   ** if P4 is not 0.  If P4 is not NULL, it points to a KeyInfo structure
  3258   3300   ** that defines the format of keys in the index.
  3259   3301   **
  3260         -** This opcode was once called OpenTemp.  But that created
  3261         -** confusion because the term "temp table", might refer either
  3262         -** to a TEMP table at the SQL level, or to a table opened by
  3263         -** this opcode.  Then this opcode was call OpenVirtual.  But
  3264         -** that created confusion with the whole virtual-table idea.
  3265         -**
  3266   3302   ** The P5 parameter can be a mask of the BTREE_* flags defined
  3267   3303   ** in btree.h.  These flags control aspects of the operation of
  3268   3304   ** the btree.  The BTREE_OMIT_JOURNAL and BTREE_SINGLE flags are
  3269   3305   ** added automatically.
  3270   3306   */
  3271   3307   /* Opcode: OpenAutoindex P1 P2 * P4 *
         3308  +** Synopsis: nColumn=P2
  3272   3309   **
  3273   3310   ** This opcode works the same as OP_OpenEphemeral.  It has a
  3274   3311   ** different name to distinguish its use.  Tables created using
  3275   3312   ** by this opcode will be used for automatically created transient
  3276   3313   ** indices in joins.
  3277   3314   */
  3278   3315   case OP_OpenAutoindex: 
................................................................................
  3319   3356     }
  3320   3357     pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);
  3321   3358     pCx->isIndex = !pCx->isTable;
  3322   3359     break;
  3323   3360   }
  3324   3361   
  3325   3362   /* Opcode: SorterOpen P1 P2 * P4 *
         3363  +** Synopsis: nColumn=P2
  3326   3364   **
  3327   3365   ** This opcode works like OP_OpenEphemeral except that it opens
  3328   3366   ** a transient index that is specifically designed to sort large
  3329   3367   ** tables using an external merge-sort algorithm.
  3330   3368   */
  3331   3369   case OP_SorterOpen: {
  3332   3370     VdbeCursor *pCx;
................................................................................
  3337   3375     pCx->pKeyInfo->enc = ENC(p->db);
  3338   3376     pCx->isSorter = 1;
  3339   3377     rc = sqlite3VdbeSorterInit(db, pCx);
  3340   3378     break;
  3341   3379   }
  3342   3380   
  3343   3381   /* Opcode: OpenPseudo P1 P2 P3 * P5
         3382  +** Synopsis: content in r[P2].. N=P3
  3344   3383   **
  3345   3384   ** Open a new cursor that points to a fake table that contains a single
  3346   3385   ** row of data.  The content of that one row in the content of memory
  3347   3386   ** register P2 when P5==0.  In other words, cursor P1 becomes an alias for the 
  3348   3387   ** MEM_Blob content contained in register P2.  When P5==1, then the
  3349   3388   ** row is represented by P3 consecutive registers beginning with P2.
  3350   3389   **
................................................................................
  3379   3418     assert( pOp->p1>=0 && pOp->p1<p->nCursor );
  3380   3419     sqlite3VdbeFreeCursor(p, p->apCsr[pOp->p1]);
  3381   3420     p->apCsr[pOp->p1] = 0;
  3382   3421     break;
  3383   3422   }
  3384   3423   
  3385   3424   /* Opcode: SeekGe P1 P2 P3 P4 *
         3425  +** Synopsis: key=r[P3].. N=P4
  3386   3426   **
  3387   3427   ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), 
  3388   3428   ** use the value in register P3 as the key.  If cursor P1 refers 
  3389   3429   ** to an SQL index, then P3 is the first in an array of P4 registers 
  3390   3430   ** that are used as an unpacked index key. 
  3391   3431   **
  3392   3432   ** Reposition cursor P1 so that  it points to the smallest entry that 
  3393   3433   ** is greater than or equal to the key value. If there are no records 
  3394   3434   ** greater than or equal to the key and P2 is not zero, then jump to P2.
  3395   3435   **
  3396   3436   ** See also: Found, NotFound, Distinct, SeekLt, SeekGt, SeekLe
  3397   3437   */
  3398   3438   /* Opcode: SeekGt P1 P2 P3 P4 *
         3439  +** Synopsis: key=r[P3].. N=P4
  3399   3440   **
  3400   3441   ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), 
  3401   3442   ** use the value in register P3 as a key. If cursor P1 refers 
  3402   3443   ** to an SQL index, then P3 is the first in an array of P4 registers 
  3403   3444   ** that are used as an unpacked index key. 
  3404   3445   **
  3405   3446   ** Reposition cursor P1 so that  it points to the smallest entry that 
  3406   3447   ** is greater than the key value. If there are no records greater than 
  3407   3448   ** the key and P2 is not zero, then jump to P2.
  3408   3449   **
  3409   3450   ** See also: Found, NotFound, Distinct, SeekLt, SeekGe, SeekLe
  3410   3451   */
  3411   3452   /* Opcode: SeekLt P1 P2 P3 P4 * 
         3453  +** Synopsis: key=r[P3].. N=P4
  3412   3454   **
  3413   3455   ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), 
  3414   3456   ** use the value in register P3 as a key. If cursor P1 refers 
  3415   3457   ** to an SQL index, then P3 is the first in an array of P4 registers 
  3416   3458   ** that are used as an unpacked index key. 
  3417   3459   **
  3418   3460   ** Reposition cursor P1 so that  it points to the largest entry that 
  3419   3461   ** is less than the key value. If there are no records less than 
  3420   3462   ** the key and P2 is not zero, then jump to P2.
  3421   3463   **
  3422   3464   ** See also: Found, NotFound, Distinct, SeekGt, SeekGe, SeekLe
  3423   3465   */
  3424   3466   /* Opcode: SeekLe P1 P2 P3 P4 *
         3467  +** Synopsis: key=r[P3].. N=P4
  3425   3468   **
  3426   3469   ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), 
  3427   3470   ** use the value in register P3 as a key. If cursor P1 refers 
  3428   3471   ** to an SQL index, then P3 is the first in an array of P4 registers 
  3429   3472   ** that are used as an unpacked index key. 
  3430   3473   **
  3431   3474   ** Reposition cursor P1 so that it points to the largest entry that 
................................................................................
  3583   3626       */
  3584   3627       pc = pOp->p2 - 1;
  3585   3628     }
  3586   3629     break;
  3587   3630   }
  3588   3631   
  3589   3632   /* Opcode: Seek P1 P2 * * *
         3633  +** Synopsis:  intkey=r[P2]
  3590   3634   **
  3591   3635   ** P1 is an open table cursor and P2 is a rowid integer.  Arrange
  3592   3636   ** for P1 to move so that it points to the rowid given by P2.
  3593   3637   **
  3594   3638   ** This is actually a deferred seek.  Nothing actually happens until
  3595   3639   ** the cursor is used to read a record.  That way, if no reads
  3596   3640   ** occur, no unnecessary I/O happens.
................................................................................
  3610   3654       pC->deferredMoveto = 1;
  3611   3655     }
  3612   3656     break;
  3613   3657   }
  3614   3658     
  3615   3659   
  3616   3660   /* Opcode: Found P1 P2 P3 P4 *
         3661  +** Synopsis: key=r[P3].. N=P4
  3617   3662   **
  3618   3663   ** If P4==0 then register P3 holds a blob constructed by MakeRecord.  If
  3619   3664   ** P4>0 then register P3 is the first of P4 registers that form an unpacked
  3620   3665   ** record.
  3621   3666   **
  3622   3667   ** Cursor P1 is on an index btree.  If the record identified by P3 and P4
  3623   3668   ** is a prefix of any entry in P1 then a jump is made to P2 and
  3624   3669   ** P1 is left pointing at the matching entry.
  3625   3670   */
  3626   3671   /* Opcode: NotFound P1 P2 P3 P4 *
         3672  +** Synopsis: key=r[P3] N=P4
  3627   3673   **
  3628   3674   ** If P4==0 then register P3 holds a blob constructed by MakeRecord.  If
  3629   3675   ** P4>0 then register P3 is the first of P4 registers that form an unpacked
  3630   3676   ** record.
  3631   3677   ** 
  3632   3678   ** Cursor P1 is on an index btree.  If the record identified by P3 and P4
  3633   3679   ** is not the prefix of any entry in P1 then a jump is made to P2.  If P1 
................................................................................
  3782   3828         pIn3->u.i = r.rowid;
  3783   3829       }
  3784   3830     }
  3785   3831     break;
  3786   3832   }
  3787   3833   
  3788   3834   /* Opcode: NotExists P1 P2 P3 * *
         3835  +** Synopsis: intkey=r[P3]
  3789   3836   **
  3790   3837   ** Use the content of register P3 as an integer key.  If a record 
  3791   3838   ** with that key does not exist in table of P1, then jump to P2. 
  3792   3839   ** If the record does exist, then fall through.  The cursor is left 
  3793   3840   ** pointing to the record if it exists.
  3794   3841   **
  3795   3842   ** The difference between this operation and NotFound is that this
................................................................................
  3835   3882       assert( pC->rowidIsValid==0 );
  3836   3883       pC->seekResult = 0;
  3837   3884     }
  3838   3885     break;
  3839   3886   }
  3840   3887   
  3841   3888   /* Opcode: Sequence P1 P2 * * *
         3889  +** Synopsis: r[P2]=rowid
  3842   3890   **
  3843   3891   ** Find the next available sequence number for cursor P1.
  3844   3892   ** Write the sequence number into register P2.
  3845   3893   ** The sequence number on the cursor is incremented after this
  3846   3894   ** instruction.  
  3847   3895   */
  3848   3896   case OP_Sequence: {           /* out2-prerelease */
................................................................................
  3850   3898     assert( p->apCsr[pOp->p1]!=0 );
  3851   3899     pOut->u.i = p->apCsr[pOp->p1]->seqCount++;
  3852   3900     break;
  3853   3901   }
  3854   3902   
  3855   3903   
  3856   3904   /* Opcode: NewRowid P1 P2 P3 * *
         3905  +** Synopsis: r[P2]=rowid
  3857   3906   **
  3858   3907   ** Get a new integer record number (a.k.a "rowid") used as the key to a table.
  3859   3908   ** The record number is not previously used as a key in the database
  3860   3909   ** table that cursor P1 points to.  The new record number is written
  3861   3910   ** written to register P2.
  3862   3911   **
  3863   3912   ** If P3>0 then P3 is a register in the root frame of this VDBE that holds 
................................................................................
  3999   4048       pC->cacheStatus = CACHE_STALE;
  4000   4049     }
  4001   4050     pOut->u.i = v;
  4002   4051     break;
  4003   4052   }
  4004   4053   
  4005   4054   /* Opcode: Insert P1 P2 P3 P4 P5
         4055  +** Synopsis: intkey=r[P3] data=r[P2]
  4006   4056   **
  4007   4057   ** Write an entry into the table of cursor P1.  A new entry is
  4008   4058   ** created if it doesn't already exist or the data for an existing
  4009   4059   ** entry is overwritten.  The data is the value MEM_Blob stored in register
  4010   4060   ** number P2. The key is stored in register P3. The key must
  4011   4061   ** be a MEM_Int.
  4012   4062   **
................................................................................
  4038   4088   ** value of register P2 will then change.  Make sure this does not
  4039   4089   ** cause any problems.)
  4040   4090   **
  4041   4091   ** This instruction only works on tables.  The equivalent instruction
  4042   4092   ** for indices is OP_IdxInsert.
  4043   4093   */
  4044   4094   /* Opcode: InsertInt P1 P2 P3 P4 P5
         4095  +** Synopsis:  intkey=P3 data=r[P2]
  4045   4096   **
  4046   4097   ** This works exactly like OP_Insert except that the key is the
  4047   4098   ** integer value P3, not the value of the integer stored in register P3.
  4048   4099   */
  4049   4100   case OP_Insert: 
  4050   4101   case OP_InsertInt: {
  4051   4102     Mem *pData;       /* MEM cell holding data for the record to be inserted */
................................................................................
  4188   4239   case OP_ResetCount: {
  4189   4240     sqlite3VdbeSetChanges(db, p->nChange);
  4190   4241     p->nChange = 0;
  4191   4242     break;
  4192   4243   }
  4193   4244   
  4194   4245   /* Opcode: SorterCompare P1 P2 P3
         4246  +** Synopsis:  if key(P1)!=r[P3] goto P2
  4195   4247   **
  4196   4248   ** P1 is a sorter cursor. This instruction compares the record blob in 
  4197   4249   ** register P3 with the entry that the sorter cursor currently points to.
  4198   4250   ** If, excluding the rowid fields at the end, the two records are a match,
  4199   4251   ** fall through to the next instruction. Otherwise, jump to instruction P2.
  4200   4252   */
  4201   4253   case OP_SorterCompare: {
................................................................................
  4209   4261     if( res ){
  4210   4262       pc = pOp->p2-1;
  4211   4263     }
  4212   4264     break;
  4213   4265   };
  4214   4266   
  4215   4267   /* Opcode: SorterData P1 P2 * * *
         4268  +** Synopsis: r[P2]=data
  4216   4269   **
  4217   4270   ** Write into register P2 the current sorter data for sorter cursor P1.
  4218   4271   */
  4219   4272   case OP_SorterData: {
  4220   4273     VdbeCursor *pC;
  4221   4274   
  4222   4275     pOut = &aMem[pOp->p2];
................................................................................
  4223   4276     pC = p->apCsr[pOp->p1];
  4224   4277     assert( pC->isSorter );
  4225   4278     rc = sqlite3VdbeSorterRowkey(pC, pOut);
  4226   4279     break;
  4227   4280   }
  4228   4281   
  4229   4282   /* Opcode: RowData P1 P2 * * *
         4283  +** Synopsis: r[P2]=data
  4230   4284   **
  4231   4285   ** Write into register P2 the complete row data for cursor P1.
  4232   4286   ** There is no interpretation of the data.  
  4233   4287   ** It is just copied onto the P2 register exactly as 
  4234   4288   ** it is found in the database file.
  4235   4289   **
  4236   4290   ** If the P1 cursor must be pointing to a valid row (not a NULL row)
  4237   4291   ** of a real table, not a pseudo-table.
  4238   4292   */
  4239   4293   /* Opcode: RowKey P1 P2 * * *
         4294  +** Synopsis: r[P2]=key
  4240   4295   **
  4241   4296   ** Write into register P2 the complete row key for cursor P1.
  4242   4297   ** There is no interpretation of the data.  
  4243   4298   ** The key is copied onto the P3 register exactly as 
  4244   4299   ** it is found in the database file.
  4245   4300   **
  4246   4301   ** If the P1 cursor must be pointing to a valid row (not a NULL row)
................................................................................
  4305   4360     }
  4306   4361     pOut->enc = SQLITE_UTF8;  /* In case the blob is ever cast to text */
  4307   4362     UPDATE_MAX_BLOBSIZE(pOut);
  4308   4363     break;
  4309   4364   }
  4310   4365   
  4311   4366   /* Opcode: Rowid P1 P2 * * *
         4367  +** Synopsis: r[P2]=rowid
  4312   4368   **
  4313   4369   ** Store in register P2 an integer which is the key of the table entry that
  4314   4370   ** P1 is currently point to.
  4315   4371   **
  4316   4372   ** P1 can be either an ordinary table or a virtual table.  There used to
  4317   4373   ** be a separate OP_VRowid opcode for use with virtual tables, but this
  4318   4374   ** one opcode now works for both table types.
................................................................................
  4462   4518     assert( pOp->p2>0 && pOp->p2<p->nOp );
  4463   4519     if( res ){
  4464   4520       pc = pOp->p2 - 1;
  4465   4521     }
  4466   4522     break;
  4467   4523   }
  4468   4524   
  4469         -/* Opcode: Next P1 P2 * P4 P5
         4525  +/* Opcode: Next P1 P2 * * P5
  4470   4526   **
  4471   4527   ** Advance cursor P1 so that it points to the next key/data pair in its
  4472   4528   ** table or index.  If there are no more key/value pairs then fall through
  4473   4529   ** to the following instruction.  But if the cursor advance was successful,
  4474   4530   ** jump immediately to P2.
  4475   4531   **
  4476   4532   ** The P1 cursor must be for a real table, not a pseudo-table.
................................................................................
  4532   4588   #endif
  4533   4589     }
  4534   4590     pC->rowidIsValid = 0;
  4535   4591     goto check_for_interrupt;
  4536   4592   }
  4537   4593   
  4538   4594   /* Opcode: IdxInsert P1 P2 P3 * P5
         4595  +** Synopsis: key=r[P2]
  4539   4596   **
  4540   4597   ** Register P2 holds an SQL index key made using the
  4541   4598   ** MakeRecord instructions.  This opcode writes that key
  4542   4599   ** into the index P1.  Data for the entry is nil.
  4543   4600   **
  4544   4601   ** P3 is a flag that provides a hint to the b-tree layer that this
  4545   4602   ** insert is likely to be an append.
................................................................................
  4578   4635         }
  4579   4636       }
  4580   4637     }
  4581   4638     break;
  4582   4639   }
  4583   4640   
  4584   4641   /* Opcode: IdxDelete P1 P2 P3 * *
         4642  +** Synopsis: key=r[P2]..
  4585   4643   **
  4586   4644   ** The content of P3 registers starting at register P2 form
  4587   4645   ** an unpacked index key. This opcode removes that entry from the 
  4588   4646   ** index opened by cursor P1.
  4589   4647   */
  4590   4648   case OP_IdxDelete: {
  4591   4649     VdbeCursor *pC;
................................................................................
  4614   4672       assert( pC->deferredMoveto==0 );
  4615   4673       pC->cacheStatus = CACHE_STALE;
  4616   4674     }
  4617   4675     break;
  4618   4676   }
  4619   4677   
  4620   4678   /* Opcode: IdxRowid P1 P2 * * *
         4679  +** Synopsis: r[P2]=rowid
  4621   4680   **
  4622   4681   ** Write into register P2 an integer which is the last entry in the record at
  4623   4682   ** the end of the index key pointed to by cursor P1.  This integer should be
  4624   4683   ** the rowid of the table entry to which this index entry points.
  4625   4684   **
  4626   4685   ** See also: Rowid, MakeRecord.
  4627   4686   */
................................................................................
  4649   4708         pOut->flags = MEM_Int;
  4650   4709       }
  4651   4710     }
  4652   4711     break;
  4653   4712   }
  4654   4713   
  4655   4714   /* Opcode: IdxGE P1 P2 P3 P4 P5
         4715  +** Synopsis: key=r[P3] N=P4
  4656   4716   **
  4657   4717   ** The P4 register values beginning with P3 form an unpacked index 
  4658   4718   ** key that omits the ROWID.  Compare this key value against the index 
  4659   4719   ** that P1 is currently pointing to, ignoring the ROWID on the P1 index.
  4660   4720   **
  4661   4721   ** If the P1 index entry is greater than or equal to the key value
  4662   4722   ** then jump to P2.  Otherwise fall through to the next instruction.
................................................................................
  4663   4723   **
  4664   4724   ** If P5 is non-zero then the key value is increased by an epsilon 
  4665   4725   ** prior to the comparison.  This make the opcode work like IdxGT except
  4666   4726   ** that if the key from register P3 is a prefix of the key in the cursor,
  4667   4727   ** the result is false whereas it would be true with IdxGT.
  4668   4728   */
  4669   4729   /* Opcode: IdxLT P1 P2 P3 P4 P5
         4730  +** Synopsis: key=r[P3] N=P4
  4670   4731   **
  4671   4732   ** The P4 register values beginning with P3 form an unpacked index 
  4672   4733   ** key that omits the ROWID.  Compare this key value against the index 
  4673   4734   ** that P1 is currently pointing to, ignoring the ROWID on the P1 index.
  4674   4735   **
  4675   4736   ** If the P1 index entry is less than the key value then jump to P2.
  4676   4737   ** Otherwise fall through to the next instruction.
................................................................................
  4815   4876         aMem[pOp->p3].u.i += nChange;
  4816   4877       }
  4817   4878     }
  4818   4879     break;
  4819   4880   }
  4820   4881   
  4821   4882   /* Opcode: CreateTable P1 P2 * * *
         4883  +** Synopsis: r[P2]=root iDb=P1
  4822   4884   **
  4823   4885   ** Allocate a new table in the main database file if P1==0 or in the
  4824   4886   ** auxiliary database file if P1==1 or in an attached database if
  4825   4887   ** P1>1.  Write the root page number of the new table into
  4826   4888   ** register P2
  4827   4889   **
  4828   4890   ** The difference between a table and an index is this:  A table must
  4829   4891   ** have a 4-byte integer key and can have arbitrary data.  An index
  4830   4892   ** has an arbitrary key but no data.
  4831   4893   **
  4832   4894   ** See also: CreateIndex
  4833   4895   */
  4834   4896   /* Opcode: CreateIndex P1 P2 * * *
         4897  +** Synopsis: r[P2]=root iDb=P1
  4835   4898   **
  4836   4899   ** Allocate a new index in the main database file if P1==0 or in the
  4837   4900   ** auxiliary database file if P1==1 or in an attached database if
  4838   4901   ** P1>1.  Write the root page number of the new table into
  4839   4902   ** register P2.
  4840   4903   **
  4841   4904   ** See documentation on OP_CreateTable for additional information.
................................................................................
  5029   5092     UPDATE_MAX_BLOBSIZE(pIn1);
  5030   5093     sqlite3VdbeChangeEncoding(pIn1, encoding);
  5031   5094     break;
  5032   5095   }
  5033   5096   #endif /* SQLITE_OMIT_INTEGRITY_CHECK */
  5034   5097   
  5035   5098   /* Opcode: RowSetAdd P1 P2 * * *
         5099  +** Synopsis:  rowset(P1)=r[P2]
  5036   5100   **
  5037   5101   ** Insert the integer value held by register P2 into a boolean index
  5038   5102   ** held in register P1.
  5039   5103   **
  5040   5104   ** An assertion fails if P2 is not an integer.
  5041   5105   */
  5042   5106   case OP_RowSetAdd: {       /* in1, in2 */
................................................................................
  5048   5112       if( (pIn1->flags & MEM_RowSet)==0 ) goto no_mem;
  5049   5113     }
  5050   5114     sqlite3RowSetInsert(pIn1->u.pRowSet, pIn2->u.i);
  5051   5115     break;
  5052   5116   }
  5053   5117   
  5054   5118   /* Opcode: RowSetRead P1 P2 P3 * *
         5119  +** Synopsis:  r[P3]=rowset(P1)
  5055   5120   **
  5056   5121   ** Extract the smallest value from boolean index P1 and put that value into
  5057   5122   ** register P3.  Or, if boolean index P1 is initially empty, leave P3
  5058   5123   ** unchanged and jump to instruction P2.
  5059   5124   */
  5060   5125   case OP_RowSetRead: {       /* jump, in1, out3 */
  5061   5126     i64 val;
................................................................................
  5071   5136       /* A value was pulled from the index */
  5072   5137       sqlite3VdbeMemSetInt64(&aMem[pOp->p3], val);
  5073   5138     }
  5074   5139     goto check_for_interrupt;
  5075   5140   }
  5076   5141   
  5077   5142   /* Opcode: RowSetTest P1 P2 P3 P4
         5143  +** Synopsis: if r[P3] in rowset(P1) goto P2
  5078   5144   **
  5079   5145   ** Register P3 is assumed to hold a 64-bit integer value. If register P1
  5080   5146   ** contains a RowSet object and that RowSet object contains
  5081   5147   ** the value held in P3, jump to register P2. Otherwise, insert the
  5082   5148   ** integer in P3 into the RowSet and continue on to the
  5083   5149   ** next opcode.
  5084   5150   **
................................................................................
  5274   5340     break;
  5275   5341   }
  5276   5342   
  5277   5343   #endif /* #ifndef SQLITE_OMIT_TRIGGER */
  5278   5344   
  5279   5345   #ifndef SQLITE_OMIT_FOREIGN_KEY
  5280   5346   /* Opcode: FkCounter P1 P2 * * *
         5347  +** Synopsis: fkctr[P1]+=P2
  5281   5348   **
  5282   5349   ** Increment a "constraint counter" by P2 (P2 may be negative or positive).
  5283   5350   ** If P1 is non-zero, the database constraint counter is incremented 
  5284   5351   ** (deferred foreign key constraints). Otherwise, if P1 is zero, the 
  5285   5352   ** statement counter is incremented (immediate foreign key constraints).
  5286   5353   */
  5287   5354   case OP_FkCounter: {
................................................................................
  5292   5359     }else{
  5293   5360       p->nFkConstraint += pOp->p2;
  5294   5361     }
  5295   5362     break;
  5296   5363   }
  5297   5364   
  5298   5365   /* Opcode: FkIfZero P1 P2 * * *
         5366  +** Synopsis: if fkctr[P1]==0 goto P2
  5299   5367   **
  5300   5368   ** This opcode tests if a foreign key constraint-counter is currently zero.
  5301   5369   ** If so, jump to instruction P2. Otherwise, fall through to the next 
  5302   5370   ** instruction.
  5303   5371   **
  5304   5372   ** If P1 is non-zero, then the jump is taken if the database constraint-counter
  5305   5373   ** is zero (the one that counts deferred constraint violations). If P1 is
................................................................................
  5314   5382     }
  5315   5383     break;
  5316   5384   }
  5317   5385   #endif /* #ifndef SQLITE_OMIT_FOREIGN_KEY */
  5318   5386   
  5319   5387   #ifndef SQLITE_OMIT_AUTOINCREMENT
  5320   5388   /* Opcode: MemMax P1 P2 * * *
         5389  +** Synopsis: r[P1]=max(r[P1],r[P2])
  5321   5390   **
  5322   5391   ** P1 is a register in the root frame of this VM (the root frame is
  5323   5392   ** different from the current frame if this instruction is being executed
  5324   5393   ** within a sub-program). Set the value of register P1 to the maximum of 
  5325   5394   ** its current value and the value in register P2.
  5326   5395   **
  5327   5396   ** This instruction throws an error if the memory cell is not initially
................................................................................
  5344   5413       pIn1->u.i = pIn2->u.i;
  5345   5414     }
  5346   5415     break;
  5347   5416   }
  5348   5417   #endif /* SQLITE_OMIT_AUTOINCREMENT */
  5349   5418   
  5350   5419   /* Opcode: IfPos P1 P2 * * *
         5420  +** Synopsis: if r[P1]>0 goto P2
  5351   5421   **
  5352   5422   ** If the value of register P1 is 1 or greater, jump to P2.
  5353   5423   **
  5354   5424   ** It is illegal to use this instruction on a register that does
  5355   5425   ** not contain an integer.  An assertion fault will result if you try.
  5356   5426   */
  5357   5427   case OP_IfPos: {        /* jump, in1 */
................................................................................
  5360   5430     if( pIn1->u.i>0 ){
  5361   5431        pc = pOp->p2 - 1;
  5362   5432     }
  5363   5433     break;
  5364   5434   }
  5365   5435   
  5366   5436   /* Opcode: IfNeg P1 P2 * * *
         5437  +** Synopsis: if r[P1]<0 goto P2
  5367   5438   **
  5368   5439   ** If the value of register P1 is less than zero, jump to P2. 
  5369   5440   **
  5370   5441   ** It is illegal to use this instruction on a register that does
  5371   5442   ** not contain an integer.  An assertion fault will result if you try.
  5372   5443   */
  5373   5444   case OP_IfNeg: {        /* jump, in1 */
................................................................................
  5376   5447     if( pIn1->u.i<0 ){
  5377   5448        pc = pOp->p2 - 1;
  5378   5449     }
  5379   5450     break;
  5380   5451   }
  5381   5452   
  5382   5453   /* Opcode: IfZero P1 P2 P3 * *
         5454  +** Synopsis: r[P1]+=P3, if r[P1]==0 goto P2
  5383   5455   **
  5384   5456   ** The register P1 must contain an integer.  Add literal P3 to the
  5385   5457   ** value in register P1.  If the result is exactly 0, jump to P2. 
  5386   5458   **
  5387   5459   ** It is illegal to use this instruction on a register that does
  5388   5460   ** not contain an integer.  An assertion fault will result if you try.
  5389   5461   */
................................................................................
  5394   5466     if( pIn1->u.i==0 ){
  5395   5467        pc = pOp->p2 - 1;
  5396   5468     }
  5397   5469     break;
  5398   5470   }
  5399   5471   
  5400   5472   /* Opcode: AggStep * P2 P3 P4 P5
         5473  +** Synopsis: accum=r[P3] step(r[P2]..) N=P5
  5401   5474   **
  5402   5475   ** Execute the step function for an aggregate.  The
  5403   5476   ** function has P5 arguments.   P4 is a pointer to the FuncDef
  5404   5477   ** structure that specifies the function.  Use register
  5405   5478   ** P3 as the accumulator.
  5406   5479   **
  5407   5480   ** The P5 arguments are taken from register P2 and its
................................................................................
  5457   5530   
  5458   5531     sqlite3VdbeMemRelease(&ctx.s);
  5459   5532   
  5460   5533     break;
  5461   5534   }
  5462   5535   
  5463   5536   /* Opcode: AggFinal P1 P2 * P4 *
         5537  +** Synopsis: accum=r[P1] N=P2
  5464   5538   **
  5465   5539   ** Execute the finalizer function for an aggregate.  P1 is
  5466   5540   ** the memory location that is the accumulator for the aggregate.
  5467   5541   **
  5468   5542   ** P2 is the number of arguments that the step function takes and
  5469   5543   ** P4 is a pointer to the FuncDef for this function.  The P2
  5470   5544   ** argument is not used by this opcode.  It is only there to disambiguate
................................................................................
  5684   5758       p->expired = 1;
  5685   5759     }
  5686   5760     break;
  5687   5761   }
  5688   5762   
  5689   5763   #ifndef SQLITE_OMIT_SHARED_CACHE
  5690   5764   /* Opcode: TableLock P1 P2 P3 P4 *
         5765  +** Synopsis: iDb=P1 root=P2 write=P3
  5691   5766   **
  5692   5767   ** Obtain a lock on a particular table. This instruction is only used when
  5693   5768   ** the shared-cache feature is enabled. 
  5694   5769   **
  5695   5770   ** P1 is the index of the database in sqlite3.aDb[] of the database
  5696   5771   ** on which the lock is acquired.  A readlock is obtained if P3==0 or
  5697   5772   ** a write lock if P3==1.
................................................................................
  5800   5875     }
  5801   5876     break;
  5802   5877   }
  5803   5878   #endif /* SQLITE_OMIT_VIRTUALTABLE */
  5804   5879   
  5805   5880   #ifndef SQLITE_OMIT_VIRTUALTABLE
  5806   5881   /* Opcode: VFilter P1 P2 P3 P4 *
         5882  +** Synopsis: iPlan=r[P3] zPlan='P4'
  5807   5883   **
  5808   5884   ** P1 is a cursor opened using VOpen.  P2 is an address to jump to if
  5809   5885   ** the filtered result set is empty.
  5810   5886   **
  5811   5887   ** P4 is either NULL or a string that was generated by the xBestIndex
  5812   5888   ** method of the module.  The interpretation of the P4 string is left
  5813   5889   ** to the module implementation.
................................................................................
  5874   5950   
  5875   5951     break;
  5876   5952   }
  5877   5953   #endif /* SQLITE_OMIT_VIRTUALTABLE */
  5878   5954   
  5879   5955   #ifndef SQLITE_OMIT_VIRTUALTABLE
  5880   5956   /* Opcode: VColumn P1 P2 P3 * *
         5957  +** Synopsis: r[P3]=vcolumn(P2)
  5881   5958   **
  5882   5959   ** Store the value of the P2-th column of
  5883   5960   ** the row of the virtual-table that the 
  5884   5961   ** P1 cursor is pointing to into register P3.
  5885   5962   */
  5886   5963   case OP_VColumn: {
  5887   5964     sqlite3_vtab *pVtab;
................................................................................
  6007   6084     }
  6008   6085     break;
  6009   6086   }
  6010   6087   #endif
  6011   6088   
  6012   6089   #ifndef SQLITE_OMIT_VIRTUALTABLE
  6013   6090   /* Opcode: VUpdate P1 P2 P3 P4 *
         6091  +** Synopsis: data=r[P3] N=P2
  6014   6092   **
  6015   6093   ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
  6016   6094   ** This opcode invokes the corresponding xUpdate method. P2 values
  6017   6095   ** are contiguous memory cells starting at P3 to pass to the xUpdate 
  6018   6096   ** invocation. The value in register (P3+P2-1) corresponds to the 
  6019   6097   ** p2th element of the argv array passed to xUpdate.
  6020   6098   **

Changes to src/vdbeaux.c.

   849    849     assert( (addr>=0 && addr<p->nOp) || p->db->mallocFailed );
   850    850     if( p->db->mallocFailed ){
   851    851       return (VdbeOp*)&dummy;
   852    852     }else{
   853    853       return &p->aOp[addr];
   854    854     }
   855    855   }
          856  +
          857  +#if defined(SQLITE_DEBUG)
          858  +/*
          859  +** Compute a string for the "comment" field of a VDBE opcode listing
          860  +*/
          861  +static int displayComment(Op *pOp, const char *zP4, char *zTemp, int nTemp){
          862  +  const char *zOpName;
          863  +  const char *zSynopsis;
          864  +  int nOpName;
          865  +  int ii, jj;
          866  +  zOpName = sqlite3OpcodeName(pOp->opcode);
          867  +  nOpName = sqlite3Strlen30(zOpName);
          868  +  if( zOpName[nOpName+1] ){
          869  +    int seenCom = 0;
          870  +    zSynopsis = zOpName += nOpName + 1;
          871  +    for(ii=jj=0; jj<nTemp-1 && zSynopsis[ii]; ii++){
          872  +      if( zSynopsis[ii]=='P' ){
          873  +        int v;
          874  +        const char *zShow = 0;
          875  +        ii++;
          876  +        switch( zSynopsis[ii] ){
          877  +          case '1': v = pOp->p1;  break;
          878  +          case '2': v = pOp->p2;  break;
          879  +          case '3': v = pOp->p3;  break;
          880  +          case '5': v = pOp->p5;  break;
          881  +          case '4': zShow = zP4;  break;
          882  +          case 'X': zShow = pOp->zComment; seenCom = 1; break;
          883  +        }
          884  +        if( zShow ){
          885  +          sqlite3_snprintf(nTemp-jj, zTemp+jj, "%s", zShow);
          886  +        }else{
          887  +          sqlite3_snprintf(nTemp-jj, zTemp+jj, "%d", v);
          888  +        }
          889  +        jj += sqlite3Strlen30(zTemp+jj);
          890  +      }else{
          891  +        zTemp[jj++] = zSynopsis[ii];
          892  +      }
          893  +    }
          894  +    if( !seenCom && jj<nTemp-5 && pOp->zComment ){
          895  +      sqlite3_snprintf(nTemp-jj, zTemp+jj, "; %s", pOp->zComment);
          896  +      jj += sqlite3Strlen30(zTemp+jj);
          897  +    }
          898  +    if( jj<nTemp ) zTemp[jj] = 0;
          899  +  }else if( pOp->zComment ){
          900  +    sqlite3_snprintf(nTemp, zTemp, "%s", pOp->zComment);
          901  +    jj = sqlite3Strlen30(zTemp);
          902  +  }else{
          903  +    zTemp[0] = 0;
          904  +    jj = 0;
          905  +  }
          906  +  return jj;
          907  +}
          908  +#endif /* SQLITE_DEBUG */
          909  +
   856    910   
   857    911   #if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) \
   858    912        || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)
   859    913   /*
   860    914   ** Compute a string that describes the P4 parameter for an opcode.
   861    915   ** Use zTemp for any required temporary buffer space.
   862    916   */
................................................................................
  1043   1097   #if defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)
  1044   1098   /*
  1045   1099   ** Print a single opcode.  This routine is used for debugging only.
  1046   1100   */
  1047   1101   void sqlite3VdbePrintOp(FILE *pOut, int pc, Op *pOp){
  1048   1102     char *zP4;
  1049   1103     char zPtr[50];
         1104  +  char zCom[100];
  1050   1105     static const char *zFormat1 = "%4d %-13s %4d %4d %4d %-4s %.2X %s\n";
  1051   1106     if( pOut==0 ) pOut = stdout;
  1052   1107     zP4 = displayP4(pOp, zPtr, sizeof(zPtr));
         1108  +#ifdef SQLITE_DEBUG
         1109  +  displayComment(pOp, zP4, zCom, sizeof(zCom));
         1110  +#else
         1111  +  zCom[0] = 0
         1112  +#endif
  1053   1113     fprintf(pOut, zFormat1, pc, 
  1054   1114         sqlite3OpcodeName(pOp->opcode), pOp->p1, pOp->p2, pOp->p3, zP4, pOp->p5,
  1055         -#ifdef SQLITE_DEBUG
  1056         -      pOp->zComment ? pOp->zComment : ""
  1057         -#else
  1058         -      ""
  1059         -#endif
         1115  +      zCom
  1060   1116     );
  1061   1117     fflush(pOut);
  1062   1118   }
  1063   1119   #endif
  1064   1120   
  1065   1121   /*
  1066   1122   ** Release an array of N Mem elements
................................................................................
  1198   1254       p->rc = SQLITE_OK;
  1199   1255       rc = SQLITE_DONE;
  1200   1256     }else if( db->u1.isInterrupted ){
  1201   1257       p->rc = SQLITE_INTERRUPT;
  1202   1258       rc = SQLITE_ERROR;
  1203   1259       sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3ErrStr(p->rc));
  1204   1260     }else{
  1205         -    char *z;
         1261  +    char *zP4;
  1206   1262       Op *pOp;
  1207   1263       if( i<p->nOp ){
  1208   1264         /* The output line number is small enough that we are still in the
  1209   1265         ** main program. */
  1210   1266         pOp = &p->aOp[i];
  1211   1267       }else{
  1212   1268         /* We are currently listing subprograms.  Figure out which one and
................................................................................
  1221   1277       if( p->explain==1 ){
  1222   1278         pMem->flags = MEM_Int;
  1223   1279         pMem->type = SQLITE_INTEGER;
  1224   1280         pMem->u.i = i;                                /* Program counter */
  1225   1281         pMem++;
  1226   1282     
  1227   1283         pMem->flags = MEM_Static|MEM_Str|MEM_Term;
  1228         -      pMem->z = (char*)sqlite3OpcodeName(pOp->opcode);  /* Opcode */
         1284  +      pMem->z = (char*)sqlite3OpcodeName(pOp->opcode); /* Opcode */
  1229   1285         assert( pMem->z!=0 );
  1230   1286         pMem->n = sqlite3Strlen30(pMem->z);
  1231   1287         pMem->type = SQLITE_TEXT;
  1232   1288         pMem->enc = SQLITE_UTF8;
  1233   1289         pMem++;
  1234   1290   
  1235   1291         /* When an OP_Program opcode is encounter (the only opcode that has
................................................................................
  1268   1324       pMem++;
  1269   1325   
  1270   1326       if( sqlite3VdbeMemGrow(pMem, 32, 0) ){            /* P4 */
  1271   1327         assert( p->db->mallocFailed );
  1272   1328         return SQLITE_ERROR;
  1273   1329       }
  1274   1330       pMem->flags = MEM_Dyn|MEM_Str|MEM_Term;
  1275         -    z = displayP4(pOp, pMem->z, 32);
  1276         -    if( z!=pMem->z ){
  1277         -      sqlite3VdbeMemSetStr(pMem, z, -1, SQLITE_UTF8, 0);
         1331  +    zP4 = displayP4(pOp, pMem->z, 32);
         1332  +    if( zP4!=pMem->z ){
         1333  +      sqlite3VdbeMemSetStr(pMem, zP4, -1, SQLITE_UTF8, 0);
  1278   1334       }else{
  1279   1335         assert( pMem->z!=0 );
  1280   1336         pMem->n = sqlite3Strlen30(pMem->z);
  1281   1337         pMem->enc = SQLITE_UTF8;
  1282   1338       }
  1283   1339       pMem->type = SQLITE_TEXT;
  1284   1340       pMem++;
................................................................................
  1292   1348         pMem->n = 2;
  1293   1349         sqlite3_snprintf(3, pMem->z, "%.2x", pOp->p5);   /* P5 */
  1294   1350         pMem->type = SQLITE_TEXT;
  1295   1351         pMem->enc = SQLITE_UTF8;
  1296   1352         pMem++;
  1297   1353     
  1298   1354   #ifdef SQLITE_DEBUG
  1299         -      if( pOp->zComment ){
  1300         -        pMem->flags = MEM_Str|MEM_Term;
  1301         -        pMem->z = pOp->zComment;
  1302         -        pMem->n = sqlite3Strlen30(pMem->z);
  1303         -        pMem->enc = SQLITE_UTF8;
  1304         -        pMem->type = SQLITE_TEXT;
  1305         -      }else
         1355  +      if( sqlite3VdbeMemGrow(pMem, 500, 0) ){
         1356  +        assert( p->db->mallocFailed );
         1357  +        return SQLITE_ERROR;
         1358  +      }
         1359  +      pMem->flags = MEM_Dyn|MEM_Str|MEM_Term;
         1360  +      pMem->n = displayComment(pOp, zP4, pMem->z, 500);
         1361  +      pMem->type = SQLITE_TEXT;
         1362  +      pMem->enc = SQLITE_UTF8;
         1363  +#else
         1364  +      pMem->flags = MEM_Null;                       /* Comment */
         1365  +      pMem->type = SQLITE_NULL;
  1306   1366   #endif
  1307         -      {
  1308         -        pMem->flags = MEM_Null;                       /* Comment */
  1309         -        pMem->type = SQLITE_NULL;
  1310         -      }
  1311   1367       }
  1312   1368   
  1313   1369       p->nResColumn = 8 - 4*(p->explain-1);
  1314   1370       p->pResultSet = &p->aMem[1];
  1315   1371       p->rc = SQLITE_OK;
  1316   1372       rc = SQLITE_ROW;
  1317   1373     }