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

Query failed by: ERROR 1105 (HY000): DB::Exception: Duplicate names in enum: 'a' = 27 and 'a' = 1 #25955

Closed
xzhangxian1008 opened this issue Jul 5, 2021 · 2 comments · Fixed by #26145
Assignees
Labels
severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@xzhangxian1008
Copy link
Contributor

reproduce step:

create table t(a int, b enum('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z') not null);
alter table t set tiflash replica 1;
insert into t values (1, "a");
select * from t as t1 right join t as t2 on t1.a != t2.a;

error message:

ERROR 1105 (HY000): DB::Exception: Duplicate names in enum: 'a' = 27 and 'a' = 1

version:
20210617 tiup playground nightly

mysql> select * from information_schema.cluster_info;
+---------+-----------------+-----------------+----------------------------+------------------------------------------+---------------------------+---------------+-----------+
| TYPE    | INSTANCE        | STATUS_ADDRESS  | VERSION                    | GIT_HASH                                 | START_TIME                | UPTIME        | SERVER_ID |
+---------+-----------------+-----------------+----------------------------+------------------------------------------+---------------------------+---------------+-----------+
| tidb    | 127.0.0.1:4000  | 127.0.0.1:10080 | 5.2.0-alpha                | ed52601e6eb560138db8cdccdfa1b5e2d33a11f0 | 2021-06-17T16:51:29+08:00 | 13m18.356991s |         0 |
| pd      | 127.0.0.1:2379  | 127.0.0.1:2379  | 5.1.0-alpha                | 2cc069fb77d96231533c2dc78ac687b19560af9d | 2021-06-17T16:51:22+08:00 | 13m25.357003s |         0 |
| tikv    | 127.0.0.1:20160 | 127.0.0.1:20180 | 5.1.0-alpha                | 36ff487de23b574180e289d90f889e7a461ba2bd | 2021-06-17T16:51:25+08:00 | 13m22.357006s |         0 |
| tiflash | 127.0.0.1:3930  | 127.0.0.1:20292 | v5.2.0-alpha-37-g74c69fb1d | 74c69fb1d35da3582cb9279ecb4d8597e4a78d00 | 2021-06-17T16:51:31+08:00 | 13m16.357009s |         0 |
+---------+-----------------+-----------------+----------------------------+------------------------------------------+---------------------------+---------------+-----------+
@xzhangxian1008 xzhangxian1008 added the type/bug The issue is confirmed as a bug. label Jul 5, 2021
@xzhangxian1008
Copy link
Contributor Author

TiDB add enum types repeatedly in the following codes:

file: tidb/planner/core/plan_to_pb.go

func (e *PhysicalExchangeReceiver) ToPB(ctx sessionctx.Context, storeType kv.StoreType) (*tipb.Executor, error) {

...

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)

...

}
pbTypes.Elems has been initialized in the clause pbType := expression.ToPBFieldType(column.RetType) and there is no need to append Elems again in pbType.Elems = append(pbType.Elems, column.RetType.Elems...).

I suggest to delete the pbType.Elems = append(pbType.Elems, column.RetType.Elems...)

@ti-srebot
Copy link
Contributor

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants