Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

CREATE UNIQUE INDEX IF NOT EXISTS doesn't work any more #11756

Closed
2 tasks done
davetapley opened this issue Apr 22, 2024 · 1 comment
Closed
2 tasks done

CREATE UNIQUE INDEX IF NOT EXISTS doesn't work any more #11756

davetapley opened this issue Apr 22, 2024 · 1 comment

Comments

@davetapley
Copy link

davetapley commented Apr 22, 2024

What happens?

CREATE UNIQUE INDEX IF NOT EXISTS works as expected on 0.9.2, but throws Catalog Error on 0.10.1.

Note: this only occurs with UNIQUE, otherwise it's okay 馃


I'll concede that CREATE INDEX IF NOT EXISTS it isn't 'explicitly mentioned in the docs,
but it is covered by tests (albeit not the failing UNIQUE case) 猬囷笍,
and since it worked as expected in 0.9.2 I'm hoping we can call this a Real Bug 馃馃徎

statement ok
CREATE INDEX i_index ON integers(i);
# cannot create an index that already exists
statement error
CREATE INDEX i_index ON integers(i);
----
# with IF NOT EXISTS it does not fail!
statement ok
CREATE INDEX IF NOT EXISTS i_index ON integers(i);

To Reproduce

Now:

v0.10.1 4a89d97db8
create table foo(bar int);
create unique index foo_bar_unique on foo(bar);
create unique index if not exists foo_bar_unique on foo(bar);
Catalog Error: An index with the name foo_bar_uniquealready exists!

But previously:

v0.9.2 3c695d7ba9
create table foo(bar int);
create unique index foo_bar_unique on foo(bar);
create unique index if not exists foo_bar_unique on foo(bar);

OS:

Ubuntu

DuckDB Version:

20.04.6

DuckDB Client:

Python and CLI

Full Name:

Dave Tapley

Affiliation:

JE Fuller

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a stable release

Did you include all relevant data sets for reproducing the issue?

Not applicable - the reproduction does not require a data set

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?

  • Yes, I have
@ewencp
Copy link
Contributor

ewencp commented Apr 24, 2024

This was introduced by 8188cd959f3b45d1c2009bda25f663c19eef7434, which tries to handle automatic indexes (pk, fk, unique) better. But in doing so, it short circuits later checks. Since unique indexes could come from a column constraint or just be created by the user, we need to at least handle the IGNORE_ON_CONFLICT case when checking the index types.

Mytherin added a commit that referenced this issue Apr 25, 2024
Fix #11756: Don't throw exception on CREATE UNIQUE INDEX IF NOT EXISTS if index already exists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants