-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: remove sequence ownership dependency when dropping sequences #50665
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glad this was a straightforward fix. Could you spend a little time brainstorming about similar cases we may have missed?
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @arulajmani and @solongordon)
pkg/sql/logictest/testdata/logic_test/sequences, line 1088 at r1 (raw file):
statement ok CREATE TABLE t_50649(a INT PRIMARY KEY)
Nit: extra space
Previously, when a sequence that was owned by a column was being dropped, we would not remove the sequence ID from the column descriptor of the column that owned it. As a result, there was a bug where if the sequence was dropped manually before the table, it would be impossible to drop the table. This patch addresses this problem by removing the ownership dependency on sequence drops. Fixes cockroachdb#50649 Release note (bug fix): there was a bug previously where if a user created a sequence owned by a table's column and dropped the sequence, it would become impossible to drop the table after. This is now fixed. See attached issue for repro steps.
TFTR. I'll spend some time going over our current testing and see if there are possible cases we might have missed as a followup. bors r=solongordon |
Build succeeded |
Thanks @arulajmani. Is this getting backported? |
I'm not sure about the backport. cc @solongordon @jordanlewis |
Yes, this needs to be backported. Otherwise, on 20.1 and on 19.2, you can still corrupt your tables by dropping sequences that have ownership relationships to those tables. |
Err, this doesn't exist on 19.2, does it. So just 20.1 is what I meant to say. |
Doesn't exist on 19.2; I'll backport to 20.1 |
Previously, when a sequence that was owned by a column was being
dropped, we would not remove the sequence ID from the column descriptor
of the column that owned it. As a result, there was a bug where if the
sequence was dropped manually before the table, it would be impossible
to drop the table.
This patch addresses this problem by removing the ownership dependency
on sequence drops.
Fixes #50649
Release note (bug fix): there was a bug previously where if a user
created a sequence owned by a table's column and dropped the sequence,
it would become impossible to drop the table after. This is now fixed.
See attached issue for repro steps.