diff --git a/mysql/type.go b/mysql/type.go index 36f3441a94b7f..9baad459e1c59 100644 --- a/mysql/type.go +++ b/mysql/type.go @@ -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 */ diff --git a/plan/plans/fields.go b/plan/plans/fields.go index f2a8b7edcb772..fc2cf64ec07eb 100644 --- a/plan/plans/fields.go +++ b/plan/plans/fields.go @@ -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" @@ -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 { r.ResultFields[i].Col.FieldType = *di.Type } row.Data[i] = di.Data diff --git a/plan/plans/plans.go b/plan/plans/plans.go index d682b06eb7d33..1d13c3f99f618 100644 --- a/plan/plans/plans.go +++ b/plan/plans/plans.go @@ -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 diff --git a/plan/plans/union.go b/plan/plans/union.go index 5675a9666bae2..392205caf0a8c 100644 --- a/plan/plans/union.go +++ b/plan/plans/union.go @@ -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"