PostgreSQL DDL for constraints backed by indexes incorrectly includes the index definition
- Dominant language
- Java
- Stars
- 51.8k
- Forks
- 4.4k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 188
Description
### Description
The DDL generated for a table with a constraint of the form `CONSTRAINT foo_ck EXCLUDE USING btree (id WITH =, bar WITH =) WHERE ((baz = 2)) DEFERRABLE INITIALLY DEFERRED` is incorrectly adding an index statement `CREATE INDEX foo_ck ON public.t_foo USING btree (id, bar) WHERE (baz = 2)`. That index is an implementation detail and will be created by PostgreSQL as part of the constraint creation. Thus the copied DDL can not be directly executed without further editing of that DDL.
This is similar to https://github.com/dbeaver/dbeaver/issues/7443 but applies to non-unique indexes.
### DBeaver Version
25.2.0 Community
### Operating System
NixOS 25.05
### Database and driver
PostgreSQL 14.19
PostgreSQL JDBC driver 42.7.2
### Steps to reproduce
1. create table with constraint `CONSTRAINT foo_ck EXCLUDE USING btree (id WITH =, bar WITH =) WHERE ((baz = 2)) DEFERRABLE INITIALLY DEFERRED`
2. right click on table and select the "Generate SQL --> DDL" menu option
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.