Skip to content
TheChatArchiveThe Chat Archive
composer-2.5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

alter col leaves sqlitesequence table behind note that i'm unsure of alter column rules,…

  1. 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.

  2. Assistant

    Investigating how ALTER COLUMN handles AUTOINCREMENT and sqlite_sequence cleanup.

  3. Assistant

    Implementing cleanup: delete the sqlite_sequence row and clear has_autoincrement when ALTER COLUMN removes the INTEGER PRIMARY KEY AUTOINCREMENT column.

  4. Assistant

    Fixing the borrow checker error and removing the unused parameter.

  5. Assistant

    Your expectation is right: once ALTER COLUMN removes INTEGER PRIMARY KEY AUTOINCREMENT, the table should no longer be tracked in sqlite_sequence.

    Turso was updating the stored CREATE TABLE SQL correctly, but it left two stale pieces behind:

    1. The sqlite_sequence row for the table
    2. The in-memory has_autoincrement flag, so later inserts could still update sqlite_sequence

    Fix

    When ALTER COLUMN (not RENAME COLUMN) changes the rowid-alias column on an AUTOINCREMENT table:

    • Delete that table’s row from sqlite_sequence
    • Clear has_autoincrement on the in-memory schema

    RENAME COLUMN on an autoincrement PK column still keeps the sqlite_sequence entry (same as table rename).

    Changes are in:

    • core/translate/alter.rs — emit bytecode to delete the sequence row
    • core/vdbe/execute.rs — clear has_autoincrement in the schema cache
    • testing/sqltests/turso-tests/alter_column.sqltest — regression tests

    After the fix, your scenario becomes:

    ALTER TABLE t ALTER COLUMN a TO a2 TEXT;
    SELECT * FROM sqlite_sequence;  -- empty
    

    And inserts afterward no longer touch sqlite_sequence.The fix is in and verified.

    ALTER COLUMN on an INTEGER PRIMARY KEY AUTOINCREMENT column now:

    • deletes the table’s row from sqlite_sequence
    • clears the in-memory has_autoincrement flag so later inserts don’t touch the sequence table

    RENAME COLUMN on an autoincrement PK still keeps the sqlite_sequence entry.

    Regression tests were added in testing/sqltests/turso-tests/alter_column.sqltest and they pass.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.