/ Check-in [39543903]
Login

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

Overview
Comment:Remove an unnecessary local variable from OP_Column, for a small size reduction and performance increase.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 39543903282409ad3f139f8a0bb376661e7595a33af4f647945b1513a028ccb4
User & Date: drh 2017-08-16 14:16:19
Context
2017-08-16
19:20
Avoid a test for CURTYPE_BTREE in sqlite3VdbeCursorMoveto() in order to reduce the size and improve the performance of OP_Column. check-in: f078deb2 user: drh tags: trunk
17:06
Update this branch with the latest changes from trunk. check-in: 380a7b7a user: dan tags: server-process-edition
14:16
Remove an unnecessary local variable from OP_Column, for a small size reduction and performance increase. check-in: 39543903 user: drh tags: trunk
11:04
Performance improvement in the OP_Column opcode. check-in: dc98a92f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

  2382   2382     int len;           /* The length of the serialized data for the column */
  2383   2383     int i;             /* Loop counter */
  2384   2384     Mem *pDest;        /* Where to write the extracted value */
  2385   2385     Mem sMem;          /* For storing the record being decoded */
  2386   2386     const u8 *zData;   /* Part of the record being decoded */
  2387   2387     const u8 *zHdr;    /* Next unparsed byte of the header */
  2388   2388     const u8 *zEndHdr; /* Pointer to first byte after the header */
  2389         -  u32 offset;        /* Offset into the data */
  2390   2389     u64 offset64;      /* 64-bit offset */
  2391   2390     u32 t;             /* A type code from the record header */
  2392   2391     Mem *pReg;         /* PseudoTable input register */
  2393   2392   
  2394   2393     pC = p->apCsr[pOp->p1];
  2395   2394     p2 = pOp->p2;
  2396   2395   
................................................................................
  2434   2433         assert( pC->szRow<=pC->payloadSize );
  2435   2434         assert( pC->szRow<=65536 );  /* Maximum page size is 64KiB */
  2436   2435         if( pC->payloadSize > (u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
  2437   2436           goto too_big;
  2438   2437         }
  2439   2438       }
  2440   2439       pC->cacheStatus = p->cacheCtr;
  2441         -    pC->iHdrOffset = getVarint32(pC->aRow, offset);
         2440  +    pC->iHdrOffset = getVarint32(pC->aRow, aOffset[0]);
  2442   2441       pC->nHdrParsed = 0;
  2443         -    aOffset[0] = offset;
  2444   2442   
  2445   2443   
  2446         -    if( pC->szRow<offset ){      /*OPTIMIZATION-IF-FALSE*/
         2444  +    if( pC->szRow<aOffset[0] ){      /*OPTIMIZATION-IF-FALSE*/
  2447   2445         /* pC->aRow does not have to hold the entire row, but it does at least
  2448   2446         ** need to cover the header of the record.  If pC->aRow does not contain
  2449   2447         ** the complete header, then set it to zero, forcing the header to be
  2450   2448         ** dynamically allocated. */
  2451   2449         pC->aRow = 0;
  2452   2450         pC->szRow = 0;
  2453   2451   
................................................................................
  2456   2454         **
  2457   2455         ** Type entries can be between 1 and 5 bytes each.  But 4 and 5 byte
  2458   2456         ** types use so much data space that there can only be 4096 and 32 of
  2459   2457         ** them, respectively.  So the maximum header length results from a
  2460   2458         ** 3-byte type for each of the maximum of 32768 columns plus three
  2461   2459         ** extra bytes for the header length itself.  32768*3 + 3 = 98307.
  2462   2460         */
  2463         -      if( offset > 98307 || offset > pC->payloadSize ){
         2461  +      if( aOffset[0] > 98307 || aOffset[0] > pC->payloadSize ){
  2464   2462           rc = SQLITE_CORRUPT_BKPT;
  2465   2463           goto abort_due_to_error;
  2466   2464         }
  2467   2465       }else{
  2468   2466         /* This is an optimization.  By skipping over the first few tests
  2469   2467         ** (ex: pC->nHdrParsed<=p2) in the next section, we achieve a
  2470   2468         ** measurable performance gain.
  2471   2469         **
  2472         -      ** This branch is taken even if offset==0.  Such a record is never
         2470  +      ** This branch is taken even if aOffset[0]==0.  Such a record is never
  2473   2471         ** generated by SQLite, and could be considered corruption, but we
  2474         -      ** accept it for historical reasons.  When offset==0, the code this
         2472  +      ** accept it for historical reasons.  When aOffset[0]==0, the code this
  2475   2473         ** branch jumps to reads past the end of the record, but never more
  2476   2474         ** than a few bytes.  Even if the record occurs at the end of the page
  2477   2475         ** content area, the "page header" comes after the page content and so
  2478   2476         ** this overread is harmless.  Similar overreads can occur for a corrupt
  2479   2477         ** database file.
  2480   2478         */
  2481   2479         zData = pC->aRow;
  2482   2480         assert( pC->nHdrParsed<=p2 );         /* Conditional skipped */
  2483         -      testcase( offset==0 );
         2481  +      testcase( aOffset[0]==0 );
  2484   2482         goto op_column_read_header;
  2485   2483       }
  2486   2484     }
  2487   2485   
  2488   2486     /* Make sure at least the first p2+1 entries of the header have been
  2489   2487     ** parsed and valid information is in aOffset[] and pC->aType[].
  2490   2488     */