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: make sysdate unfoldable (#7838) #7895

Merged
merged 1 commit into from
Oct 15, 2018
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
4 changes: 4 additions & 0 deletions cmd/explaintest/r/select.result
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,7 @@ Point_Get_1 1.00 root table:t, handle:1
desc select * from t where a = '1';
id count task operator info
Point_Get_1 1.00 root table:t, handle:1
desc select sysdate(), sleep(1), sysdate();
id count task operator info
Projection_3 1.00 root sysdate(), sleep(1), sysdate()
└─TableDual_4 1.00 root rows:1
2 changes: 2 additions & 0 deletions cmd/explaintest/t/select.test
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,5 @@ drop table if exists t;
create table t(a bigint primary key, b bigint);
desc select * from t where a = 1;
desc select * from t where a = '1';

desc select sysdate(), sleep(1), sysdate();
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)
}