diff --git a/expression/builtin_string_vec.go b/expression/builtin_string_vec.go index 5f51caefa7fec..62c123faf07bd 100644 --- a/expression/builtin_string_vec.go +++ b/expression/builtin_string_vec.go @@ -2287,7 +2287,6 @@ func (b *builtinCharSig) vecEvalString(input *chunk.Chunk, result *chunk.Column) bigints = bigints[0:0] for j := 0; j < l-1; j++ { if buf[j].IsNull(i) { - result.AppendNull() continue } bigints = append(bigints, bufint[j][i]) diff --git a/expression/builtin_string_vec_test.go b/expression/builtin_string_vec_test.go index fdb7868ccb2fd..13bfb384e10ea 100644 --- a/expression/builtin_string_vec_test.go +++ b/expression/builtin_string_vec_test.go @@ -330,6 +330,12 @@ var vecBuiltinStringCases = map[string][]vecExprBenchCase{ geners: []dataGenerator{&charInt64Gener{}, &charInt64Gener{}, &charInt64Gener{}, nil}, constants: []*Constant{nil, nil, nil, {Value: types.NewDatum("ascii"), RetType: types.NewFieldType(mysql.TypeString)}}, }, + { + retEvalType: types.ETString, + childrenTypes: []types.EvalType{types.ETInt, types.ETInt, types.ETInt, types.ETString}, + geners: []dataGenerator{&charInt64Gener{}, nil, &charInt64Gener{}, nil}, + constants: []*Constant{nil, nil, nil, {Value: types.NewDatum("ascii"), RetType: types.NewFieldType(mysql.TypeString)}}, + }, }, ast.FindInSet: { {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETString}}, diff --git a/expression/integration_test.go b/expression/integration_test.go index d3c561e3340b4..7f01c659c126d 100644 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -10649,6 +10649,18 @@ func (s *testIntegrationSuite) TestIssue29513(c *C) { tk.MustQuery("select '123' union select cast(a as char(2)) from t;").Sort().Check(testkit.Rows("123", "45")) } +func (s *testIntegrationSuite) TestIssue29755(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("use test") + + tk.MustExec("set tidb_enable_vectorized_expression = on;") + tk.MustQuery("select char(123, NULL, 123)").Check(testkit.Rows("{{")) + tk.MustQuery("select char(NULL, 123, 123)").Check(testkit.Rows("{{")) + tk.MustExec("set tidb_enable_vectorized_expression = off;") + tk.MustQuery("select char(123, NULL, 123)").Check(testkit.Rows("{{")) + tk.MustQuery("select char(NULL, 123, 123)").Check(testkit.Rows("{{")) +} + func (s *testIntegrationSuite) TestIssue30101(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test")