Skip to content

DROP INDEX rejects user-created UNIQUE indexes #6359

@LeMikaelF

Description

@LeMikaelF

Description

DROP INDEX rejects every index flagged as UNIQUE, including user-created CREATE UNIQUE INDEX indexes. SQLite only rejects dropping the auto-created sqlite_autoindex_* indexes that back table-level UNIQUE/PRIMARY KEY constraints.

Reproducer

CREATE TABLE t(a INTEGER PRIMARY KEY, b TEXT);
CREATE UNIQUE INDEX ux_t_ab ON t(a, b);
DROP INDEX ux_t_ab;
-- Turso: × Invalid argument supplied: index associated with UNIQUE or PRIMARY KEY constraint cannot be dropped
-- SQLite: (drops the index cleanly)

Per SQLite documentation: "The DROP INDEX statement removes an index added with the CREATE INDEX statement. The index is completely removed from the disk. The only way to recover the index is to reenter the appropriate CREATE INDEX command."

core/translate/index.rs:942-950 - The DROP INDEX validation rejects any index where idx.unique is true, without distinguishing user-created unique indexes from auto-created sqlite_autoindex_* indexes that back table constraints. The existing testing/sqltests/tests/drop_index.sqltest tests only cover the auto-index case, so the regression slipped through.


This issue brought to you by Mikaël and Claude Code.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions