SQLite4
Check-in [3fe22bbdf0]
Not logged in

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

Overview
Comment:Checked in untested changes by mistake.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | mistake
Files: files | file ages | folders
SHA1: 3fe22bbdf01615e38112a3fadee7c4450525b776
User & Date: drh 2013-07-30 14:16:51
Original Comment: Enhanced comments on the OP_MakeIdxKey opcode. No logic changes.
Context
2013-07-30
14:16
Checked in untested changes by mistake. Closed-Leaf check-in: 3fe22bbdf0 user: drh tags: mistake
13:22
Remove unused P4 parameter type codes. Other cleanup of P4. check-in: 3fa3e910e2 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

  2161   2161     break;
  2162   2162   }
  2163   2163   
  2164   2164   /* Opcode: MakeIdxKey P1 P2 P3 P4 P5
  2165   2165   **
  2166   2166   ** P1 is an open cursor. P2 is the first register in a contiguous array
  2167   2167   ** of N registers containing values to encode into a database key. Normally,
  2168         -** N is equal to the number of columns indexed by P1, plus the number of 
  2169         -** trailing primary key columns (if any). 
  2170         -**
  2171         -** Or, if P4 is a non-zero integer, then it contains the value for N.
         2168  +** N is taken from the KeyInfo object of P1.  However, of P4 is a positive
         2169  +** integer, P4 is used for N instead.
  2172   2170   **
  2173   2171   ** This instruction encodes the N values into a database key and writes
  2174   2172   ** the result to register P3. No affinity transformations are applied to 
  2175   2173   ** the input values before they are encoded. 
  2176   2174   **
  2177   2175   ** If the OPFLAG_SEQCOUNT bit of P5 is set, then a sequence number 
  2178   2176   ** (unique within the cursor) is appended to the record. The sole purpose
  2179         -** of this is to ensure that the key blob is unique within the cursors table.
         2177  +** of this is to ensure that the key blob is unique within the cursor table.
  2180   2178   **
  2181   2179   ** If the OPFLAG_PARTIALKEY bit of P5 is set, that means the value supplied
  2182   2180   ** for N is not the true number of values in the key, only the number that
  2183   2181   ** need to be encoded for this operation.  This effects the encoding of
  2184   2182   ** final BLOBs.
  2185   2183   */
  2186   2184   case OP_MakeIdxKey: {
................................................................................
  2196   2194     
  2197   2195     pC = p->apCsr[pOp->p1];
  2198   2196     pKeyInfo = pC->pKeyInfo;
  2199   2197     pData0 = &aMem[pOp->p2];
  2200   2198     pOut = &aMem[pOp->p3];
  2201   2199     aRec = 0;
  2202   2200   
  2203         -  /* If pOp->p5 is non-zero, encode the sequence number blob to append to
  2204         -  ** the end of the key. Variable nSeq is set to the number of bytes in
  2205         -  ** the encoded key.
         2201  +  /* If P4 contains OPFLAG_SEQCOUNT, encode the sequence number blob to be
         2202  +  ** appended to the end of the key.  Variable nSeq is set to the number
         2203  +  ** of bytes in the encoded key.  A non-standard encoding is used (not
         2204  +  ** the usual varint encoding) so that the OP_GrpCompare opcode can easily
         2205  +  ** back up over the sequence count to find the true end of the key.
  2206   2206     */
  2207   2207     nSeq = 0;
  2208   2208     if( pOp->p5 & OPFLAG_SEQCOUNT ){
  2209   2209       iSeq = pC->seqCount++;
  2210   2210       do {
  2211   2211         nSeq++;
  2212   2212         aSeq[sizeof(aSeq)-nSeq] = (u8)(iSeq & 0x007F);
................................................................................
  2213   2213         iSeq = iSeq >> 7;
  2214   2214       }while( iSeq );
  2215   2215       aSeq[sizeof(aSeq)-nSeq] |= 0x80;
  2216   2216     }
  2217   2217   
  2218   2218     memAboutToChange(p, pOut);
  2219   2219   
  2220         -  nField = pOp->p4.i;
  2221         -  if( nField==0 ) nField = pKeyInfo->nField;
         2220  +//  nField = pOp->p4.i;
         2221  +//  if( nField==0 ) nField = pKeyInfo->nField;
  2222   2222   
  2223   2223     if( pOp->p4type==P4_INT32 && pOp->p4.i ){
  2224   2224       nField = pOp->p4.i;
  2225   2225       assert( nField<=pKeyInfo->nField );
         2226  +  }else{
         2227  +    nField = pKeyInfo->nField;
  2226   2228     }
  2227   2229     rc = sqlite4VdbeEncodeKey(
  2228   2230       db, pData0, nField, pKeyInfo->nField,
  2229   2231       pC->iRoot, pKeyInfo, &aRec, &nRec, nSeq
  2230   2232     );
  2231   2233   
  2232   2234     if( rc ){