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
Now let me reproduce the issue and also check whether the in-memory schema still thinks the table has autoincrement after the ALTER:
- Assistant
Now add the detection and the call in the AlterColumn branch. The schema-rewrite
cursor_loopends right before the trigger updates: - Assistant
Now the in-memory schema update in
op_alter_column: - Assistant
The user's case is fixed. Now the table-level PK case:
- Assistant
MVCC rejects AUTOINCREMENT entirely, so that path is moot. All behavior verified. Now add regression tests to the sqltest file:
- Assistant
Suspiciously fast — the filter may have matched nothing. Let me check:
- Assistant
All 61 pass (4 new). Now check other test suites touching this behavior, and run clippy:
- Assistant
Full sqltest suite passes. Let me also run the TCL alter/autoincrement tests and the core unit tests for translate:
- Assistant
The table-level PK is dropped by a follow-up ADD COLUMN — but let me confirm that's a pre-existing issue unrelated to autoincrement (my change doesn't touch the non-autoincrement path):
- Assistant
Pre-existing and orthogonal (happens with a plain table-level PK, no AUTOINCREMENT). Final checks — fmt and clippy with all targets on the touched crate:
- Assistant
All done. Your expectation was right — SQLite has no (it's a Turso extension), so there's no upstream rule, but since the ALTER replaces the column definition wholesale (dropping its ), the entry must go with it. While validating, I found the staleness ran deeper than the leftover row.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.