diff --git a/expression/function_traits.go b/expression/function_traits.go index db5356f042b80..0965464cf68c0 100644 --- a/expression/function_traits.go +++ b/expression/function_traits.go @@ -40,6 +40,7 @@ var UnCacheableFunctions = map[string]struct{}{ // unFoldableFunctions stores functions which can not be folded duration constant folding stage. var unFoldableFunctions = map[string]struct{}{ + ast.Sysdate: {}, ast.FoundRows: {}, ast.Rand: {}, ast.UUID: {}, diff --git a/expression/function_traits_test.go b/expression/function_traits_test.go new file mode 100644 index 0000000000000..13982d9e85907 --- /dev/null +++ b/expression/function_traits_test.go @@ -0,0 +1,26 @@ +// Copyright 2018 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// See the License for the specific language governing permissions and +// limitations under the License. + +package expression + +import ( + . "github.com/pingcap/check" + "github.com/pingcap/tidb/ast" + "github.com/pingcap/tidb/util/testleak" +) + +func (s *testEvaluatorSuite) TestUnfoldableFuncs(c *C) { + defer testleak.AfterTest(c)() + _, ok := unFoldableFunctions[ast.Sysdate] + c.Assert(ok, IsTrue) +}