app/vmselect/promql: validate function name before evaluating its arguments

This avoids unneeded evaluation of args for unknown functions
This commit is contained in:
Aliaksandr Valialkin 2022-07-12 19:48:24 +03:00
parent 17b5ac1608
commit c2197ad139
No known key found for this signature in database
GPG Key ID: A72BEC6CD3D0DED1

View File

@ -292,14 +292,14 @@ func evalExprInternal(qt *querytracer.Tracer, ec *EvalConfig, e metricsql.Expr)
}
func evalTransformFunc(qt *querytracer.Tracer, ec *EvalConfig, fe *metricsql.FuncExpr) ([]*timeseries, error) {
args, err := evalExprs(qt, ec, fe.Args)
if err != nil {
return nil, err
}
tf := getTransformFunc(fe.Name)
if tf == nil {
return nil, fmt.Errorf(`unknown func %q`, fe.Name)
}
args, err := evalExprs(qt, ec, fe.Args)
if err != nil {
return nil, err
}
tfa := &transformFuncArg{
ec: ec,
fe: fe,