SQLite

View Ticket
Login
Ticket Hash: c88f3036a2fb3f1fe3eb6bed61076222b172dbe1
Title: ALTER TABLE DROP COLUMN may corrupt data
Status: Fixed Type: Code_Defect
Severity: Minor Priority: Low
Subsystem: Unknown Resolution: Fixed
Last Modified: 2021-07-23 23:49:07
Version Found In: 3.35.*
User Comments:
dan added on 2021-04-18 05:42:04: (text/x-markdown)
See forum post from Vladimir Panteleev here: <a href=https://sqlite.org/forum/forumpost/96896f825d>
https://sqlite.org/forum/forumpost/96896f825d
</a>

Reproduce with:

        CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c)
        WITH s(i) AS (
          SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<50000
        )
        INSERT INTO t1(a, b, c) SELECT i, 123, 456 FROM s;
        ALTER TABLE t1 DROP COLUMN b;

        SELECT count(*), c FROM t1 GROUP BY c;
 
The result of the final query should be (50000, 456) - the value of "c" for all rows is 456 - but instead shows that for some rows "c" has the value 123.