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

expression: fix querying cluster tables reports regexp is not supported #33052

Merged
merged 4 commits into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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