diff --git a/executor/tiflash_test.go b/executor/tiflash_test.go index 20679644dabb6..7e4cd0375c177 100644 --- a/executor/tiflash_test.go +++ b/executor/tiflash_test.go @@ -280,6 +280,23 @@ func (s *tiflashTestSuite) TestPartitionTable(c *C) { failpoint.Disable("github.com/pingcap/tidb/executor/checkUseMPP") } +func (s *tiflashTestSuite) TestMppEnum(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("use test") + tk.MustExec("drop table if exists t") + tk.MustExec("create table t(a int not null primary key, b enum('aca','bca','zca'))") + tk.MustExec("alter table t set tiflash replica 1") + tb := testGetTableByName(c, tk.Se, "test", "t") + err := domain.GetDomain(tk.Se).DDL().UpdateTableReplicaInfo(tk.Se, tb.Meta().ID, true) + c.Assert(err, IsNil) + tk.MustExec("insert into t values(1,'aca')") + tk.MustExec("insert into t values(2,'bca')") + tk.MustExec("insert into t values(3,'zca')") + tk.MustExec("set @@session.tidb_isolation_read_engines=\"tiflash\"") + tk.MustExec("set @@session.tidb_allow_mpp=ON") + tk.MustQuery("select t1.b from t t1 join t t2 on t1.a = t2.a order by t1.b").Check(testkit.Rows("aca", "bca", "zca")) +} + func (s *tiflashTestSuite) TestCancelMppTasks(c *C) { var hang = "github.com/pingcap/tidb/store/mockstore/unistore/mppRecvHang" tk := testkit.NewTestKit(c, s.store) diff --git a/go.mod b/go.mod index 5a53c7b55cb36..df3b23a117294 100644 --- a/go.mod +++ b/go.mod @@ -49,7 +49,7 @@ require ( github.com/pingcap/parser v0.0.0-20210303061548-f6776f61e268 github.com/pingcap/sysutil v0.0.0-20210221112134-a07bda3bde99 github.com/pingcap/tidb-tools v4.0.9-0.20201127090955-2707c97b3853+incompatible - github.com/pingcap/tipb v0.0.0-20210308034246-066a76fd4e1b + github.com/pingcap/tipb v0.0.0-20210309080453-72c4feaa6da7 github.com/prometheus/client_golang v1.5.1 github.com/prometheus/client_model v0.2.0 github.com/prometheus/common v0.9.1 diff --git a/go.sum b/go.sum index 0636203d83bd1..2a44f9b831409 100644 --- a/go.sum +++ b/go.sum @@ -422,8 +422,8 @@ github.com/pingcap/sysutil v0.0.0-20210221112134-a07bda3bde99 h1:/ogXgm4guJzow4U github.com/pingcap/sysutil v0.0.0-20210221112134-a07bda3bde99/go.mod h1:EB/852NMQ+aRKioCpToQ94Wl7fktV+FNnxf3CX/TTXI= github.com/pingcap/tidb-tools v4.0.9-0.20201127090955-2707c97b3853+incompatible h1:ceznmu/lLseGHP/jKyOa/3u/5H3wtLLLqkH2V3ssSjg= github.com/pingcap/tidb-tools v4.0.9-0.20201127090955-2707c97b3853+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM= -github.com/pingcap/tipb v0.0.0-20210308034246-066a76fd4e1b h1:AvGm1DqSEwbGgiiu3KVuTtwLl3MqhbwwnJpx82l6/7M= -github.com/pingcap/tipb v0.0.0-20210308034246-066a76fd4e1b/go.mod h1:nsEhnMokcn7MRqd2J60yxpn/ac3ZH8A6GOJ9NslabUo= +github.com/pingcap/tipb v0.0.0-20210309080453-72c4feaa6da7 h1:j8MkWmy5tduhHVsdsgZJugN1U9OWTMSBQoZIpn8kqPc= +github.com/pingcap/tipb v0.0.0-20210309080453-72c4feaa6da7/go.mod h1:nsEhnMokcn7MRqd2J60yxpn/ac3ZH8A6GOJ9NslabUo= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= diff --git a/planner/core/plan_to_pb.go b/planner/core/plan_to_pb.go index f199c3dd9cf19..c6a9e48c612f7 100644 --- a/planner/core/plan_to_pb.go +++ b/planner/core/plan_to_pb.go @@ -16,6 +16,7 @@ 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" @@ -280,7 +281,11 @@ 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 { - fieldTypes = append(fieldTypes, expression.ToPBFieldType(column.RetType)) + 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{ EncodedTaskMeta: encodedTask, diff --git a/store/mockstore/unistore/cophandler/mpp.go b/store/mockstore/unistore/cophandler/mpp.go index c77caa03f8f67..9849f53921099 100644 --- a/store/mockstore/unistore/cophandler/mpp.go +++ b/store/mockstore/unistore/cophandler/mpp.go @@ -132,7 +132,11 @@ func (b *mppExecBuilder) buildMPPExchangeReceiver(pb *tipb.ExchangeReceiver) (*e } for _, pbType := range pb.FieldTypes { - e.fieldTypes = append(e.fieldTypes, expression.FieldTypeFromPB(pbType)) + tp := expression.FieldTypeFromPB(pbType) + if tp.Tp == mysql.TypeEnum { + tp.Elems = append(tp.Elems, pbType.Elems...) + } + e.fieldTypes = append(e.fieldTypes, tp) } return e, nil }