-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: Fix panic adding unique, non-indexable column #26684
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.
My concern from a high level is that this is an unsafe API for us to use. The change here makes it safe by going through a special path because we have special knowledge of how to do things in the right order.
Is there a solution which makes the invalid state impossible to produce using the public API?
I'd add a test that adds the same column type and an index as two statements in the same transaction. I wonder if this problem can be fixed by allowing the index to be added but then changing |
@bobvawter as commented on the linked issue, this bug is not specific to arrays, it is general to any non-indexable type. That includes json, for example. I recommend updating the commit title and PR title accordingly, for clarity in the git history. |
This change updates the `checkColumnsFor...Index` functions to use `allNonDropColumns()` to validate against any proposed mutations. Otherwise, a `ColumnMutation` that adds a non-indexable column followed by an `IndexMutation` creating an index on that column would would be incorrectly accepted, leading to a panic. Fixes #26483 Release note (sql change): Return an error to the user instead of panicing when trying to add a column with a unique constraint when that column's type is not indexable.
PTAL: I found a much simpler way to do this by just using Review status: Comments from Reviewable |
Reviewed 2 of 2 files at r1. Comments from Reviewable |
bors r+ |
26684: sql: Fix panic adding unique, non-indexable column r=bobvawter a=bobvawter This change updates the `checkColumnsFor...Index` functions to use `allNonDropColumns()` to validate against any proposed mutations. Otherwise, a `ColumnMutation` that adds a non-indexable column followed by an `IndexMutation` creating an index on that column would would be incorrectly accepted, leading to a panic. Fixes #26483 Release note (sql change): Return an error to the user instead of panicing when trying to add a column with a unique constraint when that column's type is not indexable. 26705: roachtest: use --sequential when generating store dumps r=benesch a=petermattis This makes the mapping from cockroach node ID to roachprod node ID the identify function. Release note: None Co-authored-by: Bob Vawter <[email protected]> Co-authored-by: Peter Mattis <[email protected]>
Build succeeded |
This change updates the
checkColumnsFor...Index
functions to useallNonDropColumns()
to validate against any proposed mutations. Otherwise, aColumnMutation
that adds a non-indexable column followed by anIndexMutation
creating an index on that column would would be incorrectlyaccepted, leading to a panic.
Fixes #26483
Release note (sql change): Return an error to the user instead of panicing when
trying to add a column with a unique constraint when that column's type is not
indexable.