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.
turso> 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’ll trace the ALTER COLUMN rebuild path and sequence cleanup behavior, then add a regression test and run the focused test suite. I’m using the code-quality and testing skills because this is a repository implementation change that requires a failing compatibility test.
- Assistant
The worktree is clean.
rgis unavailable in this environment, so I’m switching to targetedgrep/findsearches and keeping the investigation scoped to schema translation and SQL tests. - Assistant
The bug is localized: ALTER COLUMN rewrites the schema and rows but never removes the table’s sequence row. The correct trigger is narrow—only altering the AUTOINCREMENT rowid-alias column should clear it; altering any other column must preserve the counter. I’ll encode both cases in the regression test before changing the translator.
- Assistant
The new test fails exactly on the stale second
t|2row, while confirming that altering the non-key column preserves the sequence. I’m now adding sequence-row deletion to the ALTER bytecode only when the altered column is the table’s AUTOINCREMENT rowid alias. - Assistant
The fix now passes all 58 ALTER COLUMN tests, including the new preservation/removal regression. I’m doing the final core test and lint checks next, plus reviewing the diff for unintended changes.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.