/ Check-in [fec071b8]
Login

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

Overview
Comment:Change an assert() into a NEVER(), since the condition is difficult to prove with certainty. Improved comment on the MemPage.nFree field.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | deferred-free-space
Files: files | file ages | folders
SHA3-256:fec071b89df2cbafda365077bb54bc9999e12086f36d6cea8d125662b36638dc
User & Date: drh 2019-02-12 00:58:10
Context
2019-02-12
01:04
Defer computing the number of bytes of free space on a btree page until that value is actually needed. check-in: 177f5f40 user: drh tags: trunk
00:58
Change an assert() into a NEVER(), since the condition is difficult to prove with certainty. Improved comment on the MemPage.nFree field. Closed-Leaf check-in: fec071b8 user: drh tags: deferred-free-space
2019-02-11
22:50
Do not invoke btreeComputeFreeSpace() when not necessary. check-in: f11b0ed4 user: drh tags: deferred-free-space
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

  8291   8291     VVA_ONLY( int balance_quick_called = 0 );
  8292   8292     VVA_ONLY( int balance_deeper_called = 0 );
  8293   8293   
  8294   8294     do {
  8295   8295       int iPage = pCur->iPage;
  8296   8296       MemPage *pPage = pCur->pPage;
  8297   8297   
  8298         -    assert( pPage->nFree>=0 );
         8298  +    if( NEVER(pPage->nFree<0) && btreeComputeFreeSpace(pPage) ) break;
  8299   8299       if( iPage==0 ){
  8300   8300         if( pPage->nOverflow ){
  8301   8301           /* The root page of the b-tree is overfull. In this case call the
  8302   8302           ** balance_deeper() function to create a new child for the root-page
  8303   8303           ** and copy the current contents of the root-page to it. The
  8304   8304           ** next iteration of the do-loop will balance the child page.
  8305   8305           */ 

Changes to src/btreeInt.h.

   282    282     u8 hdrOffset;        /* 100 for page 1.  0 otherwise */
   283    283     u8 childPtrSize;     /* 0 if leaf==1.  4 if leaf==0 */
   284    284     u8 max1bytePayload;  /* min(maxLocal,127) */
   285    285     u8 nOverflow;        /* Number of overflow cell bodies in aCell[] */
   286    286     u16 maxLocal;        /* Copy of BtShared.maxLocal or BtShared.maxLeaf */
   287    287     u16 minLocal;        /* Copy of BtShared.minLocal or BtShared.minLeaf */
   288    288     u16 cellOffset;      /* Index in aData of first cell pointer */
   289         -  int nFree;           /* Number of free bytes on the page */
          289  +  int nFree;           /* Number of free bytes on the page. -1 for unknown */
   290    290     u16 nCell;           /* Number of cells on this page, local and ovfl */
   291    291     u16 maskPage;        /* Mask for page offset */
   292    292     u16 aiOvfl[4];       /* Insert the i-th overflow cell before the aiOvfl-th
   293    293                          ** non-overflow cell */
   294    294     u8 *apOvfl[4];       /* Pointers to the body of overflow cells */
   295    295     BtShared *pBt;       /* Pointer to BtShared that this page is part of */
   296    296     u8 *aData;           /* Pointer to disk image of the page data */