/ Check-in [e54c9f8d]
Login

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

Overview
Comment:Improvements to opcode documentation in the bytecode engine. No changes to code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:e54c9f8db5b2fa8ea82c6eab7482255431af16901f7992c9667b56a0e50a9f4f
User & Date: drh 2017-04-29 18:02:49
Context
2017-04-29
19:29
Add a single testcase() macro to the subquery processing logic. check-in: 4e1df76e user: drh tags: trunk
18:02
Improvements to opcode documentation in the bytecode engine. No changes to code. check-in: e54c9f8d user: drh tags: trunk
15:27
Evaluate WHERE clause terms that reference only the index before evaluating terms that require the table, and thereby avoid seeking the table row if index terms are false. This is called the "push-down" optimization in the MySQL world, we are told. check-in: d7bb79ed user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

   760    760   ** to the current line should be indented for EXPLAIN output.
   761    761   */
   762    762   case OP_Goto: {             /* jump */
   763    763   jump_to_p2_and_check_for_interrupt:
   764    764     pOp = &aOp[pOp->p2 - 1];
   765    765   
   766    766     /* Opcodes that are used as the bottom of a loop (OP_Next, OP_Prev,
   767         -  ** OP_VNext, OP_RowSetNext, or OP_SorterNext) all jump here upon
          767  +  ** OP_VNext, or OP_SorterNext) all jump here upon
   768    768     ** completion.  Check to see if sqlite3_interrupt() has been called
   769    769     ** or if the progress callback needs to be invoked. 
   770    770     **
   771    771     ** This code uses unstructured "goto" statements and does not look clean.
   772    772     ** But that is not due to sloppy coding habits. The code is written this
   773    773     ** way for performance, to avoid having to run the interrupt and progress
   774    774     ** checks on every opcode.  This helps sqlite3_step() to run about 1.5%
................................................................................
  1563   1563   arithmetic_result_is_null:
  1564   1564     sqlite3VdbeMemSetNull(pOut);
  1565   1565     break;
  1566   1566   }
  1567   1567   
  1568   1568   /* Opcode: CollSeq P1 * * P4
  1569   1569   **
  1570         -** P4 is a pointer to a CollSeq struct. If the next call to a user function
         1570  +** P4 is a pointer to a CollSeq object. If the next call to a user function
  1571   1571   ** or aggregate calls sqlite3GetFuncCollSeq(), this collation sequence will
  1572   1572   ** be returned. This is used by the built-in min(), max() and nullif()
  1573   1573   ** functions.
  1574   1574   **
  1575   1575   ** If P1 is not zero, then it is a register that a subsequent min() or
  1576   1576   ** max() aggregate will set to 1 if the current row is not the minimum or
  1577   1577   ** maximum.  The P1 register is initialized to 0 by this instruction.
................................................................................
  1844   1844   #ifndef SQLITE_OMIT_CAST
  1845   1845   /* Opcode: Cast P1 P2 * * *
  1846   1846   ** Synopsis: affinity(r[P1])
  1847   1847   **
  1848   1848   ** Force the value in register P1 to be the type defined by P2.
  1849   1849   ** 
  1850   1850   ** <ul>
  1851         -** <li value="97"> TEXT
  1852         -** <li value="98"> BLOB
  1853         -** <li value="99"> NUMERIC
  1854         -** <li value="100"> INTEGER
  1855         -** <li value="101"> REAL
         1851  +** <li> P2=='A' &rarr; BLOB
         1852  +** <li> P2=='B' &rarr; TEXT
         1853  +** <li> P2=='C' &rarr; NUMERIC
         1854  +** <li> P2=='D' &rarr; INTEGER
         1855  +** <li> P2=='E' &rarr; REAL
  1856   1856   ** </ul>
  1857   1857   **
  1858   1858   ** A NULL value is not changed by this routine.  It remains NULL.
  1859   1859   */
  1860   1860   case OP_Cast: {                  /* in1 */
  1861   1861     assert( pOp->p2>=SQLITE_AFF_BLOB && pOp->p2<=SQLITE_AFF_REAL );
  1862   1862     testcase( pOp->p2==SQLITE_AFF_TEXT );
................................................................................
  2719   2719   }
  2720   2720   
  2721   2721   /* Opcode: Affinity P1 P2 * P4 *
  2722   2722   ** Synopsis: affinity(r[P1@P2])
  2723   2723   **
  2724   2724   ** Apply affinities to a range of P2 registers starting with P1.
  2725   2725   **
  2726         -** P4 is a string that is P2 characters long. The nth character of the
  2727         -** string indicates the column affinity that should be used for the nth
         2726  +** P4 is a string that is P2 characters long. The N-th character of the
         2727  +** string indicates the column affinity that should be used for the N-th
  2728   2728   ** memory cell in the range.
  2729   2729   */
  2730   2730   case OP_Affinity: {
  2731   2731     const char *zAffinity;   /* The affinity to be applied */
  2732   2732   
  2733   2733     zAffinity = pOp->p4.z;
  2734   2734     assert( zAffinity!=0 );
................................................................................
  2747   2747   /* Opcode: MakeRecord P1 P2 P3 P4 *
  2748   2748   ** Synopsis: r[P3]=mkrec(r[P1@P2])
  2749   2749   **
  2750   2750   ** Convert P2 registers beginning with P1 into the [record format]
  2751   2751   ** use as a data record in a database table or as a key
  2752   2752   ** in an index.  The OP_Column opcode can decode the record later.
  2753   2753   **
  2754         -** P4 may be a string that is P2 characters long.  The nth character of the
  2755         -** string indicates the column affinity that should be used for the nth
         2754  +** P4 may be a string that is P2 characters long.  The N-th character of the
         2755  +** string indicates the column affinity that should be used for the N-th
  2756   2756   ** field of the index key.
  2757   2757   **
  2758   2758   ** The mapping from character to affinity is given by the SQLITE_AFF_
  2759   2759   ** macros defined in sqliteInt.h.
  2760   2760   **
  2761   2761   ** If P4 is NULL then all index fields have the affinity BLOB.
  2762   2762   */
................................................................................
  5744   5744     break;
  5745   5745   }
  5746   5746   #endif /* SQLITE_OMIT_INTEGRITY_CHECK */
  5747   5747   
  5748   5748   /* Opcode: RowSetAdd P1 P2 * * *
  5749   5749   ** Synopsis: rowset(P1)=r[P2]
  5750   5750   **
  5751         -** Insert the integer value held by register P2 into a boolean index
         5751  +** Insert the integer value held by register P2 into a RowSet object
  5752   5752   ** held in register P1.
  5753   5753   **
  5754   5754   ** An assertion fails if P2 is not an integer.
  5755   5755   */
  5756   5756   case OP_RowSetAdd: {       /* in1, in2 */
  5757   5757     pIn1 = &aMem[pOp->p1];
  5758   5758     pIn2 = &aMem[pOp->p2];
................................................................................
  5764   5764     sqlite3RowSetInsert(pIn1->u.pRowSet, pIn2->u.i);
  5765   5765     break;
  5766   5766   }
  5767   5767   
  5768   5768   /* Opcode: RowSetRead P1 P2 P3 * *
  5769   5769   ** Synopsis: r[P3]=rowset(P1)
  5770   5770   **
  5771         -** Extract the smallest value from boolean index P1 and put that value into
  5772         -** register P3.  Or, if boolean index P1 is initially empty, leave P3
         5771  +** Extract the smallest value from the RowSet object in P1
         5772  +** and put that value into register P3.
         5773  +** Or, if RowSet object P1 is initially empty, leave P3
  5773   5774   ** unchanged and jump to instruction P2.
  5774   5775   */
  5775   5776   case OP_RowSetRead: {       /* jump, in1, out3 */
  5776   5777     i64 val;
  5777   5778   
  5778   5779     pIn1 = &aMem[pOp->p1];
  5779   5780     if( (pIn1->flags & MEM_RowSet)==0 
................................................................................
  5796   5797   **
  5797   5798   ** Register P3 is assumed to hold a 64-bit integer value. If register P1
  5798   5799   ** contains a RowSet object and that RowSet object contains
  5799   5800   ** the value held in P3, jump to register P2. Otherwise, insert the
  5800   5801   ** integer in P3 into the RowSet and continue on to the
  5801   5802   ** next opcode.
  5802   5803   **
  5803         -** The RowSet object is optimized for the case where successive sets
  5804         -** of integers, where each set contains no duplicates. Each set
  5805         -** of values is identified by a unique P4 value. The first set
  5806         -** must have P4==0, the final set P4=-1.  P4 must be either -1 or
  5807         -** non-negative.  For non-negative values of P4 only the lower 4
  5808         -** bits are significant.
         5804  +** The RowSet object is optimized for the case where sets of integers
         5805  +** are inserted in distinct phases, which each set contains no duplicates.
         5806  +** Each set is identified by a unique P4 value. The first set
         5807  +** must have P4==0, the final set must have P4==-1, and for all other sets
         5808  +** must have P4>0.
  5809   5809   **
  5810   5810   ** This allows optimizations: (a) when P4==0 there is no need to test
  5811         -** the rowset object for P3, as it is guaranteed not to contain it,
         5811  +** the RowSet object for P3, as it is guaranteed not to contain it,
  5812   5812   ** (b) when P4==-1 there is no need to insert the value, as it will
  5813   5813   ** never be tested for, and (c) when a value that is part of set X is
  5814   5814   ** inserted, there is no need to search to see if the same value was
  5815   5815   ** previously inserted as part of set X (only if it was previously
  5816   5816   ** inserted as part of some other set).
  5817   5817   */
  5818   5818   case OP_RowSetTest: {                     /* jump, in1, in3 */