Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix conflict
Browse files Browse the repository at this point in the history
Damon Zhao committed Mar 17, 2017

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 3d4aa55 + aa92604 commit cc441fa
Showing 11 changed files with 52 additions and 20 deletions.
2 changes: 1 addition & 1 deletion docs/QUICKSTART.md
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ Read the documents for [binary deployment](https://github.com/pingcap/docs/blob/

#### __Pre-requirement__

Go environment. Currently a 64-bit version of go >= 1.5 is required.
Go environment. Currently a 64-bit version of go >= 1.7 is required.
```
git clone https://github.com/pingcap/tidb.git $GOPATH/src/github.com/pingcap/tidb
cd $GOPATH/src/github.com/pingcap/tidb
3 changes: 0 additions & 3 deletions executor/analyze_test.go
Original file line number Diff line number Diff line change
@@ -18,16 +18,13 @@ import (
"strings"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/plan"
"github.com/pingcap/tidb/util/testkit"
"github.com/pingcap/tidb/util/testleak"
)

func (s *testSuite) TestAnalyzeTable(c *C) {
plan.EnableStatistic = true
defer func() {
testleak.AfterTest(c)()
plan.EnableStatistic = false
}()
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
18 changes: 17 additions & 1 deletion expression/builtin_math.go
Original file line number Diff line number Diff line change
@@ -869,7 +869,23 @@ type builtinExpSig struct {

// See https://dev.mysql.com/doc/refman/5.7/en/mathematical-functions.html#function_exp
func (b *builtinExpSig) eval(row []types.Datum) (d types.Datum, err error) {
return d, errFunctionNotExists.GenByArgs("exp")
args, err := b.evalArgs(row)
if err != nil {
return d, errors.Trace(err)
}

arg := args[0]
if arg.IsNull() {
return d, nil
}

num, err := arg.ToFloat64(b.ctx.GetSessionVars().StmtCtx)
if err != nil {
return d, errors.Trace(err)
}

d.SetFloat64(math.Exp(num))
return d, nil
}

type piFunctionClass struct {
28 changes: 28 additions & 0 deletions expression/builtin_math_test.go
Original file line number Diff line number Diff line change
@@ -75,6 +75,34 @@ func (s *testEvaluatorSuite) TestCeil(c *C) {
}
}

func (s *testEvaluatorSuite) TestExp(c *C) {
defer testleak.AfterTest(c)()
for _, t := range []struct {
num interface{}
ret interface{}
err Checker
}{
{int64(1), float64(2.718281828459045), IsNil},
{float64(1.23), float64(3.4212295362896734), IsNil},
{float64(-1.23), float64(0.2922925776808594), IsNil},
{float64(-1), float64(0.36787944117144233), IsNil},
{float64(0), float64(1), IsNil},
{"1.23", float64(3.4212295362896734), IsNil},
{"-1.23", float64(0.2922925776808594), IsNil},
{"0", float64(1), IsNil},
{nil, nil, IsNil},
{"abce", nil, NotNil},
{"", nil, NotNil},
} {
fc := funcs[ast.Exp]
f, err := fc.getFunction(datumsToConstants(types.MakeDatums(t.num)), s.ctx)
c.Assert(err, IsNil)
v, err := f.eval(nil)
c.Assert(err, t.err)
c.Assert(v, testutil.DatumEquals, types.NewDatum(t.ret))
}
}

func (s *testEvaluatorSuite) TestFloor(c *C) {
defer testleak.AfterTest(c)()
for _, t := range []struct {
1 change: 1 addition & 0 deletions expression/builtin_string_test.go
Original file line number Diff line number Diff line change
@@ -1005,6 +1005,7 @@ func (s *testEvaluatorSuite) TestMakeSet(c *C) {
f, err := fc.getFunction(datumsToConstants(types.MakeDatums(t.argList...)), s.ctx)
c.Assert(err, IsNil)
r, err := f.eval(nil)
c.Assert(err, IsNil)
c.Assert(r, testutil.DatumEquals, types.NewDatum(t.ret))
}
}
2 changes: 0 additions & 2 deletions plan/analyze_test.go
Original file line number Diff line number Diff line change
@@ -29,10 +29,8 @@ type testAnalyzeSuite struct {
}

func (s *testAnalyzeSuite) TestAnalyze(c *C) {
plan.EnableStatistic = true
defer func() {
testleak.AfterTest(c)()
plan.EnableStatistic = false
}()
store, err := newStoreWithBootstrap()
c.Assert(err, IsNil)
8 changes: 1 addition & 7 deletions plan/logical_plan_builder.go
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@ import (
"github.com/pingcap/tidb/expression"
"github.com/pingcap/tidb/model"
"github.com/pingcap/tidb/mysql"
"github.com/pingcap/tidb/plan/statistics"
"github.com/pingcap/tidb/plan/statscache"
"github.com/pingcap/tidb/sessionctx/variable"
"github.com/pingcap/tidb/util/types"
@@ -928,12 +927,7 @@ func (b *planBuilder) buildTableDual() LogicalPlan {
}

func (b *planBuilder) buildDataSource(tn *ast.TableName) LogicalPlan {
var statisticTable *statistics.Table
if EnableStatistic {
statisticTable = statscache.GetStatisticsTableCache(tn.TableInfo)
} else {
statisticTable = statistics.PseudoTable(tn.TableInfo)
}
statisticTable := statscache.GetStatisticsTableCache(tn.TableInfo)
if b.err != nil {
return nil
}
3 changes: 0 additions & 3 deletions plan/optimizer.go
Original file line number Diff line number Diff line change
@@ -27,9 +27,6 @@ import (
// AllowCartesianProduct means whether tidb allows cartesian join without equal conditions.
var AllowCartesianProduct = true

// EnableStatistic means whether tidb uses the statistic information to do cost-based optimization.
var EnableStatistic = false

const (
flagPrunColumns uint64 = 1 << iota
flagBuildKeyInfo
2 changes: 1 addition & 1 deletion plan/typeinferer.go
Original file line number Diff line number Diff line change
@@ -342,7 +342,7 @@ func (v *typeInferrer) handleFuncCallExpr(x *ast.FuncCallExpr) {
} else {
tp = types.NewFieldType(mysql.TypeLonglong)
}
case "ln", "log", "log2", "log10", "sqrt":
case "ln", "log", "log2", "log10", "sqrt", ast.Exp:
tp = types.NewFieldType(mysql.TypeDouble)
case "acos", "asin", "atan":
tp = types.NewFieldType(mysql.TypeDouble)
3 changes: 3 additions & 0 deletions plan/typeinferer_test.go
Original file line number Diff line number Diff line change
@@ -247,6 +247,9 @@ func (ts *testTypeInferrerSuite) TestInferType(c *C) {
{`coalesce(1, "1" + 1)`, mysql.TypeDouble, charset.CharsetBin},
{`coalesce(1, "abc")`, mysql.TypeVarString, charset.CharsetUTF8},
{`make_set(1 | 3, "hello", "nice", null, "world")`, mysql.TypeVarString, charset.CharsetUTF8},
{`exp(1)`, mysql.TypeDouble, charset.CharsetBin},
{`exp(1.23)`, mysql.TypeDouble, charset.CharsetBin},
{`exp('1.23')`, mysql.TypeDouble, charset.CharsetBin},
}
for _, ca := range cases {
ctx := testKit.Se.(context.Context)
2 changes: 0 additions & 2 deletions tidb-server/main.go
Original file line number Diff line number Diff line change
@@ -59,7 +59,6 @@ var (
logFile = flag.String("log-file", "", "log file path")
joinCon = flag.Int("join-concurrency", 5, "the number of goroutines that participate joining.")
crossJoin = flag.Bool("cross-join", true, "whether support cartesian product or not.")
enableStatistic = flag.Bool("enable-statistic", false, "whether we do cost-based optimization with statistic info or not.")
metricsAddr = flag.String("metrics-addr", "", "prometheus pushgateway address, leaves it empty will disable prometheus push.")
metricsInterval = flag.Int("metrics-interval", 15, "prometheus client push interval in second, set \"0\" to disable prometheus push.")
binlogSocket = flag.String("binlog-socket", "", "socket file to write binlog")
@@ -114,7 +113,6 @@ func main() {
plan.JoinConcurrency = *joinCon
}
plan.AllowCartesianProduct = *crossJoin
plan.EnableStatistic = *enableStatistic
// Call this before setting log level to make sure that TiDB info could be printed.
printer.PrintTiDBInfo()
log.SetLevelByString(cfg.LogLevel)

0 comments on commit cc441fa

Please sign in to comment.