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

fix a bug that nullable unique index can not find null values using index. #7163

Merged
merged 6 commits into from Jul 27, 2018

Conversation

@winkyao
Copy link
Member

commented Jul 26, 2018

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:

// IsPoint checks if the key range represents a point.
func (r *KeyRange) IsPoint() bool {
	return bytes.Equal(r.StartKey.PrefixNext(), r.EndKey)
}

What is the type of the changes? (mandatory)

  • Bug fix (non-breaking change which fixes an issue)

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)

@winkyao

This comment has been minimized.

Copy link
Member Author

commented Jul 26, 2018

var hasNull bool
for _, highVal := range ran.HighVal {
if highVal.IsNull() {
hasNull = true

This comment has been minimized.

Copy link
@winoros

winoros Jul 26, 2018

Member

We could break at once?

This comment has been minimized.

Copy link
@winkyao

winkyao Jul 26, 2018

Author Member

Done.

@@ -67,6 +67,10 @@ func (ran *Range) IsPoint(sc *stmtctx.StatementContext) bool {
if cmp != 0 {
return false
}

if a.IsNull() && b.IsNull() {

This comment has been minimized.

Copy link
@winoros

winoros Jul 26, 2018

Member

Since cmp is 0. Compare once is enough?

}

if hasNull {
// append 0 to make unique-key range [null, null] to be a scan rather than point-get.

This comment has been minimized.

Copy link
@winoros

winoros Jul 26, 2018

Member

Capitalize first character.

winoros and others added 3 commits Jul 26, 2018
…into fix_unique_null_get
@winkyao

This comment has been minimized.

Copy link
Member Author

commented Jul 26, 2018

@winoros PTAL

Copy link
Member

left a comment

lgtm

@winoros winoros added the status/LGT1 label Jul 26, 2018
@winkyao

This comment has been minimized.

Copy link
Member Author

commented Jul 27, 2018

@coocood PTAL

Copy link
Member

left a comment

LGTM

@zimulala

This comment has been minimized.

Copy link
Member

commented Jul 27, 2018

/run-all-tests

@zimulala zimulala added status/LGT2 and removed status/LGT1 labels Jul 27, 2018
@coocood

This comment has been minimized.

Copy link
Member

commented Jul 27, 2018

LGTM

coocood and others added 2 commits Jul 27, 2018
@winkyao

This comment has been minimized.

Copy link
Member Author

commented Jul 27, 2018

/run-all-tests

@winkyao

This comment has been minimized.

Copy link
Member Author

commented Jul 27, 2018

/run-unit-test

@winkyao winkyao merged commit f107fee into pingcap:master Jul 27, 2018
11 checks passed
11 checks passed
ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jenkins-ci-tidb/build Jenkins job succeeded.
Details
jenkins-ci-tidb/common-test Jenkins job succeeded.
Details
jenkins-ci-tidb/integration-common-test Jenkins job succeeded.
Details
jenkins-ci-tidb/integration-compatibility-test Jenkins job succeeded.
Details
jenkins-ci-tidb/integration-ddl-test Jenkins job succeeded.
Details
jenkins-ci-tidb/mybatis-test Jenkins job succeeded.
Details
jenkins-ci-tidb/sqllogic-test Jenkins job succeeded.
Details
jenkins-ci-tidb/unit-test Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details
@winkyao winkyao deleted the winkyao:fix_unique_null_get branch Jul 27, 2018
winkyao added a commit to winkyao/tidb that referenced this pull request Jul 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.