/ Check-in [3e11dc31]
Login

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

Overview
Comment:Fix harmless compiler warnings in the cell-overwrite logic.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | cell-overwrite-prototype
Files: files | file ages | folders
SHA3-256: 3e11dc3183bc3e8ec49af244a8e8b3e07d12f7a2e59028b2bf64ce0ab589a91f
User & Date: drh 2018-05-07 11:29:59
Context
2018-05-07
11:48
On an UPDATE, try to overwrite an existing btree cell with the modified content, if the old and new cell are the same size. Use memcmp() first to avoid dirtying pages that are unchanged. check-in: 5887d8be user: drh tags: trunk
11:29
Fix harmless compiler warnings in the cell-overwrite logic. Closed-Leaf check-in: 3e11dc31 user: drh tags: cell-overwrite-prototype
2018-05-04
19:18
Merge enhancements from trunk. check-in: 9650f71b user: drh tags: cell-overwrite-prototype
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

  8210   8210     rc = btreeOverwriteContent(pPage, pCur->info.pPayload, pX,
  8211   8211                                0, pCur->info.nLocal);
  8212   8212     if( rc ) return rc;
  8213   8213     if( pCur->info.nLocal==nTotal ) return SQLITE_OK;
  8214   8214   
  8215   8215     /* Now overwrite the overflow pages */
  8216   8216     iOffset = pCur->info.nLocal;
         8217  +  assert( nTotal>=0 );
         8218  +  assert( iOffset>=0 );
  8217   8219     ovflPgno = get4byte(pCur->info.pPayload + iOffset);
  8218   8220     pBt = pPage->pBt;
  8219   8221     ovflPageSize = pBt->usableSize - 4;
  8220   8222     do{
  8221   8223       rc = btreeGetPage(pBt, ovflPgno, &pPage, 0);
  8222   8224       if( rc ) return rc;
  8223   8225       if( sqlite3PagerPageRefcount(pPage->pDbPage)!=1 ){
  8224   8226         rc = SQLITE_CORRUPT_BKPT;
  8225   8227       }else{
  8226         -      if( iOffset+ovflPageSize<nTotal ){
         8228  +      if( iOffset+ovflPageSize<(u32)nTotal ){
  8227   8229           ovflPgno = get4byte(pPage->aData);
  8228   8230         }else{
  8229   8231           ovflPageSize = nTotal - iOffset;
  8230   8232         }
  8231   8233         rc = btreeOverwriteContent(pPage, pPage->aData+4, pX,
  8232   8234                                    iOffset, ovflPageSize);
  8233   8235       }
................................................................................
  8334   8336   
  8335   8337       /* If the cursor is currently on the last row and we are appending a
  8336   8338       ** new row onto the end, set the "loc" to avoid an unnecessary
  8337   8339       ** btreeMoveto() call */
  8338   8340       if( (pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey==pCur->info.nKey ){
  8339   8341         /* The current is currently pointing to the entry that is to be
  8340   8342         ** overwritten */
  8341         -      if( pCur->info.nSize!=0 && pCur->info.nPayload==pX->nData+pX->nZero ){
         8343  +      assert( pX->nData>=0 && pX->nZero>=0 );
         8344  +      if( pCur->info.nSize!=0
         8345  +       && pCur->info.nPayload==(u32)pX->nData+pX->nZero
         8346  +      ){
  8342   8347           return btreeOverwriteCell(pCur, pX);
  8343   8348         }
  8344   8349         loc = 0;
  8345   8350       }else if( loc==0 ){
  8346   8351         rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, flags!=0, &loc);
  8347   8352         if( rc ) return rc;
  8348   8353       }