SQLite

View Ticket
Login
Ticket Hash: 596d059af77f249314159d608e7449c899ea0764
Title: Committing a transaction with a failed ALTER TABLE may subtly corrupt schema
Status: Closed Type: Code_Defect
Severity: Critical Priority: Immediate
Subsystem: Code_Generator Resolution: Fixed
Last Modified: 2019-03-15 16:28:24
Version Found In:
User Comments:
dan added on 2019-03-15 15:43:08:

  CREATE TABLE t1(a, b);
  CREATE TABLE t3(e, f);
  CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
    INSERT INTO t2 VALUES(new.a, new.b);
  END;
  BEGIN;
    ALTER TABLE t3 RENAME TO t4;
  COMMIT;
  SELECT * FROM sqlite_master WHERE type='table' AND name!='t1';

The output of the above script is:

  table|t3|t3|3|CREATE TABLE "t4"(e, f) 

The schema is now corrupt - as the table name in the SQL does not match the table names in the "name" and "tbl_name" columns.


dan added on 2019-03-15 16:27:35:

Problem introduced along with the ALTER TABLE enhancements in version 3.25.0.


dan added on 2019-03-15 16:28:07:

Fixed here [596d059a].