|17:53||• Fixed ticket [d8dc2b3a]: Crash when the schema for sqlite_sequence is corrupt plus 5 other changes (artifact: de111d9d user: drh)|
|17:53||Remove a branch that is no longer used due to the fix to the sqlite_sequence schema problem, ticket [d8dc2b3a58cd5dc2918a1d4acbba4676a23ada4c] (check-in: 06674269 user: drh tags: trunk)|
|16:50||Verify that the sqlite_sequence table exists and is in approximately the correct format prior to using it to process an autoincrement table. Fix for ticket [d8dc2b3a58cd5dc2918a1d4a]. (check-in: e199e859 user: drh tags: trunk)|
|15:28||• New ticket [d8dc2b3a] Crash when the schema for sqlite_sequence is corrupt. (artifact: 82d3a7b3 user: drh)|
|Title:||Crash when the schema for sqlite_sequence is corrupt|
|Last Modified:||2018-05-23 17:53:50|
|Version Found In:||3.23.1|
drh added on 2018-05-23 15:28:51:
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:
.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');
.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');
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.