Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#40429
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
time-and-fate authored and ti-chi-bot committed Sep 12, 2024
1 parent 337f4a0 commit bdf7581
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions planner/core/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8350,6 +8350,7 @@ func TestAutoIncrementCheckWithCheckConstraint(t *testing.T) {
)`)
}

<<<<<<< HEAD
// https://github.com/pingcap/tidb/issues/41273
func TestIssue41273(t *testing.T) {
store := testkit.CreateMockStore(t)
Expand Down Expand Up @@ -8796,4 +8797,12 @@ FROM (
WHERE res.state != 2
ORDER BY res.branch_id;
`, errno.ErrNotSupportedYet)
=======
func TestIssue40285(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("CREATE TABLE t(col1 enum('p5', '9a33x') NOT NULL DEFAULT 'p5',col2 tinyblob DEFAULT NULL) ENGINE = InnoDB DEFAULT CHARSET = latin1 COLLATE = latin1_bin;")
tk.MustQuery("(select last_value(col1) over () as r0 from t) union all (select col2 as r0 from t);")
>>>>>>> 362defb112d (planner: add nil check when handling empty charset in `setUnionFlen` (#40429))
}
4 changes: 3 additions & 1 deletion planner/core/logical_plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,9 @@ func (*PlanBuilder) setUnionFlen(resultTp *types.FieldType, cols []expression.Ex
childTp := cols[i].GetType()
childTpCharLen := 1
if isBinary {
childTpCharLen = charset.CharacterSetInfos[childTp.GetCharset()].Maxlen
if charsetInfo, ok := charset.CharacterSetInfos[childTp.GetCharset()]; ok {
childTpCharLen = charsetInfo.Maxlen
}
}
resultTp.SetFlen(mathutil.Max(resultTp.GetFlen(), childTpCharLen*childTp.GetFlen()))
}
Expand Down
1 change: 1 addition & 0 deletions planner/core/plan_cost_ver2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ func TestCostModelVer2ScanRowSize(t *testing.T) {
tk.MustExec(`create table t (pk int, a int, b int, c int, d int, primary key(pk), index ab(a, b), index abc(a, b, c))`)
tk.MustExec("insert into t values (1, 1, 1, 1, 1)")
tk.MustExec(`set @@tidb_cost_model_version=2`)
tk.MustExec("set global tidb_enable_collect_execution_info=1;")

cases := []struct {
query string
Expand Down

0 comments on commit bdf7581

Please sign in to comment.