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 tool vet --shadow #31

Merged
merged 2 commits into from
Sep 7, 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
8 changes: 6 additions & 2 deletions ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,17 @@ func (d *ddl) buildIndex(ctx context.Context, t table.Table, idxInfo *model.Inde
cols := t.Cols()
var vals []interface{}
for _, v := range idxInfo.Columns {
var (
data []byte
val interface{}
)
col := cols[v.Offset]
k := t.RecordKey(h, col)
data, err := txn.Get([]byte(k))
data, err = txn.Get([]byte(k))
if err != nil {
return errors.Trace(err)
}
val, err := t.DecodeValue(data, col)
val, err = t.DecodeValue(data, col)
if err != nil {
return errors.Trace(err)
}
Expand Down
6 changes: 3 additions & 3 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,9 @@ func newdriverRows(rs rset.Recordset) *driverRows {
go func() {
err := io.EOF
if e := r.rs.Do(func(data []interface{}) (bool, error) {
vv, err := types.Clone(data)
if err != nil {
return false, errors.Trace(err)
vv, cloneErr := types.Clone(data)
if cloneErr != nil {
return false, errors.Trace(cloneErr)
}
select {
case r.rows <- vv:
Expand Down
3 changes: 2 additions & 1 deletion plan/plans/distinct.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ func (r *DistinctDefaultPlan) Do(ctx context.Context, f plan.RowIterFunc) (err e

var rows [][]interface{}
if err = r.Src.Do(ctx, func(id interface{}, in []interface{}) (bool, error) {
var v []interface{}
// get distinct key
key := in[0:r.HiddenFieldOffset]
v, err := t.Get(key)
v, err = t.Get(key)
if err != nil {
return false, err
}
Expand Down
10 changes: 6 additions & 4 deletions plan/plans/from.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ func (r *TableNilPlan) Do(ctx context.Context, f plan.RowIterFunc) error {
}
defer it.Close()
for it.Valid() && strings.HasPrefix(it.Key(), prefix) {
var err error
id, err := util.DecodeHandleFromRowKey(it.Key())
var id int64
id, err = util.DecodeHandleFromRowKey(it.Key())
if err != nil {
return err
}

// do nothing
if m, err := f(id, nil); !m || err != nil {
var m bool
if m, err = f(id, nil); !m || err != nil {
return err
}

Expand Down Expand Up @@ -291,7 +292,8 @@ func (r *TableDefaultPlan) Do(ctx context.Context, f plan.RowIterFunc) error {
}
rks.appendKeys(rke)
rec = append(rec, rks)
if m, err := f(int64(0), rec); !m || err != nil {
m, err := f(int64(0), rec)
if !m || err != nil {
return err
}

Expand Down
3 changes: 2 additions & 1 deletion plan/plans/groupby.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ func (r *GroupByDefaultPlan) Do(ctx context.Context, f plan.RowIterFunc) (err er

if len(outRows) == 0 {
// empty table
out, err := r.evalEmptyTable(ctx)
var out []interface{}
out, err = r.evalEmptyTable(ctx)
if err != nil || out == nil {
return err
}
Expand Down
7 changes: 3 additions & 4 deletions plan/plans/union.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func (p *UnionPlan) Do(ctx context.Context, f plan.RowIterFunc) error {

// Eval the following select statements
for i, distinct := range p.Distincts {
var err error
src = p.Srcs[i+1]
// Eval src
if len(src.GetFields()) != len(rfs) {
Expand Down Expand Up @@ -100,9 +99,9 @@ func (p *UnionPlan) Do(ctx context.Context, f plan.RowIterFunc) error {
}
if distinct {
// distinct union, check duplicate
v, err := t.Get(in)
if err != nil {
return false, err
v, getErr := t.Get(in)
if getErr != nil {
return false, getErr
}
if len(v) > 0 {
// Find duplicate, ignore it
Expand Down
6 changes: 3 additions & 3 deletions stmt/stmts/insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ func (s *InsertIntoStmt) Exec(ctx context.Context) (_ rset.Recordset, err error)
// For "insert into t values (default)" Default Eval.
m[expressions.ExprEvalDefaultName] = cols[i].Name.O

val, err := expr.Eval(ctx, m)
if err != nil {
return nil, errors.Trace(err)
val, evalErr := expr.Eval(ctx, m)
if evalErr != nil {
return nil, errors.Trace(evalErr)
}
r[cols[i].Offset] = val
marked[cols[i].Offset] = struct{}{}
Expand Down
11 changes: 4 additions & 7 deletions stmt/stmts/union.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ func (s *UnionStmt) SetText(text string) {

// Plan implements the plan.Planner interface.
func (s *UnionStmt) Plan(ctx context.Context) (plan.Plan, error) {
var r plan.Plan
var err error
srcs := make([]plan.Plan, 0, len(s.Selects))
for _, s := range s.Selects {
p, err := s.Plan(ctx)
Expand All @@ -65,13 +63,12 @@ func (s *UnionStmt) Plan(ctx context.Context) (plan.Plan, error) {
}
srcs = append(srcs, p)
}
if r, err = (&rsets.UnionRset{

r, err := (&rsets.UnionRset{
Srcs: srcs,
Distincts: s.Distincts,
}).Plan(ctx); err != nil {
return nil, err
}
return r, nil
}).Plan(ctx)
return r, err
}

// Exec implements the stmt.Statement Exec interface.
Expand Down
3 changes: 2 additions & 1 deletion table/tables/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,8 @@ func (t *Table) IterRecords(ctx context.Context, startKey string, cols []*column
if err != nil {
return err
}
if more, err := fn(h, data, cols); !more || err != nil {
more, err := fn(h, data, cols)
if !more || err != nil {
return err
}

Expand Down