Skip to content

Commit

Permalink
util/types: new Compare implementation with Datum.
Browse files Browse the repository at this point in the history
  • Loading branch information
coocood committed Mar 2, 2016
1 parent b207d1a commit e71e25e
Show file tree
Hide file tree
Showing 11 changed files with 537 additions and 485 deletions.
2 changes: 1 addition & 1 deletion ast/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (dn *dmlNode) dmlStatement() {}
// Expression implementations should embed it in.
type exprNode struct {
node
Datum
types.Datum
Type *types.FieldType
flag uint64
}
Expand Down
4 changes: 2 additions & 2 deletions ast/cloner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ func (ts *testClonerSuite) TestCloner(c *C) {
a3 := a2.(*ValueExpr)
b3 := b2.(*ValueExpr)
c.Assert(a3, Not(Equals), b3)
c.Assert(a3.GetValue(), Equals, true)
c.Assert(b3.GetValue(), Equals, true)
c.Assert(a3.GetValue(), Equals, int64(1))
c.Assert(b3.GetValue(), Equals, int64(1))
}
159 changes: 0 additions & 159 deletions ast/datum.go

This file was deleted.

4 changes: 2 additions & 2 deletions executor/subquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (

var _ ast.SubqueryExec = &subquery{}

// SubQuery is an exprNode with a plan.
// subquery is an exprNode with a plan.
type subquery struct {
ast.Datum
types.Datum
Type *types.FieldType
flag uint64
text string
Expand Down
3 changes: 0 additions & 3 deletions expression/builtin/control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,4 @@ func (s *testBuiltinSuite) TestNullIf(c *C) {
c.Assert(err, IsNil)
c.Assert(v, DeepEquals, t.Ret)
}

_, err := builtinNullIf([]interface{}{errors.New("must error"), 1}, nil)
c.Assert(err, NotNil)
}
4 changes: 2 additions & 2 deletions optimizer/evaluator/evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1013,12 +1013,12 @@ func (s *testEvaluatorSuite) TestUnaryOp(c *C) {
}
ctx := mock.NewContext()
expr := &ast.UnaryOperationExpr{}
for _, t := range tbl {
for i, t := range tbl {
expr.Op = t.op
expr.V = ast.NewValueExpr(t.arg)
result, err := Eval(ctx, expr)
c.Assert(err, IsNil)
c.Assert(result, DeepEquals, t.result)
c.Assert(result, DeepEquals, t.result, Commentf("%d", i))
}

tbl = []struct {
Expand Down
6 changes: 3 additions & 3 deletions optimizer/evaluator/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ func getTimeValue(ctx context.Context, v interface{}, tp byte, fsp int) (interfa
}
case *ast.ValueExpr:
switch x.Kind() {
case ast.KindString:
case types.KindString:
value, err = mysql.ParseTime(x.GetString(), tp, fsp)
if err != nil {
return nil, errors.Trace(err)
}
case ast.KindInt64:
case types.KindInt64:
value, err = mysql.ParseTimeFromNum(x.GetInt64(), tp, fsp)
if err != nil {
return nil, errors.Trace(err)
}
case ast.KindNull:
case types.KindNull:
return nil, nil
default:
return nil, errors.Trace(errDefaultValue)
Expand Down
Loading

0 comments on commit e71e25e

Please sign in to comment.