SQLite

View Ticket
Login
2017-06-12
23:44
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]. (check-in: 30c50f0e user: drh tags: branch-3.18)
2017-06-10
17:23
Remove sqlite3_log() and abort() calls added to this branch to debug the pointer-map problem ([fda22108]). (check-in: 79544fc2 user: dan tags: begin-concurrent)
2017-06-08
13:10 Fixed ticket [fda22108]: Corruption due to REPLACE in an auto-vacuumed database plus 3 other changes (artifact: eee8ce59 user: drh)
11:26
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]. (check-in: 9478106c user: drh tags: branch-3.19)
11:14
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]. (check-in: b30dfba8 user: dan tags: trunk)
11:08 Ticket [fda22108] Corruption due to REPLACE in an auto-vacuumed database status still Open with 6 other changes (artifact: 7b1cb0c7 user: drh)
11:07 New ticket [fda22108]. (artifact: 548c43a8 user: drh)

Ticket Hash: fda221088036926487c4be78e67b02acc66afea5
Title: Corruption due to REPLACE in an auto-vacuumed database
Status: Fixed Type: Code_Defect
Severity: Critical Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2017-06-08 13:10:05
Version Found In: 3.19.2
User Comments:
drh added on 2017-06-08 11:07:41:

The following SQL generates a corrupt database file:

PRAGMA page_size = 1024;
PRAGMA auto_vacuum = 1;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
INSERT INTO t1 VALUES(25, randomblob(104));
REPLACE INTO t1 VALUES(25, randomblob(1117));
PRAGMA integrity_check;

The corruption only happens on an auto-vacuumed database. No data is lost and the corruption can be repaired by running VACUUM.

The problem was introduced by check-in [0b86fbca6615ccf1] on 2016-12-09 as part of an optimization to the b-tree row insertion logic. The optimization was to overwrite an existing row rather than doing a separate delete and insert. The problem arises because the pointer map pages were not correctly updated if the overwriting row had the same amount of content on the btree leaf page but a different number of overflow pages.

The problem first appeared in the 3.16.0 release.