SQLite

View Ticket
Login
Ticket Hash: b5ca442af9fadf5eff5b2bf64839516ab82cfc3d
Title: "Malformed database schema" when creating a failing index within a transaction
Status: Closed Type: Code_Defect
Severity: Cosmetic Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2019-05-21 14:46:52
Version Found In: 3.28
User Comments:
mrigger added on 2019-05-21 10:04:03:

It seems that an integer overflow that occurs when creating an index does not prevent the index from being created, when the CREATE statement is executed as part of an explicit transaction:

CREATE TABLE IF NOT EXISTS t0(c0);
INSERT INTO t0(c0) VALUES (-9223372036854775808);
BEGIN TRANSACTION;
CREATE INDEX i0 ON t0(ABS(c0)); -- integer overflow (expected)
COMMIT; -- unexpected: the index is still created
CREATE INDEX i0 ON t0(1); -- malformed database schema (i0) - index i0 already exists

That the schema is malformed can also be verified by pragma integrity_check. Without the BEGIN TRANSACTION and COMMIT, the index is not created as expected.


mrigger added on 2019-05-21 10:20:27:

This bug seems serious, since the index can also not be dropped:

CREATE TABLE IF NOT EXISTS t0(c0);
INSERT INTO t0(c0) VALUES (-9223372036854775808);
BEGIN TRANSACTION;
CREATE INDEX i0 ON t0(ABS(c0)); -- integer overflow (expected)
COMMIT; -- unexpected: the index is still created
DROP INDEX i0; -- no such index: i0
CREATE INDEX i0 ON t0(1); -- malformed database schema (i0) - index i0 already exists