Skip to content

Commit

Permalink
executor: fix cop request key range order another case (#36883) (#36886)
Browse files Browse the repository at this point in the history
close #36876
  • Loading branch information
ti-srebot authored Aug 4, 2022
1 parent 0da30a3 commit 95c7157
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions executor/distsql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,4 +627,19 @@ func TestCoprocessorPagingReqKeyRangeSorted(t *testing.T) {
tk.MustExec("execute stmt using @a,@b,@c,@d;")
tk.MustExec("set @a=0xFCABFE6198B6323EE8A46247EDD33830453B1BDE, @b=0xFCABFE6198B6323EE8A46247EDD33830453B1BDE, @c=0xFCABFE6198B6323EE8A46247EDD33830453B1BDE, @d=0xFCABFE6198B6323EE8A46247EDD33830453B1BDE;")
tk.MustExec("execute stmt using @a,@b,@c,@d;")

tk.MustExec("CREATE TABLE `PK_SNPRE10114` (" +
"`COL1` varbinary(10) NOT NULL DEFAULT 'S'," +
"`COL2` varchar(20) DEFAULT NULL," +
"`COL4` datetime DEFAULT NULL," +
"`COL3` bigint(20) DEFAULT NULL," +
"`COL5` float DEFAULT NULL," +
"PRIMARY KEY (`COL1`) CLUSTERED)")
tk.MustExec(`prepare stmt from 'SELECT * FROM PK_SNPRE10114 WHERE col1 IN (?, ?, ?) AND (col2 IS NULL OR col2 IN (?, ?)) AND (col3 IS NULL OR col4 IS NULL);';`)
tk.MustExec(`set @a=0x0D5BDAEB79074756F203, @b=NULL, @c=0x6A911AAAC728F1ED3B4F, @d="鏖秿垙麜濇凗辯Ũ卮伄幖轒ƀ漭蝏雓轊恿磔徵", @e="訇廵纹髺釖寒近槩靏詗膦潳陒錃粓悧闒摔)乀";`)
tk.MustExec(`execute stmt using @a,@b,@c,@d,@e;`)
tk.MustExec(`set @a=7775448739068993371, @b=5641728652098016210, @c=6774432238941172824, @d="HqpP5rN", @e="8Fy";`)
tk.MustExec(`execute stmt using @a,@b,@c,@d,@e;`)
tk.MustExec(`set @a=0x61219F79C90D3541F70E, @b=5501707547099269248, @c=0xEC43EFD30131DEA2CB8B, @d="呣丼蒢咿卻鹻铴础湜僂頃dž縍套衞陀碵碼幓9", @e="鹹楞睕堚尛鉌翡佾搁紟精廬姆燵藝潐楻翇慸嵊";`)
tk.MustExec(`execute stmt using @a,@b,@c,@d,@e;`)
}
4 changes: 4 additions & 0 deletions executor/table_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package executor

import (
"bytes"
"context"
"time"

Expand Down Expand Up @@ -309,6 +310,9 @@ func (e *TableReaderExecutor) buildResp(ctx context.Context, ranges []*ranger.Ra
if err != nil {
return nil, err
}
slices.SortFunc(kvReq.KeyRanges, func(i, j kv.KeyRange) bool {
return bytes.Compare(i.StartKey, j.StartKey) < 0
})
e.kvRanges = append(e.kvRanges, kvReq.KeyRanges...)

result, err := e.SelectResult(ctx, e.ctx, kvReq, retTypes(e), e.feedback, getPhysicalPlanIDs(e.plans), e.id)
Expand Down

0 comments on commit 95c7157

Please sign in to comment.