/ Check-in [c1f0ae9d]
Login

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

Overview
Comment:Additional comments and an assert on the sqlite3BtreeInsert() overwrite optimization.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c1f0ae9d2981a19875103750379ad26f2575f878
User & Date: drh 2016-12-09 18:09:42
Context
2016-12-09
19:42
When doing the sqlite3BtreeInsert() overwrite optimization, make sure the memcpy() does not extend off the end of the page. check-in: 684ef458 user: drh tags: trunk
18:09
Additional comments and an assert on the sqlite3BtreeInsert() overwrite optimization. check-in: c1f0ae9d user: drh tags: trunk
17:32
In sqlite3BtreeInsert() when replacing a re-existing row, try to overwrite the cell directly rather than deallocate and reallocate the cell. check-in: 0b86fbca user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

  8058   8058       }
  8059   8059       oldCell = findCell(pPage, idx);
  8060   8060       if( !pPage->leaf ){
  8061   8061         memcpy(newCell, oldCell, 4);
  8062   8062       }
  8063   8063       rc = clearCell(pPage, oldCell, &info);
  8064   8064       if( info.nSize==szNew && info.nLocal==info.nPayload ){
  8065         -      /* Overwrite the old cell with the new */
         8065  +      /* Overwrite the old cell with the new if they are the same size.
         8066  +      ** We could also try to do this if the old cell is smaller, then add
         8067  +      ** the leftover space to the free list.  But experiments show that
         8068  +      ** doing that is no faster then skipping this optimization and just
         8069  +      ** calling dropCell() and insertCell(). */
         8070  +      assert( rc==SQLITE_OK ); /* clearCell never fails when nLocal==nPayload */
  8066   8071         memcpy(oldCell, newCell, szNew);
  8067   8072         return SQLITE_OK;
  8068   8073       }
  8069   8074       dropCell(pPage, idx, info.nSize, &rc);
  8070   8075       if( rc ) goto end_insert;
  8071   8076     }else if( loc<0 && pPage->nCell>0 ){
  8072   8077       assert( pPage->leaf );