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: generate tableDual when partition pruning failed #26894

Merged
merged 10 commits into from
Aug 17, 2021
11 changes: 11 additions & 0 deletions planner/core/partition_pruner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,3 +488,14 @@ func (s *testPartitionPruneSuit) TestRangePartitionPredicatePruner(c *C) {
tk.MustQuery(tt).Check(testkit.Rows(output[i].Result...))
}
}

func (s *testPartitionPruneSuit) TestIssue26551(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("set @@tidb_partition_prune_mode='static'")
tk.MustExec("USE test;")
tk.MustExec("DROP TABLE IF EXISTS t;")
tk.MustExec("CREATE TABLE t (`COL1` int, `COL3` bigint) PARTITION BY HASH ((`COL1` * `COL3`))PARTITIONS 13;")
tk.MustQuery("explain format = 'brief' SELECT * FROM t WHERE col3 =2659937067964964513 and col1 = 783367513002;").Check(testkit.Rows(
"TableDual 0.00 root rows:0"))
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1690 BIGINT value is out of range in '(test.t.col1 * test.t.col3)'"))
}
3 changes: 2 additions & 1 deletion planner/core/rule_partition_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ func (s *partitionProcessor) processHashPartition(ds *DataSource, pi *model.Part
}
used, err := s.pruneHashPartition(ds.SCtx(), ds.table, ds.partitionNames, ds.allConds, ds.TblCols, names)
if err != nil {
return nil, err
// Just report warning and generate the tableDual
ds.SCtx().GetSessionVars().StmtCtx.AppendWarning(err)
}
if used != nil {
return s.makeUnionAllChildren(ds, pi, convertToRangeOr(used, pi))
Expand Down