Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions core/translate/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1822,7 +1822,7 @@ pub fn translate_drop_table(
let seq_cursor_id = program.alloc_cursor_id(CursorType::BTreeTable(seq_table.clone()));
let seq_table_name_reg = program.alloc_register();
let dropped_table_name_reg =
program.emit_string8_new_reg(tbl_name.name.as_str().to_string());
program.emit_string8_new_reg(normalize_ident(tbl_name.name.as_str()));
program.mark_last_insn_constant();

program.emit_insn(Insn::OpenWrite {
Expand Down Expand Up @@ -1875,7 +1875,8 @@ pub fn translate_drop_table(
{
let ver_cursor_id = program.alloc_cursor_id(CursorType::BTreeTable(version_table.clone()));
let ver_table_name_reg = program.alloc_register();
let dropped_name_reg = program.emit_string8_new_reg(tbl_name.name.as_str().to_string());
let dropped_name_reg =
program.emit_string8_new_reg(normalize_ident(tbl_name.name.as_str()));
program.mark_last_insn_constant();

program.emit_insn(Insn::OpenWrite {
Expand Down
17 changes: 17 additions & 0 deletions testing/sqltests/tests/autoincr.sqltest
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,23 @@ test autoinc-drop-last-table-empties-sequence {
expect {
}

# https://github.com/tursodatabase/turso/issues/5807
# DROP TABLE should remove sqlite_sequence entries even for quoted mixed-case names.
@cross-check-integrity
test autoinc-drop-mixed-case-table-removes-sequence-entry {
CREATE TABLE "MiXeD Name"(id INTEGER PRIMARY KEY AUTOINCREMENT, v);
INSERT INTO "MiXeD Name"(v) VALUES('x');
DROP TABLE "MiXeD Name";
CREATE TABLE "MiXeD Name"(id INTEGER PRIMARY KEY AUTOINCREMENT, v);
INSERT INTO "MiXeD Name"(v) VALUES('y');
SELECT id, v FROM "MiXeD Name";
SELECT seq FROM sqlite_sequence;
}
expect {
1|y
1
}

# Test: Renaming an AUTOINCREMENT table updates sqlite_sequence in place.
@cross-check-integrity
test autoinc-rename-table-updates-sequence-entry {
Expand Down
Loading