Skip to content

Commit

Permalink
expression: fix querying cluster tables reports regexp is not suppo…
Browse files Browse the repository at this point in the history
…rted (#33052)

close #32783
  • Loading branch information
djshow832 authored Mar 16, 2022
1 parent e110e73 commit 93d44e2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
8 changes: 4 additions & 4 deletions expression/distsql_builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
22 changes: 22 additions & 0 deletions expression/distsql_builtin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 6 additions & 0 deletions infoschema/cluster_tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 93d44e2

Please sign in to comment.