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

Pass go vet #16

Merged
merged 4 commits into from
Sep 6, 2015
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
2 changes: 1 addition & 1 deletion domain/domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type testSuite struct {
}

func (*testSuite) TestT(c *C) {
driver := localstore.Driver{goleveldb.MemoryDriver{}}
driver := localstore.Driver{Driver: goleveldb.MemoryDriver{}}
store, err := driver.Open("memory")
c.Assert(err, IsNil)
defer store.Close()
Expand Down
6 changes: 3 additions & 3 deletions expression/expressions/binop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ func (s *testBinOpSuite) TestComparisonOp(c *C) {
{"1", float64(2), -1},
{"1", uint64(1), 0},
{"1", mysql.NewDecimalFromInt(1, 0), 0},
{"2011-01-01 11:11:11", mysql.Time{time.Now(), mysql.TypeDatetime, 0}, -1},
{"2011-01-01 11:11:11", mysql.Time{Time: time.Now(), Type: mysql.TypeDatetime, Fsp: 0}, -1},
{"12:00:00", mysql.ZeroDuration, 1},
{mysql.ZeroDuration, mysql.ZeroDuration, 0},
{mysql.Time{time.Now().Add(time.Second * 10), mysql.TypeDatetime, 0},
mysql.Time{time.Now(), mysql.TypeDatetime, 0}, 1},
{mysql.Time{Time: time.Now().Add(time.Second * 10), Type: mysql.TypeDatetime, Fsp: 0},
mysql.Time{Time: time.Now(), Type: mysql.TypeDatetime, Fsp: 0}, 1},
}

for _, t := range cmpTbl {
Expand Down
7 changes: 4 additions & 3 deletions expression/expressions/unary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,13 @@ func (s *testUnaryOperationSuite) TestUnaryOp(c *C) {
result interface{}
}{
{mysql.NewDecimalFromInt(1, 0), opcode.Plus, mysql.NewDecimalFromInt(1, 0)},
{mysql.Duration{time.Duration(838*3600 + 59*60 + 59), mysql.DefaultFsp}, opcode.Plus, mysql.Duration{time.Duration(838*3600 + 59*60 + 59), mysql.DefaultFsp}},
{mysql.Time{time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC), mysql.TypeDatetime, 0}, opcode.Plus, mysql.Time{time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC), mysql.TypeDatetime, 0}},
{mysql.Duration{Duration: time.Duration(838*3600 + 59*60 + 59), Fsp: mysql.DefaultFsp}, opcode.Plus,
mysql.Duration{Duration: time.Duration(838*3600 + 59*60 + 59), Fsp: mysql.DefaultFsp}},
{mysql.Time{Time: time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC), Type: mysql.TypeDatetime, Fsp: 0}, opcode.Plus, mysql.Time{Time: time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC), Type: mysql.TypeDatetime, Fsp: 0}},

{mysql.NewDecimalFromInt(1, 0), opcode.Minus, mysql.NewDecimalFromInt(-1, 0)},
{mysql.ZeroDuration, opcode.Minus, mysql.NewDecimalFromInt(0, 0)},
{mysql.Time{time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC), mysql.TypeDatetime, 0}, opcode.Minus, mysql.NewDecimalFromInt(-20091110230000, 0)},
{mysql.Time{Time: time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC), Type: mysql.TypeDatetime, Fsp: 0}, opcode.Minus, mysql.NewDecimalFromInt(-20091110230000, 0)},
}

