(text/x-fossil-wiki)
When the entry in the sqlite_master table that describes the
sqlite_sequence is corrupted in various ways, subsequent writes to an
autoincrement table result in an assertion fault or crash. Where are
two ways to reproduce the problem from the CLI:
<blockquote><verbatim>
.open -new test.db
CREATE TABLE fake_sequence(name TEXT PRIMARY KEY,seq) WITHOUT ROWID;
PRAGMA writable_schema=on;
UPDATE sqlite_master SET
sql=replace(sql,'fake_','sqlite_'),
name='sqlite_sequence',
tbl_name='sqlite_sequence'
WHERE name='fake_sequence';
.open test.db
CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b TEXT);
INSERT INTO t1(b) VALUES('one');
</verbatim></blockquote>
<blockquote><verbatim>
.open -new test.db
CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b TEXT);
INSERT INTO t1(b) VALUES('one');
PRAGMA writable_schema=on;
UPDATE sqlite_master SET
sql=replace(sql,'sqlite_','x_'),
name='x_sequence',
tbl_name='x_sequence'
WHERE name='sqlite_sequence';
.open test.db
INSERT INTO t1(b) VALUES('two');
</verbatim></blockquote>
There are probably many other reproduction scripts.
The problem has existed ever since autoincrement tables were first
added to SQLite version 3 with version 3.1.0 on 2005-01-21. This problem
was reported on the SQLite users mailing list.
|