Skip to content

Commit

Permalink
*: Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shenli committed Oct 19, 2015
1 parent 3442b77 commit c14b723
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions mysql/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ const (
TypeGeometry
)

// UnInitializedType is an uninitialized type code.
// TypeDecimal is the old type code for decimal and not be used in the new mysql version.
const UnInitializedType = TypeDecimal

// Flag informations.
const (
NotNullFlag = 1 /* Field can't be NULL */
Expand Down
3 changes: 2 additions & 1 deletion plan/plans/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/pingcap/tidb/context"
"github.com/pingcap/tidb/expression"
"github.com/pingcap/tidb/field"
"github.com/pingcap/tidb/mysql"
"github.com/pingcap/tidb/plan"
"github.com/pingcap/tidb/util/format"
"github.com/pingcap/tidb/util/types"
Expand Down Expand Up @@ -83,7 +84,7 @@ func (r *SelectFieldsDefaultPlan) Next(ctx context.Context) (row *plan.Row, err
}
di, ok := d.(*types.DataItem)
if ok {
if r.ResultFields[i].Col.Tp == 0 {
if r.ResultFields[i].Col.Tp == mysql.UnInitializedType {

This comment has been minimized.

Copy link
@ngaut

ngaut Oct 20, 2015

Member

Extract to function maybe better.

This comment has been minimized.

Copy link
@shenli

shenli Oct 20, 2015

Author Member

PTAL @ngaut

r.ResultFields[i].Col.FieldType = *di.Type
}
row.Data[i] = di.Data
Expand Down
2 changes: 1 addition & 1 deletion plan/plans/plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func setResultFieldInfo(fields []*field.ResultField, values []interface{}) error
return errors.Errorf("Fields and Values length unmatch %d VS %d", len(fields), len(values))
}
for i, rf := range fields {
if rf.Col.Tp == 0 {
if rf.Col.Tp == mysql.UnInitializedType {
// 0 == TypeDecimal, Tp maybe uninitialized
rf.Col.Charset = charset.CharsetBin
rf.Col.Collate = charset.CharsetBin
Expand Down
2 changes: 1 addition & 1 deletion plan/plans/union.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/pingcap/tidb/expression"
"github.com/pingcap/tidb/field"
"github.com/pingcap/tidb/kv/memkv"
mysql "github.com/pingcap/tidb/mysqldef"
"github.com/pingcap/tidb/mysql"
"github.com/pingcap/tidb/plan"
"github.com/pingcap/tidb/util/format"
"github.com/pingcap/tidb/util/types"
Expand Down

1 comment on commit c14b723

@qiuyesuifeng
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Please sign in to comment.