cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
30.05k stars 3.8k forks source link

sql: support transactionally dropping an index and creating one with the same name #98494

Open ajwerner opened 1 year ago

ajwerner commented 1 year ago

Is your feature request related to a problem? Please describe. Today, if you try this, you'll get an error.

root@localhost:26257/defaultdb> create table foo (i int primary key, j int);
CREATE TABLE
root@localhost:26257/defaultdb> create index idx on foo(j);
CREATE INDEX
root@localhost:26257/defaultdb> begin;
BEGIN
root@localhost:26257/defaultdb  OPEN> drop index idx;
NOTICE: the data for dropped indexes is reclaimed asynchronously
HINT: The reclamation delay can be customized in the zone configuration for the table.
DROP INDEX
root@localhost:26257/defaultdb  OPEN> create index idx on foo(j);
ERROR: index "idx" being dropped, try again later
SQLSTATE: 55000

Describe the solution you'd like It should just work. The declarative schema changer will make this straightforward.

Additional context This is hard to fix in the legacy schema changer.

Jira issue: CRDB-25297

Jolg42 commented 1 year ago

(Random find) I could reproduce this on CockroachDB v23.1

And I opened a separate issue for columns https://github.com/cockroachdb/cockroach/issues/109587