Skip to content

Commit

Permalink
expression: make sysdate unfoldable (#7838) (#7894)
Browse files Browse the repository at this point in the history
  • Loading branch information
zz-jason authored Oct 15, 2018
1 parent 44cb05f commit 2af0f18
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions expression/function_traits.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: {},
Expand Down
26 changes: 26 additions & 0 deletions expression/function_traits_test.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 2af0f18

Please sign in to comment.