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

builtins: fix potential panic in crdb_internal.encode_key #42456

Merged
merged 1 commit into from
Nov 13, 2019

Conversation

rohany
Copy link
Contributor

@rohany rohany commented Nov 13, 2019

crdb_internal.encode_key was indexing into a table descriptor's
indexes slice using index ID's, when it should have been using
FindIndexByID.

Release note (bug fix): For tables with dropped indexes, the SHOW RANGE FOR ROW command sometimes returned incorrect
results or an error. Fixed the underlying issue in the crdb_internal.encode_key built-in.

@rohany rohany requested review from solongordon and a team November 13, 2019 20:30
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@solongordon solongordon left a comment

Choose a reason for hiding this comment

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

Fix looks good. Could you add a test? Also I think the release note could use more detail on how this affects users. Doesn't this mean that SHOW RANGE FROM INDEX could return incorrect results?

Copy link
Contributor

@solongordon solongordon left a comment

Choose a reason for hiding this comment

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

I'm still going to pick on the release note. For one thing we should call it out as a "bug fix" rather than a "sql change". For another, we should make it clear that the SHOW RANGE FROM INDEX command is affected since that is the most likely way a user would hit this. (They're unlikely to be calling encode_key directly, right?) And finally I would avoid implementation-level language like "table descriptor" if possible since it's not meaningful to users.

How about something like this?

Release note (bug fix): For tables with dropped indexes, the SHOW RANGE FROM INDEX command sometimes returned incorrect results or an error. Fixed the underlying issue in the encode_key built-in.

Also I would say it's not necessary to say "This should be in 19.2.1" in the commit message. You can just backport it now.

@rohany
Copy link
Contributor Author

rohany commented Nov 13, 2019

Sorry about the back and forth -- what you're saying makes sense. I'll use the updated release note.

Also I would say it's not necessary to say "This should be in 19.2.1" in the commit message. You can just backport it now.

Oh, I didn't know that the branch was open for 19.2.1, i'll open up a backport after this.

crdb_internal.encode_key was indexing into a table descriptor's
indexes slice using index ID's, when it should have been using
`FindIndexByID`.

Release note (bug fix): For tables with dropped indexes, the SHOW RANGE FOR ROW command sometimes returned incorrect
results or an error. Fixed the underlying issue in the crdb_internal.encode_key built-in.
@rohany
Copy link
Contributor Author

rohany commented Nov 13, 2019

bors r+

craig bot pushed a commit that referenced this pull request Nov 13, 2019
42448: sql/mutations: add stats injector + refactor r=mjibson a=mjibson



42456: builtins: fix potential panic in crdb_internal.encode_key r=rohany a=rohany

crdb_internal.encode_key was indexing into a table descriptor's
indexes slice using index ID's, when it should have been using
`FindIndexByID`.

Release note (bug fix): For tables with dropped indexes, the SHOW RANGE FOR ROW command sometimes returned incorrect
results or an error. Fixed the underlying issue in the crdb_internal.encode_key built-in.

Co-authored-by: Matt Jibson <matt.jibson@gmail.com>
Co-authored-by: Rohan Yadav <rohany@alumni.cmu.edu>
@craig
Copy link
Contributor

craig bot commented Nov 13, 2019

Build succeeded

@craig craig bot merged commit 1539f95 into cockroachdb:master Nov 13, 2019
SQL Features (Deprecated - use SQL Experience board) automation moved this from Open PRs to Done Nov 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants