Skip to content

Update sqlite_sequence on ALTER TABLE ... RENAME TO#5653

Merged
penberg merged 1 commit intotursodatabase:mainfrom
kumarUjjawal:fix/alter_table_rename_sequence
Feb 27, 2026
Merged

Update sqlite_sequence on ALTER TABLE ... RENAME TO#5653
penberg merged 1 commit intotursodatabase:mainfrom
kumarUjjawal:fix/alter_table_rename_sequence

Conversation

@kumarUjjawal
Copy link
Contributor

@kumarUjjawal kumarUjjawal commented Feb 27, 2026

Description

Fixes ALTER TABLE ... RENAME TO for AUTOINCREMENT tables so that sqlite_sequence is updated in place during rename.

Changes:

  • Update the ALTER TABLE rename translation path to rewrite
    sqlite_sequence.name from old table name to new table name.
  • Keep behavior consistent with existing MVCC update patterns.
  • Add regression test autoinc-rename-table-updates-sequence-entry in
    testing/runner/tests/autoincr.sqltest.

Motivation and context

Issue #5129 reported that after:

  1. creating an AUTOINCREMENT table,
  2. renaming it via ALTER TABLE ... RENAME TO,
  3. querying sqlite_sequence,

the old table name remained, and later inserts created a second row for the new table name.

Closes #5129

Description of AI Usage

Copy link

@turso-bot turso-bot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review @PThorpe92

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 27, 2026

Merging this PR will improve performance by 16.24%

⚡ 1 improved benchmark
✅ 278 untouched benchmarks
⏩ 105 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation concat_blobs 1.7 µs 1.4 µs +16.24%

Comparing kumarUjjawal:fix/alter_table_rename_sequence (a0940b4) with main (21bdf09)

Open in CodSpeed

Footnotes

  1. 105 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copy link
Collaborator

@penberg penberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, maybe let's have @jussisaurio or @PThorpe92 to have a look too

@penberg penberg merged commit c78b976 into tursodatabase:main Feb 27, 2026
103 of 110 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ALTER TABLE ... RENAME TO does not update sqlite_sequence

3 participants