SQLite

View Ticket
Login
Ticket Hash: a8a4847a2d96f5de99082be3310dc5f0f96675f8
Title: Trigger inserts duplicate value in UNIQUE column
Status: Fixed Type: Code_Defect
Severity: Important Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2019-10-16 14:56:24
Version Found In: 3.30.0
User Comments:
mrigger added on 2019-10-16 13:18:22:

Consider the following test case:

PRAGMA recursive_triggers = true;
CREATE TABLE t0(c0 UNIQUE);
CREATE TRIGGER tr0 AFTER DELETE ON t0 BEGIN INSERT INTO t0 VALUES(0); END;
INSERT OR REPLACE INTO t0(c0) VALUES(0), (0);
REINDEX; -- UNIQUE constraint failed: t0.c0

Unexpectedly, the trigger results in the insertion of a duplicate value, which is detected by the REINDEX.