-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sql: differentiate unique constraints from unique indexes #65929
Comments
Upon further discussion, we probably ought to preserve the old syntax in some form or another for at least one release. An idea is to support it behind a feature flag, warn about it when used, and internally convert such constraints to |
We still don't differentiate the index and the constraint properly but we now treat them all as indexes. I think at this point the fix ought to be to allow dropping the indexes, at least if they aren't weird like partial or have descending orders via the alter table ... drop constraint. That would address #42840. |
This also came up in #91902 I tried something quick:
but then it led to a different round-tripping failure:
|
I don't think I understand your patch. We should not be able to |
Agreed. I'm just pointing out that the patch I attempted to fix round-tripping |
I think that if we were to differentiate them, it'd look like:
would be
and
would be
|
Is your feature request related to a problem? Please describe.
Relates to #65475
Cockroach currently only does a haphazard job distinguishing unique indexes from unique constraints. In postgres these are two distinct objects; a unique constraint is implemented by a unique index but a unique index is not a unique constraint (see #65885). Furthermore, we had code to differentiate these two things, but it was not used properly in
CREATE TABLE
or inIMPORT
. We never really noticed because our display logic forSHOW CREATE TABLE
etc hid any fact that they might differ.The rub here is that unique constraints offer fewer features than unique indexes. We syntactically supported some of these features already. To improve postgres compatibility, we should remove some of this syntax support from unique constraints (meaning people may need to insert the keyword
INDEX
in some places.This is likely to be a backwards incompatible change.
Open questions
ASC
/DESC
orNULLS FIRST
in the elements of the unique constraint. Postgres certainly does not. However, we do in PRIMARY KEY constraints where postgres also does not and we don't have a great hope of eliminating that. Maybe that implies that we should support some, or all of these indexing features.Epic: CRDB-10239
Jira issue: CRDB-7802
The text was updated successfully, but these errors were encountered: