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 rewrite and its schema/sequence cleanup, then add a regression test that proves the stale row is removed while preserving SQLite’s internal
sqlite_sequencetable semantics. I’m using the code-quality and testing guides because this is an implementation change that requires a focused compatibility test. - Assistant
rgisn’t installed in this checkout, so I’m falling back to targeted recursive searches. The key question is whether ALTER COLUMN uses the normal table-drop path or directly replaces schema rows, since sequence cleanup should be tied to the former behavior. - Assistant
The behavior is now pinned down:
AUTOINCREMENTcan only belong to the rowid-alias column, and ALTER COLUMN rejects adding a new primary key. Therefore altering that specific column necessarily removesAUTOINCREMENT; altering any other column must leave the sequence intact. I’m adding both sides as regression coverage, including a follow-up insert to catch stale in-memory metadata. - Assistant
The regression runner is compiling the Rust backend. While it runs, the implementation point is clear: emit a targeted delete from
sqlite_sequenceduring ALTER’s write program, then clearhas_autoincrementin the live schema when the altered column was the AUTOINCREMENT rowid alias. Both are needed so the current connection and reopened connections agree. - Assistant
The new regression failed before the implementation with exactly
t|2and thent|3, proving both the stale row and stale live metadata. It now passes, and the control test confirms altering a different column keeps the counter and advances it to 3. I’m doing the broader core checks and reviewing the final diff for unintended schema behavior. - Assistant
The focused suite is green: 59/59 ALTER COLUMN tests pass. The full
turso_coretest target is still compiling its test-only dependencies; formatting and diff validation are already clean.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.