Skip to content

Commit

Permalink
Merge branch 'release-6.1' into cherry-pick-40003-to-release-6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bb7133 authored Jan 13, 2023
2 parents 948792c + ec077a0 commit 6d8bf6c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
15 changes: 0 additions & 15 deletions distsql/request_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,20 +735,5 @@ func EncodeIndexKey(sc *stmtctx.StatementContext, ran *ranger.Range) ([]byte, []
if !ran.HighExclude {
high = kv.Key(high).PrefixNext()
}

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

// NOTE: this is a hard-code operation to avoid wrong results when accessing unique index with NULL;
// Please see https://github.com/pingcap/tidb/issues/29650 for more details
if hasNull {
// Append 0 to make unique-key range [null, null] to be a scan rather than point-get.
high = kv.Key(high).Next()
}
return low, high, nil
}
12 changes: 12 additions & 0 deletions executor/executor_issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1302,3 +1302,15 @@ func TestIssue33214(t *testing.T) {
}
}
}

func TestIssue40158(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)

tk.MustExec("use test")
tk.MustExec("drop table if exists t1")
tk.MustExec("create table t1 (_id int PRIMARY KEY, c1 char, index (c1));")
tk.MustExec("insert into t1 values (1, null);")
tk.MustQuery("select * from t1 where c1 is null and _id < 1;").Check(testkit.Rows())
}

0 comments on commit 6d8bf6c

Please sign in to comment.