Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

planner: Fix issue 52198, HandleColOffset was wrong. (#52210) #52213

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions pkg/planner/core/find_best_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -2574,11 +2574,17 @@ func (ds *DataSource) convertToPointGet(prop *property.PhysicalProperty, candida
pointGetPlan.Handle = kv.IntHandle(candidate.path.Ranges[0].LowVal[0].GetInt64())
pointGetPlan.UnsignedHandle = mysql.HasUnsignedFlag(ds.handleCols.GetCol(0).RetType.GetFlag())
pointGetPlan.accessCols = ds.TblCols
hc, err := ds.handleCols.ResolveIndices(ds.schema)
if err != nil {
found := false
for i := range ds.Columns {
if ds.Columns[i].ID == ds.handleCols.GetCol(0).ID {
pointGetPlan.HandleColOffset = ds.Columns[i].Offset
found = true
break
}
}
if !found {
return invalidTask
}
pointGetPlan.HandleColOffset = hc.GetCol(0).Index
// Add filter condition to table plan now.
if len(candidate.path.TableFilters) > 0 {
sel := PhysicalSelection{
Expand Down
6 changes: 6 additions & 0 deletions tests/integrationtest/r/executor/partition/issues.result
Original file line number Diff line number Diff line change
Expand Up @@ -427,3 +427,9 @@ TableReader_7 1.00 root partition:p0,p6 data:Selection_6
select * from t where col_29 between -7 and -6;
col_29
-6
create table issue52198 (a int, b int, primary key (b)) partition by hash(b) partitions 5;
insert into issue52198 values (1,1);
select space(1), b from issue52198 where b in (1);
space(1) b
1
drop table issue52198;
5 changes: 5 additions & 0 deletions tests/integrationtest/t/executor/partition/issues.test
Original file line number Diff line number Diff line change
Expand Up @@ -337,3 +337,8 @@ explain select * from t where col_29 between -7 and -6;
--sorted_result
select * from t where col_29 between -7 and -6;

# TestIssue52198
create table issue52198 (a int, b int, primary key (b)) partition by hash(b) partitions 5;
insert into issue52198 values (1,1);
select space(1), b from issue52198 where b in (1);
drop table issue52198;