/ Check-in [6ac7b07a]
Login

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

Overview
Comment:Remove the OP_RowKey opcode. Use OP_RowData in its place.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6ac7b07a4aff2e1a9031289e3dafdb9ac0071c24
User & Date: drh 2016-11-25 19:32:32
Context
2016-11-25
20:20
Clarification of the behavior of sqlite3_stmt_readonly() on BEGIN IMMEDIATE statements. The is comment changes only - no changes to code. check-in: a4205a83 user: drh tags: trunk
19:32
Remove the OP_RowKey opcode. Use OP_RowData in its place. check-in: 6ac7b07a user: drh tags: trunk
19:18
Refactor the sqlite3BtreeKey() and sqlite3BtreeData() internal interfaces into sqlite3BtreePayload() and sqlite3BtreePayloadChecked(), respectively. This is a continuation of the optimization started by check-in [2d831074cf]. The result is a slightly smaller and faster binary. check-in: 49ebc219 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/delete.c.

   491    491         if( !IsVirtual(pTab) && aToOpen[iDataCur-iTabCur] ){
   492    492           assert( pPk!=0 || pTab->pSelect!=0 );
   493    493           sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, addrBypass, iKey, nKey);
   494    494           VdbeCoverage(v);
   495    495         }
   496    496       }else if( pPk ){
   497    497         addrLoop = sqlite3VdbeAddOp1(v, OP_Rewind, iEphCur); VdbeCoverage(v);
   498         -      sqlite3VdbeAddOp2(v, OP_RowKey, iEphCur, iKey);
          498  +      sqlite3VdbeAddOp2(v, OP_RowData, iEphCur, iKey);
   499    499         assert( nKey==0 );  /* OP_Found will use a composite key */
   500    500       }else{
   501    501         addrLoop = sqlite3VdbeAddOp3(v, OP_RowSetRead, iRowSet, 0, iKey);
   502    502         VdbeCoverage(v);
   503    503         assert( nKey==1 );
   504    504       }  
   505    505     

