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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: Allow unique-without-index not valid constraint in table creation #115354

Conversation

Xiang-Gu
Copy link
Contributor

Fixes #115352
Release note (bug fix): we fixed a bug where if we add a unique-without-index-not-valid constraint to a table, then the create_statement from SHOW CREATE t is not executable and errors with "unique constraint cannot be NOT VALID". The intention here is to disallow index-backed-unique constraint and this patch fixes that.

Copy link

blathers-crl bot commented Nov 30, 2023

It looks like your PR touches SQL parser code but doesn't add or edit parser tests. Please make sure you add or edit parser tests if you edit the parser.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Release note (bug fix): we fixed a bug where if we add a
unique-without-index-not-valid constraint to a table, then the
`create_statement` from `SHOW CREATE t` is not executable and errors
with "unique constraint cannot be NOT VALID". The intention here is to
disallow index-backed-unique constraint and this patch fixes that.
@Xiang-Gu Xiang-Gu force-pushed the bug/allow-unique-without-index-not-valid-in-create-table branch from 519e621 to 44d218c Compare November 30, 2023 19:41
@Xiang-Gu Xiang-Gu marked this pull request as ready for review December 4, 2023 16:12
@Xiang-Gu Xiang-Gu requested a review from a team as a code owner December 4, 2023 16:12
Copy link
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @mgartner and @Xiang-Gu)


-- commits line 8 at r1:
I don't understand this last sentence

Copy link
Contributor Author

@Xiang-Gu Xiang-Gu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @mgartner and @rytaft)


-- commits line 8 at r1:

Previously, rytaft (Rebecca Taft) wrote…

I don't understand this last sentence

"index-backed-unique constraint" is the usual UNIQUE constraint (implemented by creating a unique index).
UNIQUE-WITHOUT-INDEX constraint, on the other hand, is sometimes referred to as "non-index-backed-unique constraint" bc it's not implemented by a unique index.

@Xiang-Gu
Copy link
Contributor Author

Xiang-Gu commented Dec 7, 2023

TFTR!

bors r+

@rytaft
Copy link
Collaborator

rytaft commented Dec 7, 2023

-- commits line 8 at r1:

Previously, Xiang-Gu (Xiang Gu) wrote…

"index-backed-unique constraint" is the usual UNIQUE constraint (implemented by creating a unique index).
UNIQUE-WITHOUT-INDEX constraint, on the other hand, is sometimes referred to as "non-index-backed-unique constraint" bc it's not implemented by a unique index.

I see, I think I was just confused about what you were disallowing. I guess the point is that you're disallowing use of NOT VALID only with index-backed unique constraints. This could probably use a bit of clarification, but not a big deal.

@craig
Copy link
Contributor

craig bot commented Dec 7, 2023

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Dec 7, 2023

Build succeeded:

@craig craig bot merged commit eb4a916 into cockroachdb:master Dec 7, 2023
9 checks passed
@Xiang-Gu Xiang-Gu deleted the bug/allow-unique-without-index-not-valid-in-create-table branch December 7, 2023 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sql: Mistakenly disallow UNIQUE WITHOUT INDEX NOT VALID in CREATE TABLE stmt
3 participants