-
Notifications
You must be signed in to change notification settings - Fork 5.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
fix a bug that nullable unique index can not find null values using index. #7163
Conversation
var hasNull bool | ||
for _, highVal := range ran.HighVal { | ||
if highVal.IsNull() { | ||
hasNull = true |
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.
We could break at once?
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.
Done.
util/ranger/types.go
Outdated
@@ -67,6 +67,10 @@ func (ran *Range) IsPoint(sc *stmtctx.StatementContext) bool { | |||
if cmp != 0 { | |||
return false | |||
} | |||
|
|||
if a.IsNull() && b.IsNull() { |
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.
Since cmp
is 0. Compare once is enough?
distsql/request_builder.go
Outdated
} | ||
|
||
if hasNull { | ||
// append 0 to make unique-key range [null, null] to be a scan rather than point-get. |
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.
Capitalize first character.
@winoros PTAL |
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.
lgtm
@coocood PTAL |
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.
LGTM
/run-all-tests |
LGTM |
/run-all-tests |
/run-unit-test |
What have you changed? (mandatory)
Append 0 to the EndKey of the 'Is Null' index range. To make unique-key range [null, null] to be a scan rather than point-get in tikv.
See https://github.com/pingcap/tidb/blob/master/store/mockstore/mocktikv/executor.go#L289, and it will judge the range as point-get by:
What is the type of the changes? (mandatory)
How has this PR been tested? (mandatory)
UT
Does this PR affect documentation (docs/docs-cn) update? (mandatory)
no
Does this PR affect tidb-ansible update? (mandatory)
no
Does this PR need to be added to the release notes? (mandatory)
no
Refer to a related PR or issue link (optional)
Benchmark result if necessary (optional)
Add a few positive/negative examples (optional)