/ Check-in [83a1e5db]
Login

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

Overview
Comment:Fix harmless compiler warnings in the new balance_nonroot() routine.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 83a1e5db926b3a6d40f4a5cf9a8e6852b9bac9ac
User & Date: drh 2014-11-05 21:21:08
Context
2014-11-05
21:34
Fixes to the Windows VFS to allow memory mapped files to work without WAL support. check-in: 272fddc1 user: drh tags: trunk
21:21
Fix harmless compiler warnings in the new balance_nonroot() routine. check-in: 83a1e5db user: drh tags: trunk
19:26
Change the query planner to do a better job of estimating the number rows selected by a BETWEEN operator using STAT4 when both upper and lower bounds are contained within the same sample. check-in: 2d36be5d user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

  1293   1293   ** allocation is being made in order to insert a new cell, so we will
  1294   1294   ** also end up needing a new cell pointer.
  1295   1295   */
  1296   1296   static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
  1297   1297     const int hdr = pPage->hdrOffset;    /* Local cache of pPage->hdrOffset */
  1298   1298     u8 * const data = pPage->aData;      /* Local cache of pPage->aData */
  1299   1299     int top;                             /* First byte of cell content area */
         1300  +  int rc = SQLITE_OK;                  /* Integer return code */
  1300   1301     int gap;        /* First byte of gap between cell pointers and cell content */
  1301         -  int rc;         /* Integer return code */
  1302   1302     
  1303   1303     assert( sqlite3PagerIswriteable(pPage->pDbPage) );
  1304   1304     assert( pPage->pBt );
  1305   1305     assert( sqlite3_mutex_held(pPage->pBt->mutex) );
  1306   1306     assert( nByte>=0 );  /* Minimum cell size is 4 */
  1307   1307     assert( pPage->nFree>=nByte );
  1308   1308     assert( pPage->nOverflow==0 );
................................................................................
  1324   1324     ** array entry offset, and if the freelist is not empty, then search the
  1325   1325     ** freelist looking for a free slot big enough to satisfy the request.
  1326   1326     */
  1327   1327     testcase( gap+2==top );
  1328   1328     testcase( gap+1==top );
  1329   1329     testcase( gap==top );
  1330   1330     if( gap+2<=top && (data[hdr+1] || data[hdr+2]) ){
  1331         -    int rc = SQLITE_OK;
  1332   1331       int bDefrag = 0;
  1333   1332       u8 *pSpace = pageFindSlot(pPage, nByte, &rc, &bDefrag);
  1334   1333       if( rc ) return rc;
  1335   1334       if( bDefrag ) goto defragment_page;
  1336   1335       if( pSpace ){
  1337         -      *pIdx = pSpace - data;
         1336  +      assert( pSpace>=data && (pSpace - data)<65536 );
         1337  +      *pIdx = (int)(pSpace - data);
  1338   1338         return SQLITE_OK;
  1339   1339       }
  1340   1340     }
  1341   1341   
  1342   1342     /* The request could not be fulfilled using a freelist slot.  Check
  1343   1343     ** to see if defragmentation is necessary.
  1344   1344     */
................................................................................
  6113   6113     int szFree = 0;
  6114   6114   
  6115   6115     for(i=0; i<nCell; i++){
  6116   6116       u8 *pCell = apCell[i];
  6117   6117       if( pCell>=pStart && pCell<pEnd ){
  6118   6118         int sz = szCell[i];
  6119   6119         if( pFree!=(pCell + sz) ){
  6120         -        if( pFree ) freeSpace(pPg, pFree - aData, szFree);
         6120  +        if( pFree ){
         6121  +          assert( pFree>aData && (pFree - aData)<65536 );
         6122  +          freeSpace(pPg, (u16)(pFree - aData), szFree);
         6123  +        }
  6121   6124           pFree = pCell;
  6122   6125           szFree = sz;
  6123   6126           if( pFree+sz>pEnd ) return 0;
  6124   6127         }else{
  6125   6128           pFree = pCell;
  6126   6129           szFree += sz;
  6127   6130         }
  6128   6131         nRet++;
  6129   6132       }
  6130   6133     }
  6131         -  if( pFree ) freeSpace(pPg, pFree - aData, szFree);
         6134  +  if( pFree ){
         6135  +    assert( pFree>aData && (pFree - aData)<65536 );
         6136  +    freeSpace(pPg, (u16)(pFree - aData), szFree);
         6137  +  }
  6132   6138     return nRet;
  6133   6139   }
  6134   6140   
  6135   6141   /*
  6136   6142   ** The pPg->nFree field is invalid when this function returns. It is the
  6137   6143   ** responsibility of the caller to set it correctly.
  6138   6144   */
................................................................................
  6188   6194       nCell += nAdd;
  6189   6195     }
  6190   6196   
  6191   6197     /* Add any overflow cells */
  6192   6198     for(i=0; i<pPg->nOverflow; i++){
  6193   6199       int iCell = (iOld + pPg->aiOvfl[i]) - iNew;
  6194   6200       if( iCell>=0 && iCell<nNew ){
  6195         -      u8 *pCellptr = &pPg->aCellIdx[iCell * 2];
         6201  +      pCellptr = &pPg->aCellIdx[iCell * 2];
  6196   6202         memmove(&pCellptr[2], pCellptr, (nCell - iCell) * 2);
  6197   6203         nCell++;
  6198   6204         if( pageInsertArray(
  6199   6205               pPg, pBegin, &pData, pCellptr,
  6200   6206               1, &apCell[iCell + iNew], &szCell[iCell + iNew]
  6201   6207         ) ) goto editpage_fail;
  6202   6208       }
................................................................................
  6877   6883           rc = SQLITE_CORRUPT_BKPT;
  6878   6884           goto balance_cleanup;
  6879   6885         }
  6880   6886       }
  6881   6887     }
  6882   6888     for(i=0; i<nNew; i++){
  6883   6889       int iBest = 0;                /* aPgno[] index of page number to use */
  6884         -    Pgno pgno;                    /* Page number to use */
  6885   6890       for(j=1; j<nNew; j++){
  6886   6891         if( aPgOrder[j]<aPgOrder[iBest] ) iBest = j;
  6887   6892       }
  6888   6893       pgno = aPgOrder[iBest];
  6889   6894       aPgOrder[iBest] = 0xffffffff;
  6890   6895       if( iBest!=i ){
  6891   6896         if( iBest>i ){