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 (pingcap#40313)

close pingcap#40309
  • Loading branch information
winoros authored and ti-chi-bot committed Jan 9, 2023
1 parent 47b5ee4 commit fcb7ddc
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 @@ -637,6 +637,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 @@ -1075,7 +1075,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 @@ -1103,6 +1102,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 fcb7ddc

Please sign in to comment.