cockroachdb / cockroachdb/cockroach

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

Open
#98,494 1 comment 3 reactions 0 assignees View on GitHub
A-schema-transactional C-enhancement T-sql-foundations
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**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

Epic CRDB-60942

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.