Changes to src/insert.c.

  2152   2152       sqlite3VdbeSetP4KeyInfo(pParse, pSrcIdx);
  2153   2153       VdbeComment((v, "%s", pSrcIdx->zName));
  2154   2154       sqlite3VdbeAddOp3(v, OP_OpenWrite, iDest, pDestIdx->tnum, iDbDest);
  2155   2155       sqlite3VdbeSetP4KeyInfo(pParse, pDestIdx);
  2156   2156       sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR);
  2157   2157       VdbeComment((v, "%s", pDestIdx->zName));
  2158   2158       addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); VdbeCoverage(v);
  2159         -    sqlite3VdbeAddOp2(v, OP_RowKey, iSrc, regData);
         2159  +    sqlite3VdbeAddOp2(v, OP_RowData, iSrc, regData);
  2160   2160       if( db->flags & SQLITE_Vacuum ){
  2161   2161         /* This INSERT command is part of a VACUUM operation, which guarantees
  2162   2162         ** that the destination table is empty. If all indexed columns use
  2163   2163         ** collation sequence BINARY, then it can also be assumed that the
  2164   2164         ** index will be populated by inserting keys in strictly sorted 
  2165   2165         ** order. In this case, instead of seeking within the b-tree as part
  2166   2166         ** of every OP_IdxInsert opcode, an OP_Last is added before the

Changes to src/select.c.

  2502   2502           generateColumnNames(pParse, pFirst->pSrc, pFirst->pEList);
  2503   2503         }
  2504   2504         iBreak = sqlite3VdbeMakeLabel(v);
  2505   2505         iCont = sqlite3VdbeMakeLabel(v);
  2506   2506         computeLimitRegisters(pParse, p, iBreak);
  2507   2507         sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak); VdbeCoverage(v);
  2508   2508         r1 = sqlite3GetTempReg(pParse);
  2509         -      iStart = sqlite3VdbeAddOp2(v, OP_RowKey, tab1, r1);
         2509  +      iStart = sqlite3VdbeAddOp2(v, OP_RowData, tab1, r1);
  2510   2510         sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0); VdbeCoverage(v);
  2511   2511         sqlite3ReleaseTempReg(pParse, r1);
  2512   2512         selectInnerLoop(pParse, p, p->pEList, tab1,
  2513   2513                         0, 0, &dest, iCont, iBreak);
  2514   2514         sqlite3VdbeResolveLabel(v, iCont);
  2515   2515         sqlite3VdbeAddOp2(v, OP_Next, tab1, iStart); VdbeCoverage(v);
  2516   2516         sqlite3VdbeResolveLabel(v, iBreak);

Changes to src/update.c.

   448    448       labelContinue = labelBreak;
   449    449       sqlite3VdbeAddOp2(v, OP_IsNull, pPk ? regKey : regOldRowid, labelBreak);
   450    450       VdbeCoverageIf(v, pPk==0);
   451    451       VdbeCoverageIf(v, pPk!=0);
   452    452     }else if( pPk ){
   453    453       labelContinue = sqlite3VdbeMakeLabel(v);
   454    454       sqlite3VdbeAddOp2(v, OP_Rewind, iEph, labelBreak); VdbeCoverage(v);
   455         -    addrTop = sqlite3VdbeAddOp2(v, OP_RowKey, iEph, regKey);
          455  +    addrTop = sqlite3VdbeAddOp2(v, OP_RowData, iEph, regKey);
   456    456       sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue, regKey, 0);
   457    457       VdbeCoverage(v);
   458    458     }else{
   459    459       labelContinue = sqlite3VdbeAddOp3(v, OP_RowSetRead, regRowSet, labelBreak,
   460    460                                regOldRowid);
   461    461       VdbeCoverage(v);
   462    462       sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid);

Changes to src/vdbe.c.

  4634   4634     p->apCsr[pOp->p3]->cacheStatus = CACHE_STALE;
  4635   4635     break;
  4636   4636   }
  4637   4637   
  4638   4638   /* Opcode: RowData P1 P2 * * *
  4639   4639   ** Synopsis: r[P2]=data
  4640   4640   **
  4641         -** Write into register P2 the complete row data for cursor P1.
         4641  +** Write into register P2 the complete row content for the row at 
         4642  +** which cursor P1 is currently pointing.
  4642   4643   ** There is no interpretation of the data.  
  4643   4644   ** It is just copied onto the P2 register exactly as 
  4644   4645   ** it is found in the database file.
  4645   4646   **
  4646         -** If the P1 cursor must be pointing to a valid row (not a NULL row)
  4647         -** of a real table, not a pseudo-table.
  4648         -*/
  4649         -/* Opcode: RowKey P1 P2 * * *
  4650         -** Synopsis: r[P2]=key
  4651         -**
  4652         -** Write into register P2 the complete row key for cursor P1.
  4653         -** There is no interpretation of the data.  
  4654         -** The key is copied onto the P2 register exactly as 
  4655         -** it is found in the database file.
         4647  +** If cursor P1 is an index, then the content is the key of the row.
         4648  +** If cursor P2 is a table, then the content extracted is the data.
  4656   4649   **
  4657   4650   ** If the P1 cursor must be pointing to a valid row (not a NULL row)
  4658   4651   ** of a real table, not a pseudo-table.
  4659   4652   */
  4660         -case OP_RowKey:
  4661   4653   case OP_RowData: {
  4662   4654     VdbeCursor *pC;
  4663   4655     BtCursor *pCrsr;
  4664   4656     u32 n;
  4665   4657   
  4666   4658     pOut = &aMem[pOp->p2];
  4667   4659     memAboutToChange(p, pOut);
  4668   4660   
  4669         -  /* Note that RowKey and RowData are really exactly the same instruction */
  4670   4661     assert( pOp->p1>=0 && pOp->p1<p->nCursor );
  4671   4662     pC = p->apCsr[pOp->p1];
  4672   4663     assert( pC!=0 );
  4673   4664     assert( pC->eCurType==CURTYPE_BTREE );
  4674   4665     assert( isSorter(pC)==0 );
  4675         -  assert( pC->isTable || pOp->opcode!=OP_RowData );
  4676         -  assert( pC->isTable==0 || pOp->opcode==OP_RowData );
  4677   4666     assert( pC->nullRow==0 );
  4678   4667     assert( pC->uc.pCursor!=0 );
  4679   4668     pCrsr = pC->uc.pCursor;
  4680   4669   
  4681         -  /* The OP_RowKey and OP_RowData opcodes always follow OP_NotExists or
         4670  +  /* The OP_RowData opcodes always follow OP_NotExists or
  4682   4671     ** OP_SeekRowid or OP_Rewind/Op_Next with no intervening instructions
  4683   4672     ** that might invalidate the cursor.
  4684   4673     ** If this where not the case, on of the following assert()s
  4685   4674     ** would fail.  Should this ever change (because of changes in the code
  4686   4675     ** generator) then the fix would be to insert a call to
  4687   4676     ** sqlite3VdbeCursorMoveto().
  4688   4677     */