alter col leaves sqlitesequence table behind note that i'm unsure of alter column rules,…
- User
alter col leaves sqlite_sequence table behind note that i'm unsure of alter column rules, i was not able to find any docs or rules around this, but my expectation is when we change a autoincrement col to plain text there shouldn't be a stale sqlite_sequence.
sqlturso> CREATE TABLE t(a INTEGER PRIMARY KEY AUTOINCREMENT, b TEXT); INSERT INTO t(b) VALUES('x'),('y'); ALTER TABLE t ALTER COLUMN a TO a2 TEXT; SELECT * FROM sqlite_sequence; SELECT sql FROM sqlite_schema WHERE name='t'; ┌──────┬─────┐ │ name │ seq │ ├──────┼─────┤ │ t │ 2 │ └──────┴─────┘ ┌──────────────────────────────────┐ │ sql │ ├──────────────────────────────────┤ │ CREATE TABLE t (a2 TEXT, b TEXT) │ └──────────────────────────────────┘ turso> select * from sqlite_schema; ┌───────┬─────────────────┬─────────────────┬──────────┬────────────────────────────────────────┐ │ type │ name │ tbl_name │ rootpage │ sql │ ├───────┼─────────────────┼─────────────────┼──────────┼────────────────────────────────────────┤ │ table │ sqlite_sequence │ sqlite_sequence │ 2 │ CREATE TABLE sqlite_sequence(name,seq) │ ├───────┼─────────────────┼─────────────────┼──────────┼────────────────────────────────────────┤ │ table │ t │ t │ 3 │ CREATE TABLE t (a2 TEXT, b TEXT) │ └───────┴─────────────────┴─────────────────┴──────────┴────────────────────────────────────────┘Interface
No new interfaces are introduced.
- Assistant
I’m using the code-quality and testing guides because this is a correctness fix that needs a focused regression test. I’ll trace ALTER COLUMN’s schema-rebuild path and the existing AUTOINCREMENT cleanup behavior, then implement and verify the narrow fix.
- Assistant
rgisn’t installed in this checkout, so I’m using targetedgrep/findsearches instead. The symptom suggests ALTER COLUMN copies the table through a temporary schema but skips the sequence-row cleanup normally done when an AUTOINCREMENT table is dropped or rebuilt. - Assistant
The repository’s language reference confirms the intended rule:
ALTER COLUMN ... TO ...replaces the entire inline column definition. For the reported inlineINTEGER PRIMARY KEY AUTOINCREMENT, that removes AUTOINCREMENT. I also found that the in-memory table metadata keeps its AUTOINCREMENT flag, so the fix must remove both the persisted sequence row and that cached flag. Thesqlite_sequencetable itself should remain, matching existing DROP TABLE behavior; onlyt’s stale row is removed. - Assistant
The regression test is now building against the current code. It checks both observable pieces: the sequence row disappears, and a subsequent insert leaves the new TEXT column
NULLinstead of continuing hidden AUTOINCREMENT behavior. - Assistant
The focused test passes. A formatting invocation also exposed unrelated rustfmt churn in two very large files; I’m cleaning that noise out now so the final patch contains only the sequence cleanup, metadata update, and regression test.
- Assistant
The cleaned patch now has no unrelated formatting changes. The full Turso-specific ALTER COLUMN SQL test file passes (58/58), including the new regression. I’m doing one final core lint/build check before handing it back.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.