Skip to content

Commit

Permalink
planner/core: fix duplicate enum items (#26145) (#26202)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-srebot authored Jul 15, 2021
1 parent bc1d3ea commit ce98048
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 0 additions & 4 deletions planner/core/plan_to_pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package core
import (
"github.com/pingcap/errors"
"github.com/pingcap/parser/model"
"github.com/pingcap/parser/mysql"
"github.com/pingcap/tidb/distsql"
"github.com/pingcap/tidb/expression"
"github.com/pingcap/tidb/expression/aggregation"
Expand Down Expand Up @@ -279,9 +278,6 @@ func (e *PhysicalExchangeReceiver) ToPB(ctx sessionctx.Context, storeType kv.Sto
fieldTypes := make([]*tipb.FieldType, 0, len(e.Schema().Columns))
for _, column := range e.Schema().Columns {
pbType := expression.ToPBFieldType(column.RetType)
if column.RetType.Tp == mysql.TypeEnum {
pbType.Elems = append(pbType.Elems, column.RetType.Elems...)
}
fieldTypes = append(fieldTypes, pbType)
}
ecExec := &tipb.ExchangeReceiver{
Expand Down
9 changes: 9 additions & 0 deletions planner/core/plan_to_pb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,13 @@ func (s *testDistsqlSuite) TestColumnToProto(c *C) {
}
pc = util.ColumnToProto(col1)
c.Assert(pc.Collation, Equals, int32(-8))

tp = types.NewFieldType(mysql.TypeEnum)
tp.Flag = 10
tp.Elems = []string{"a", "b"}
col2 := &model.ColumnInfo{
FieldType: *tp,
}
pc = util.ColumnToProto(col2)
c.Assert(len(pc.Elems), Equals, 2)
}

0 comments on commit ce98048

Please sign in to comment.