/ Check-in [d007bc33]
Login

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

Overview
Comment:Minor optimization to allocateSpace().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d007bc339b9ea6d59a3dd2b0c5e77e9c801b16f6
User & Date: drh 2015-06-25 15:04:56
Context
2015-06-25
15:21
Remove a NEVER() that is in fact reachable. check-in: f824e66b user: drh tags: trunk
15:04
Minor optimization to allocateSpace(). check-in: d007bc33 user: drh tags: trunk
13:03
Enhance the Btree object to remember whether or not it is holding an Incrblob cursor. Use this knowledge to improve performance in the common case where it does not. check-in: 476b1156 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to src/btree.c.

  1436   1436     gap = pPage->cellOffset + 2*pPage->nCell;
  1437   1437     assert( gap<=65536 );
  1438   1438     /* EVIDENCE-OF: R-29356-02391 If the database uses a 65536-byte page size
  1439   1439     ** and the reserved space is zero (the usual value for reserved space)
  1440   1440     ** then the cell content offset of an empty page wants to be 65536.
  1441   1441     ** However, that integer is too large to be stored in a 2-byte unsigned
  1442   1442     ** integer, so a value of 0 is used in its place. */
  1443         -  top = get2byteNotZero(&data[hdr+5]);
  1444         -  if( gap>top || (u32)top>pPage->pBt->usableSize ){
         1443  +  top = get2byte(&data[hdr+5]);
         1444  +  assert( top<=pPage->pBt->usableSize ); /* Prevent by getAndInitPage() */
         1445  +  if( gap>top ){
         1446  +    if( top==0 && pPage->pBt->usableSize==65536 ){
         1447  +      top = 65536;
         1448  +    }else{
  1445   1449       return SQLITE_CORRUPT_BKPT;
  1446   1450     }
         1451  +  }
  1447   1452   
  1448   1453     /* If there is enough space between gap and top for one more cell pointer
  1449   1454     ** array entry offset, and if the freelist is not empty, then search the
  1450   1455     ** freelist looking for a free slot big enough to satisfy the request.
  1451   1456     */
  1452   1457     testcase( gap+2==top );
  1453   1458     testcase( gap+1==top );