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’m going to trace the ALTER COLUMN rebuild path and its schema/sequence cleanup. I’ll use the code-quality and testing guides because this is an implementation fix that needs a regression test.
- Assistant
rgisn’t installed in this checkout, so I’m falling back to targetedgrepsearches. I’m first locating the schema rewrite and existing ALTER tests, then I’ll add the smallest compatibility case that captures the stale row. - Assistant
The stale row is emitted because ALTER rewrites
sqlite_schemabut never performs the sequence cleanup that DROP TABLE already does. The affected case is specifically altering the AUTOINCREMENT rowid-alias column; altering some other column must preserve the counter. I’m adding coverage for both sides of that distinction. - Assistant
The regression test fails on the pre-fix build exactly as reported (
count(*)is 1), while the control case confirms changing a different column retainst|2. The fix now deletes only the affected table’s sequence row and updates the in-memory table metadata so later statements in the same connection no longer treat it as AUTOINCREMENT. - Assistant
The repository isn’t clean under the installed formatter: formatting the touched files rewrote unrelated import ordering and expressions. I’m removing those mechanical changes and retaining only the targeted implementation/test diff before final verification.
- Assistant
The focused ALTER COLUMN suite now passes all 59 cases, including a same-connection insert proving the altered text column receives
NULLrather than continuing AUTOINCREMENT behavior. A broaderturso_coretest attempt with--no-default-featuresis not a supported configuration here and failed on pre-existing feature-gated APIs (uuid,UnixIO::new, database open helpers); the default-feature build used by the SQL suite succeeds.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- fable-5Compare side by side →
- fable-5Compare side by side →