/ Check-in [a159e9d2]
Login

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

Overview
Comment:Reverse the order of two conditionals in a test in order to achieve coverage of them both. Also: clarifications to comments in btree.c. (CVS 6912)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a159e9d24708dfe6c5a98d220e39f3b1b2a3d281
User & Date: drh 2009-07-20 19:30:01
Context
2009-07-21
11:52
Changes to btree.c in support of coverage testing. (CVS 6913) check-in: 4cf23e9e user: drh tags: trunk
2009-07-20
19:30
Reverse the order of two conditionals in a test in order to achieve coverage of them both. Also: clarifications to comments in btree.c. (CVS 6912) check-in: a159e9d2 user: drh tags: trunk
17:11
Modify various routines inside btree.c to take a pointer to the return-code as a parameter and to no-op if the return-code storage location already contains a non-zero code. (CVS 6911) check-in: 7dcf2a78 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** $Id: btree.c,v 1.692 2009/07/20 17:11:50 drh Exp $
           12  +** $Id: btree.c,v 1.693 2009/07/20 19:30:01 drh Exp $
    13     13   **
    14     14   ** This file implements a external (disk-based) database using BTrees.
    15     15   ** See the header comment on "btreeInt.h" for additional information.
    16     16   ** Including a description of file format and an overview of operation.
    17     17   */
    18     18   #include "btreeInt.h"
    19     19   
................................................................................
  5586   5586   ** balancing routine to fix this problem (see the balance() routine). 
  5587   5587   **
  5588   5588   ** If this routine fails for any reason, it might leave the database
  5589   5589   ** in a corrupted state. So if this routine fails, the database should
  5590   5590   ** be rolled back.
  5591   5591   **
  5592   5592   ** The third argument to this function, aOvflSpace, is a pointer to a
  5593         -** buffer page-size bytes in size. If, in inserting cells into the parent
  5594         -** page (pParent), the parent page becomes overfull, this buffer is
  5595         -** used to store the parents overflow cells. Because this function inserts
         5593  +** buffer big enough to hold one page. If while inserting cells into the parent
         5594  +** page (pParent) the parent page becomes overfull, this buffer is
         5595  +** used to store the parent's overflow cells. Because this function inserts
  5596   5596   ** a maximum of four divider cells into the parent page, and the maximum
  5597   5597   ** size of a cell stored within an internal node is always less than 1/4
  5598   5598   ** of the page-size, the aOvflSpace[] buffer is guaranteed to be large
  5599   5599   ** enough for all overflow cells.
  5600   5600   **
  5601   5601   ** If aOvflSpace is set to a null pointer, this function returns 
  5602   5602   ** SQLITE_NOMEM.
................................................................................
  5642   5642   #if 0
  5643   5643     TRACE(("BALANCE: begin page %d child of %d\n", pPage->pgno, pParent->pgno));
  5644   5644   #endif
  5645   5645   
  5646   5646     /* At this point pParent may have at most one overflow cell. And if
  5647   5647     ** this overflow cell is present, it must be the cell with 
  5648   5648     ** index iParentIdx. This scenario comes about when this function
  5649         -  ** is called (indirectly) from sqlite3BtreeDelete(). */
         5649  +  ** is called (indirectly) from sqlite3BtreeDelete().
         5650  +  */
  5650   5651     assert( pParent->nOverflow==0 || pParent->nOverflow==1 );
  5651   5652     assert( pParent->nOverflow==0 || pParent->aOvfl[0].idx==iParentIdx );
  5652   5653   
  5653   5654     if( !aOvflSpace ){
  5654   5655       return SQLITE_NOMEM;
  5655   5656     }
  5656   5657   
................................................................................
  5658   5659     ** that divide the siblings. An attempt is made to find NN siblings on 
  5659   5660     ** either side of pPage. More siblings are taken from one side, however, 
  5660   5661     ** if there are fewer than NN siblings on the other side. If pParent
  5661   5662     ** has NB or fewer children then all children of pParent are taken.  
  5662   5663     **
  5663   5664     ** This loop also drops the divider cells from the parent page. This
  5664   5665     ** way, the remainder of the function does not have to deal with any
  5665         -  ** overflow cells in the parent page, as if one existed it has already
  5666         -  ** been removed.  */
         5666  +  ** overflow cells in the parent page, since if any existed they will
         5667  +  ** have already been removed.
         5668  +  */
  5667   5669     i = pParent->nOverflow + pParent->nCell;
  5668   5670     if( i<2 ){
  5669   5671       nxDiv = 0;
  5670   5672       nOld = i+1;
  5671   5673     }else{
  5672   5674       nOld = 3;
  5673   5675       if( iParentIdx==0 ){                 
................................................................................
  5690   5692       if( rc ){
  5691   5693         memset(apOld, 0, i*sizeof(MemPage*));
  5692   5694         goto balance_cleanup;
  5693   5695       }
  5694   5696       nMaxCells += 1+apOld[i]->nCell+apOld[i]->nOverflow;
  5695   5697       if( (i--)==0 ) break;
  5696   5698   
  5697         -    if( pParent->nOverflow && i+nxDiv==pParent->aOvfl[0].idx ){
         5699  +    if( i+nxDiv==pParent->aOvfl[0].idx && pParent->nOverflow ){
  5698   5700         apDiv[i] = pParent->aOvfl[0].pCell;
  5699   5701         pgno = get4byte(apDiv[i]);
  5700   5702         szNew[i] = cellSizePtr(pParent, apDiv[i]);
  5701   5703         pParent->nOverflow = 0;
  5702   5704       }else{
  5703   5705         apDiv[i] = findCell(pParent, i+nxDiv-pParent->nOverflow);
  5704   5706         pgno = get4byte(apDiv[i]);