cockroachdb / cockroachdb/cockroach
sql: support transactionally dropping an index and creating one with the same name
- 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
Assessment
This issue has not been assessed yet.