Skip to content

Fix Mixed Case AutoIncrement Leaving Stale SQLite Sequence ROws#6055

Open
redixhumayun wants to merge 2 commits intotursodatabase:mainfrom
redixhumayun:fix/sqlite-sequence-mixed-case
Open

Fix Mixed Case AutoIncrement Leaving Stale SQLite Sequence ROws#6055
redixhumayun wants to merge 2 commits intotursodatabase:mainfrom
redixhumayun:fix/sqlite-sequence-mixed-case

Conversation

@redixhumayun
Copy link
Contributor

@redixhumayun redixhumayun commented Mar 18, 2026

Description

This PR changes the instructions emitted during DROP TABLE to emit the normalized table name for accurate comparison.

Motivation and context

This PR closes #5807

The issue was that during instruction emission, the non-normalized table name was being used, whereas what is stored is the normalized table name for SQLite sequence.

Description of AI Usage

This PR was written entirely by AI agents (Codex) with Claude reviewing the output. It took a little back and forth to force the agent to scope the changes tightly. For instance, Claude doesn't seem to understand that storing the lowercase name is an explicit design choice in Turso because SQLite does the opposite.

Reproduction Of Fixed Sequence

turso> CREATE TABLE "MiXeD Name"(id INTEGER PRIMARY KEY AUTOINCREMENT, v);
turso> INSERT INTO "MiXeD Name"(v) VALUES('x');
turso> DROP TABLE "MiXeD Name";
turso> CREATE TABLE "MiXeD Name"(id INTEGER PRIMARY KEY AUTOINCREMENT, v);
turso> INSERT INTO "MiXeD Name"(v) VALUES('y');
turso> SELECT id,v FROM "MiXeD Name";
┌────┬───┐
│ id │ v │
├────┼───┤
│  1 │ y │
└────┴───┘
turso> SELECT name,seq FROM sqlite_sequence;
┌────────────┬─────┐
│ name       │ seq │
├────────────┼─────┤
│ mixed name │   1 │
└────────────┴─────┘

This commit normalizes the table name before emitting instructions for drop table. Earlier, the non-normalized name was being emitted.
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 @penberg

Copy link
Collaborator

@PThorpe92 PThorpe92 left a comment

Choose a reason for hiding this comment

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

lgtm 👍

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.

DROP TABLE on Quoted Mixed-Case AUTOINCREMENT Tables Leaves Stale sqlite_sequence Rows

2 participants