Skip to content

Commit

Permalink
planner, executor: split the range for unsigned pk of partition table…
Browse files Browse the repository at this point in the history
… when limit is used (#40313)

close #40309
  • Loading branch information
winoros authored Jan 9, 2023
1 parent 7dbf1a5 commit 0f838d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions executor/partition_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,17 @@ func TestOrderByAndLimit(t *testing.T) {
}
}

func TestOrderByOnUnsignedPk(t *testing.T) {
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table tunsigned_hash(a bigint unsigned primary key) partition by hash(a) partitions 6")
tk.MustExec("insert into tunsigned_hash values(25), (9279808998424041135)")
tk.MustQuery("select min(a) from tunsigned_hash").Check(testkit.Rows("25"))
tk.MustQuery("select max(a) from tunsigned_hash").Check(testkit.Rows("9279808998424041135"))
}

func TestBatchGetandPointGetwithHashPartition(t *testing.T) {
store := testkit.CreateMockStore(t)

Expand Down
3 changes: 2 additions & 1 deletion planner/core/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,6 @@ func (p *PhysicalTopN) pushTopNDownToDynamicPartition(copTsk *copTask) (task, bo
if !propMatched {
return nil, false
}

idxScan.Desc = isDesc
childProfile := copTsk.plan().statsInfo()
newCount := p.Offset + p.Count
Expand Down Expand Up @@ -1100,6 +1099,8 @@ func (p *PhysicalTopN) pushTopNDownToDynamicPartition(copTsk *copTask) (task, bo
}
}
tblScan.Desc = isDesc
// SplitRangesAcrossInt64Boundary needs the KeepOrder flag. See that func and the struct tableResultHandler for more details.
tblScan.KeepOrder = true
childProfile := copTsk.plan().statsInfo()
newCount := p.Offset + p.Count
stats := deriveLimitStats(childProfile, float64(newCount))
Expand Down

0 comments on commit 0f838d9

Please sign in to comment.