diff --git a/expression/distsql_builtin.go b/expression/distsql_builtin.go index 8d2c2ad4d7826..5f344cbad8478 100644 --- a/expression/distsql_builtin.go +++ b/expression/distsql_builtin.go @@ -668,10 +668,10 @@ func getSignatureByPB(ctx sessionctx.Context, sigCode tipb.ScalarFuncSig, tp *ti f = &builtinUUIDSig{base} case tipb.ScalarFuncSig_LikeSig: f = &builtinLikeSig{base, nil, false, sync.Once{}} - // case tipb.ScalarFuncSig_RegexpSig: - // f = &builtinRegexpSig{base} - // case tipb.ScalarFuncSig_RegexpUTF8Sig: - // f = &builtinRegexpUTF8Sig{base} + case tipb.ScalarFuncSig_RegexpSig: + f = newBuiltinRegexpSig(base) + case tipb.ScalarFuncSig_RegexpUTF8Sig: + f = newBuiltinRegexpUTF8Sig(base) case tipb.ScalarFuncSig_JsonExtractSig: f = &builtinJSONExtractSig{base} case tipb.ScalarFuncSig_JsonUnquoteSig: diff --git a/expression/distsql_builtin_test.go b/expression/distsql_builtin_test.go index 26f47169e9098..7cb7cc972b029 100644 --- a/expression/distsql_builtin_test.go +++ b/expression/distsql_builtin_test.go @@ -847,6 +847,28 @@ func TestPBToExprWithNewCollation(t *testing.T) { } } +// Test convert various scalar functions. +func TestPBToScalarFuncExpr(t *testing.T) { + sc := new(stmtctx.StatementContext) + fieldTps := make([]*types.FieldType, 1) + exprs := []*tipb.Expr{ + { + Tp: tipb.ExprType_ScalarFunc, + Sig: tipb.ScalarFuncSig_RegexpSig, + FieldType: ToPBFieldType(newStringFieldType()), + }, + { + Tp: tipb.ExprType_ScalarFunc, + Sig: tipb.ScalarFuncSig_RegexpUTF8Sig, + FieldType: ToPBFieldType(newStringFieldType()), + }, + } + for _, expr := range exprs { + _, err := PBToExpr(expr, fieldTps, sc) + require.NoError(t, err) + } +} + func datumExpr(t *testing.T, d types.Datum) *tipb.Expr { expr := new(tipb.Expr) switch d.Kind() { diff --git a/infoschema/cluster_tables_test.go b/infoschema/cluster_tables_test.go index da4432ddb2c8e..86d886886b3f1 100644 --- a/infoschema/cluster_tables_test.go +++ b/infoschema/cluster_tables_test.go @@ -245,6 +245,12 @@ func TestSelectClusterTable(t *testing.T) { re := tk.MustQuery("select * from `CLUSTER_statements_summary`") require.NotNil(t, re) require.Greater(t, len(re.Rows()), 0) + re = tk.MustQuery("select * from `CLUSTER_statements_summary` where table_names REGEXP '\\binformation_schema\\.'") + require.NotNil(t, re) + require.Equal(t, len(re.Rows()), 0) + re = tk.MustQuery("select * from `CLUSTER_statements_summary` where table_names REGEXP 'information_schema\\.'") + require.NotNil(t, re) + require.Greater(t, len(re.Rows()), 0) // Test for TiDB issue 14915. re = tk.MustQuery("select sum(exec_count*avg_mem) from cluster_statements_summary_history group by schema_name,digest,digest_text;") require.NotNil(t, re)