Skip to content

Commit

Permalink
cherry pick #18814 to release-4.0 (#18815)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-srebot authored Jul 28, 2020
1 parent b59b532 commit 575bc85
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions executor/batch_point_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,14 @@ func (s *testBatchPointGetSuite) TestBatchPointGetInTxn(c *C) {
tk.MustQuery("select * from s where (a, b) in ((1, 1), (2, 2), (3, 3)) for update").Check(testkit.Rows("1 1 1", "3 3 10"))
tk.MustExec("rollback")
}

func (s *testBatchPointGetSuite) TestBatchPointGetCache(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("create table customers (id int primary key, token varchar(255) unique)")
tk.MustExec("INSERT INTO test.customers (id, token) VALUES (28, '07j')")
tk.MustExec("INSERT INTO test.customers (id, token) VALUES (29, '03j')")
tk.MustExec("BEGIN")
tk.MustQuery("SELECT id, token FROM test.customers WHERE id IN (28)")
tk.MustQuery("SELECT id, token FROM test.customers WHERE id IN (28, 29);").Check(testkit.Rows("28 07j", "29 03j"))
}
2 changes: 1 addition & 1 deletion store/tikv/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (s *tikvSnapshot) BatchGet(ctx context.Context, keys []kv.Key) (map[string]
m := make(map[string][]byte)
s.mu.RLock()
if s.mu.cached != nil {
tmp := keys[:0]
tmp := make([]kv.Key, 0, len(keys))
for _, key := range keys {
if val, ok := s.mu.cached[string(key)]; ok {
if len(val) > 0 {
Expand Down

0 comments on commit 575bc85

Please sign in to comment.