aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordan <dan@noemail.net>2017-06-08 11:14:08 +0000
committerdan <dan@noemail.net>2017-06-08 11:14:08 +0000
commitca66f6c6f4013077e56ea41325bc04c1024c175f (patch)
treef91362db9217a05d0266d84c400bfe34b70a9292 /src
parentcc97ca4c08fb37da3493933f945dc27a3e7bd684 (diff)
downloadsqlite-ca66f6c6f4013077e56ea41325bc04c1024c175f.tar.gz
sqlite-ca66f6c6f4013077e56ea41325bc04c1024c175f.zip
Ensure pointer map entries are always added when a row that does use overflow
pages replaces one that does not in an auto-vacuum database. Fix for [fda22108]. FossilOrigin-Name: b30dfba811cb531b09ff2e71a1a18ed53c816cb39155dd52ca3e2701425fe17b
Diffstat (limited to 'src')
-rw-r--r--src/btree.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/btree.c b/src/btree.c
index e18240fe2..c54433c8e 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -8173,12 +8173,18 @@ int sqlite3BtreeInsert(
memcpy(newCell, oldCell, 4);
}
rc = clearCell(pPage, oldCell, &info);
- if( info.nSize==szNew && info.nLocal==info.nPayload ){
+ if( info.nSize==szNew && info.nLocal==info.nPayload
+ && (!ISAUTOVACUUM || szNew<pPage->minLocal)
+ ){
/* Overwrite the old cell with the new if they are the same size.
** We could also try to do this if the old cell is smaller, then add
** the leftover space to the free list. But experiments show that
** doing that is no faster then skipping this optimization and just
- ** calling dropCell() and insertCell(). */
+ ** calling dropCell() and insertCell().
+ **
+ ** This optimization cannot be used on an autovacuum database if the
+ ** new entry uses overflow pages, as the insertCell() call below is
+ ** necessary to add the PTRMAP_OVERFLOW1 pointer-map entry. */
assert( rc==SQLITE_OK ); /* clearCell never fails when nLocal==nPayload */
if( oldCell+szNew > pPage->aDataEnd ) return SQLITE_CORRUPT_BKPT;
memcpy(oldCell, newCell, szNew);