for _, t := range tbl {
Expand Down
10 changes: 5 additions & 5 deletions field/result_field_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type testResultFieldSuite struct {

func (*testResultFieldSuite) TestMain(c *C) {
col := column.Col{
model.ColumnInfo{
ColumnInfo: model.ColumnInfo{
FieldType: *types.NewFieldType(mysql.TypeLong),
Name: model.NewCIStr("c1"),
},
Expand All @@ -53,7 +53,7 @@ func (*testResultFieldSuite) TestMain(c *C) {
c.Assert(r.String(), Equals, cr.String())

col1 := column.Col{
model.ColumnInfo{
ColumnInfo: model.ColumnInfo{
FieldType: *types.NewFieldType(mysql.TypeLong),
Name: model.NewCIStr("c2"),
},
Expand All @@ -75,14 +75,14 @@ func (*testResultFieldSuite) TestMain(c *C) {
c.Assert(ns[1], Equals, "\"c2\"")

col2 := column.Col{
model.ColumnInfo{
ColumnInfo: model.ColumnInfo{
FieldType: *types.NewFieldType(mysql.TypeVarchar),
Name: model.NewCIStr("c3"),
},
}
col2.Flag |= mysql.UnsignedFlag
col3 := column.Col{
model.ColumnInfo{
ColumnInfo: model.ColumnInfo{
FieldType: *types.NewFieldType(mysql.TypeBlob),
Name: model.NewCIStr("c4"),
},
Expand All @@ -100,7 +100,7 @@ func (*testResultFieldSuite) TestMain(c *C) {
c.Assert(err, IsNil)

col4 := column.Col{
model.ColumnInfo{
ColumnInfo: model.ColumnInfo{
FieldType: *types.NewFieldType(mysql.TypeVarchar),
Name: model.NewCIStr("c2"),
},
Expand Down
2 changes: 1 addition & 1 deletion infoschema/infoschema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type testSuite struct {
func (*testSuite) TestT(c *C) {
table.TableFromMeta = tables.TableFromMeta

driver := localstore.Driver{goleveldb.MemoryDriver{}}
driver := localstore.Driver{Driver: goleveldb.MemoryDriver{}}
store, err := driver.Open("memory")
c.Assert(err, IsNil)
defer store.Close()
Expand Down
2 changes: 1 addition & 1 deletion meta/autoid/autoid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type testSuite struct {
}

func (*testSuite) TestT(c *C) {
driver := localstore.Driver{goleveldb.MemoryDriver{}}
driver := localstore.Driver{Driver: goleveldb.MemoryDriver{}}
store, err := driver.Open("memory")
c.Assert(err, IsNil)
defer store.Close()
Expand Down
2 changes: 1 addition & 1 deletion meta/meta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type testSuite struct {
}

func (*testSuite) TestT(c *C) {
driver := localstore.Driver{goleveldb.MemoryDriver{}}
driver := localstore.Driver{Driver: goleveldb.MemoryDriver{}}
store, err := driver.Open("memory")
c.Assert(err, IsNil)
defer store.Close()
Expand Down
2 changes: 1 addition & 1 deletion parser/coldef/col_def.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func checkDefaultValue(c *column.Col, hasDefaultValue bool) error {
func ColumnDefToCol(offset int, colDef *ColumnDef) (*column.Col, []*TableConstraint, error) {
constraints := []*TableConstraint{}
col := &column.Col{
model.ColumnInfo{
ColumnInfo: model.ColumnInfo{
Offset: offset,
Name: model.NewCIStr(colDef.Name),
FieldType: *colDef.Tp,
Expand Down
2 changes: 1 addition & 1 deletion plan/plans/from_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (p *testFromSuit) TestTableDefaultPlan(c *C) {
p.tbl.AddIndex(idxCol)

expr4 := &expressions.Ident{
model.NewCIStr("id"),
CIStr: model.NewCIStr("id"),
}
_, filtered, err = pln.FilterForUpdateAndDelete(p, expr4)
c.Assert(err, IsNil)
Expand Down
2 changes: 1 addition & 1 deletion plan/plans/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (p *testIndexSuit) TestIndexPlan(c *C) {
}

expr5 := &expressions.Ident{
model.NewCIStr("id"),
CIStr: model.NewCIStr("id"),
}

np, _, err := pln.Filter(p, expr)
Expand Down
8 changes: 4 additions & 4 deletions plan/plans/join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (s *testJoinSuit) TestJoin(c *C) {
Right: tblPlan2,
Type: "CROSS",
Fields: []*field.ResultField{},
On: expressions.Value{true},
On: expressions.Value{Val: true},
}

joinPlan.Do(nil, func(id interface{}, data []interface{}) (bool, error) {
Expand All @@ -88,7 +88,7 @@ func (s *testJoinSuit) TestJoin(c *C) {
Right: tblPlan2,
Type: "LEFT",
Fields: []*field.ResultField{},
On: expressions.Value{true},
On: expressions.Value{Val: true},
}

joinPlan.Do(nil, func(id interface{}, data []interface{}) (bool, error) {
Expand All @@ -100,7 +100,7 @@ func (s *testJoinSuit) TestJoin(c *C) {
Right: tblPlan2,
Type: "RIGHT",
Fields: []*field.ResultField{},
On: expressions.Value{true},
On: expressions.Value{Val: true},
}

expr := &expressions.BinaryOperation{
Expand All @@ -125,7 +125,7 @@ func (s *testJoinSuit) TestJoin(c *C) {
Right: tblPlan2,
Type: "FULL",
Fields: []*field.ResultField{},
On: expressions.Value{true},
On: expressions.Value{Val: true},
}

joinPlan.Do(nil, func(id interface{}, data []interface{}) (bool, error) {
Expand Down
2 changes: 1 addition & 1 deletion plan/plans/orderby_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (t *testOrderBySuit) TestOrderBy(c *C) {
Src: tblPlan,
By: []expression.Expression{
&expressions.Ident{
model.NewCIStr("id"),
CIStr: model.NewCIStr("id"),
},
},
Ascs: []bool{false},
Expand Down
2 changes: 1 addition & 1 deletion rset/rsets/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (r *SelectFieldsRset) Plan(ctx context.Context) (plan.Plan, error) {
}
}
if isConst {
src = &plans.TableNilPlan{x.T}
src = &plans.TableNilPlan{T: x.T}
}
}

Expand Down
25 changes: 13 additions & 12 deletions rset/rsets/groupby_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (s *testGroupByRsetSuite) SetUpSuite(c *C) {
Fields: fields,
}

by := []expression.Expression{&expressions.Ident{model.NewCIStr("name")}}
by := []expression.Expression{&expressions.Ident{CIStr: model.NewCIStr("name")}}

s.r = &GroupByRset{Src: tblPlan, SelectList: selectList, By: by}
}
Expand All @@ -60,42 +60,42 @@ func (s *testGroupByRsetSuite) TestGroupByRsetPlan(c *C) {
c.Assert(ok, IsTrue)

// `select id, name from t group by abc`
s.r.By[0] = expressions.Value{"abc"}
s.r.By[0] = expressions.Value{Val: "abc"}

_, err = s.r.Plan(nil)
c.Assert(err, IsNil)

// `select id, name from t group by 1`
s.r.By[0] = expressions.Value{int64(1)}
s.r.By[0] = expressions.Value{Val: int64(1)}

_, err = s.r.Plan(nil)
c.Assert(err, IsNil)

s.r.By[0] = expressions.Value{uint64(1)}
s.r.By[0] = expressions.Value{Val: uint64(1)}

_, err = s.r.Plan(nil)
c.Assert(err, IsNil)

// `select id, name from t group by 0`
s.r.By[0] = expressions.Value{int64(0)}
s.r.By[0] = expressions.Value{Val: int64(0)}

_, err = s.r.Plan(nil)
c.Assert(err, NotNil)

fldExpr, err := expressions.NewCall("count", []expression.Expression{expressions.Value{1}}, false)
fldExpr, err := expressions.NewCall("count", []expression.Expression{expressions.Value{Val: 1}}, false)
c.Assert(err, IsNil)

// `select count(1) as a, name from t group by 1`
fld := &field.Field{Expr: fldExpr, Name: "a"}
s.r.SelectList.Fields[0] = fld

s.r.By[0] = expressions.Value{int64(1)}
s.r.By[0] = expressions.Value{Val: int64(1)}

_, err = s.r.Plan(nil)
c.Assert(err, NotNil)

// check ambiguous field, like `select id as name, name from t group by name`
s.r.By[0] = &expressions.Ident{model.NewCIStr("name")}
s.r.By[0] = &expressions.Ident{CIStr: model.NewCIStr("name")}

fldx := &field.Field{Expr: &expressions.Ident{CIStr: model.NewCIStr("id")}, Name: "name"}
fldy := &field.Field{Expr: &expressions.Ident{CIStr: model.NewCIStr("name")}, Name: "name"}
Expand All @@ -108,7 +108,7 @@ func (s *testGroupByRsetSuite) TestGroupByRsetPlan(c *C) {
c.Assert(err, NotNil)

// check aggregate function reference, like `select count(1) as a, name from t group by a + 1`
expr := expressions.NewBinaryOperation(opcode.Plus, &expressions.Ident{model.NewCIStr("a")}, expressions.Value{1})
expr := expressions.NewBinaryOperation(opcode.Plus, &expressions.Ident{CIStr: model.NewCIStr("a")}, expressions.Value{Val: 1})

s.r.By[0] = expr

Expand Down Expand Up @@ -145,9 +145,10 @@ func (s *testGroupByRsetSuite) TestGroupByHasAmbiguousField(c *C) {
c.Assert(ret, IsFalse)

// check `c1+c2 as c2, c1+c3 as c2`
exprx := expressions.NewBinaryOperation(opcode.Plus, expressions.Value{"c1"}, expressions.Value{"c2"})

expry := expressions.NewBinaryOperation(opcode.Plus, expressions.Value{"c1"}, expressions.Value{"c3"})
exprx := expressions.NewBinaryOperation(opcode.Plus, expressions.Value{Val: "c1"},
expressions.Value{Val: "c2"})
expry := expressions.NewBinaryOperation(opcode.Plus, expressions.Value{Val: "c1"},
expressions.Value{Val: "c3"})

fldx := &field.Field{Expr: exprx, Name: "c2"}
fldy := &field.Field{Expr: expry, Name: "c2"}
Expand Down
12 changes: 6 additions & 6 deletions rset/rsets/having_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (s *testHavingRsetSuite) SetUpSuite(c *C) {
tblPlan := newTestTablePlan(testData, names)

// expr `id > 1`
expr := expressions.NewBinaryOperation(opcode.GT, &expressions.Ident{model.NewCIStr("id")}, expressions.Value{1})
expr := expressions.NewBinaryOperation(opcode.GT, &expressions.Ident{CIStr: model.NewCIStr("id")}, expressions.Value{Val: 1})

s.r = &HavingRset{Src: tblPlan, Expr: expr}
}
Expand Down Expand Up @@ -64,19 +64,19 @@ func (s *testHavingRsetSuite) TestHavingRsetCheckAndUpdateSelectList(c *C) {
selectList.ResultFields = selectList.ResultFields[1:]
selectList.Fields = selectList.Fields[1:]

groupBy = []expression.Expression{&expressions.Ident{model.NewCIStr("id")}}
groupBy = []expression.Expression{&expressions.Ident{CIStr: model.NewCIStr("id")}}
err = s.r.CheckAndUpdateSelectList(selectList, groupBy, resultFields)
c.Assert(err, IsNil)

// `select name from t group by id + 1 having id > 1`
expr := expressions.NewBinaryOperation(opcode.Plus, &expressions.Ident{model.NewCIStr("id")}, expressions.Value{1})
expr := expressions.NewBinaryOperation(opcode.Plus, &expressions.Ident{CIStr: model.NewCIStr("id")}, expressions.Value{Val: 1})

groupBy = []expression.Expression{expr}
err = s.r.CheckAndUpdateSelectList(selectList, groupBy, resultFields)
c.Assert(err, IsNil)

// `select name from t group by id + 1 having count(1) > 1`
aggExpr, err := expressions.NewCall("count", []expression.Expression{expressions.Value{1}}, false)
aggExpr, err := expressions.NewCall("count", []expression.Expression{expressions.Value{Val: 1}}, false)
c.Assert(err, IsNil)

s.r.Expr = aggExpr
Expand All @@ -85,7 +85,7 @@ func (s *testHavingRsetSuite) TestHavingRsetCheckAndUpdateSelectList(c *C) {
c.Assert(err, IsNil)

// `select name from t group by id + 1 having count(xxx) > 1`
aggExpr, err = expressions.NewCall("count", []expression.Expression{&expressions.Ident{model.NewCIStr("xxx")}}, false)
aggExpr, err = expressions.NewCall("count", []expression.Expression{&expressions.Ident{CIStr: model.NewCIStr("xxx")}}, false)
c.Assert(err, IsNil)

s.r.Expr = aggExpr
Expand All @@ -94,7 +94,7 @@ func (s *testHavingRsetSuite) TestHavingRsetCheckAndUpdateSelectList(c *C) {
c.Assert(err, NotNil)

// `select name from t group by id having xxx > 1`
expr = expressions.NewBinaryOperation(opcode.GT, &expressions.Ident{model.NewCIStr("xxx")}, expressions.Value{1})
expr = expressions.NewBinaryOperation(opcode.GT, &expressions.Ident{CIStr: model.NewCIStr("xxx")}, expressions.Value{Val: 1})

s.r.Expr = expr

Expand Down
2 changes: 1 addition & 1 deletion rset/rsets/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type testHelperSuite struct {

func (s *testHelperSuite) SetUpSuite(c *C) {
fldx := &field.Field{Expr: &expressions.Ident{CIStr: model.NewCIStr("name")}, Name: "a"}
expr, err := expressions.NewCall("count", []expression.Expression{expressions.Value{1}}, false)
expr, err := expressions.NewCall("count", []expression.Expression{expressions.Value{Val: 1}}, false)
c.Assert(err, IsNil)
fldy := &field.Field{Expr: expr}

Expand Down
2 changes: 1 addition & 1 deletion rset/rsets/join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (s *testJoinRsetSuite) TestJoinRsetPlan(c *C) {

func (s *testJoinRsetSuite) TestJoinRsetString(c *C) {
s.r.Right = s.r.Left
s.r.On = expressions.Value{1}
s.r.On = expressions.Value{Val: 1}
str := s.r.String()
c.Assert(len(str), Greater, 0)
}
Loading