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: use bare name string of new pk to compare with pk name when altering primary key #90865

Conversation

chengxiong-ruan
Copy link
Contributor

Fixes #90836

Release note (sql change): previously, the DROP CONSTRAINT, ADD CONSTRAINT in one trick to have a new primary key without moving old primary key to be a secondary index didn't work if the primary key name is a reserved SQL keyword. A constraint already exists error was returned. This patch fixed the bug, the trick now also works with primary key named as reserved keywords.

@chengxiong-ruan chengxiong-ruan requested a review from a team October 28, 2022 19:30
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Fixes cockroachdb#90836

Release note (sql change): previously, the `DROP CONSTRAINT, ADD CONSTRAINT`
in one trick to have a new primary key without moving old
primary key to be a secondary index didn't work if the primary
key name is a reserved SQL keyword. A `constraint already exists`
error was returned. This patch fixed the bug, the trick now
also works with primary key named as reserved keywords.
@chengxiong-ruan chengxiong-ruan force-pushed the use-bare-string-when-comparing-pkey-name branch from 5699779 to 746f8f9 Compare October 28, 2022 19:31
@chengxiong-ruan
Copy link
Contributor Author

Thanks for the review and adding backport flag!
bors r+

@craig
Copy link
Contributor

craig bot commented Oct 31, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Oct 31, 2022

Build succeeded:

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: Drop and add a primary key constraint trick doesn't work with primary key named as sql keyword
3 participants