Skip to content

Commit

Permalink
evaluator: Check function call min and max arguments in new evaluator.
Browse files Browse the repository at this point in the history
For github issue pingcap#758.
  • Loading branch information
chenyanzhe committed Dec 20, 2015
1 parent 60ec9fc commit a5b5fd6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion expression/builtin/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ var Funcs = map[string]Func{
"curdate": {builtinCurrentDate, 0, 0, false, false},
"current_date": {builtinCurrentDate, 0, 0, false, false},
"current_timestamp": {builtinNow, 0, 1, false, false},
"date": {builtinDate, 8, 8, true, false},
"date": {builtinDate, 1, 1, true, false},
"day": {builtinDay, 1, 1, true, false},
"dayofmonth": {builtinDayOfMonth, 1, 1, true, false},
"dayofweek": {builtinDayOfWeek, 1, 1, true, false},
Expand Down
4 changes: 4 additions & 0 deletions optimizer/evaluator/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,10 @@ func (e *Evaluator) funcCall(v *ast.FuncCallExpr) bool {
e.err = ErrInvalidOperation.Gen("unknown function %s", v.FnName.O)
return false
}
if len(v.Args) < f.MinArgs || len(v.Args) > f.MaxArgs {
e.err = ErrInvalidOperation.Gen("number of function arguments must in [%d, %d].", f.MinArgs, f.MaxArgs)
return false
}
a := make([]interface{}, len(v.Args))
for i, arg := range v.Args {
a[i] = arg.GetValue()
Expand Down

0 comments on commit a5b5fd6

Please sign in to comment.