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

alter set/enum type column does not check constraint #19804

Closed
xiongjiwei opened this issue Sep 4, 2020 · 4 comments · Fixed by #19806
Closed

alter set/enum type column does not check constraint #19804

xiongjiwei opened this issue Sep 4, 2020 · 4 comments · Fixed by #19806
Labels
component/infoschema help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@xiongjiwei
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table if exists t;
create table t(a set('a', 'b', 'c'));
insert into t (a) values ('a'), ('b'), ('c');
alter table t change a a set('a', 'b', 'c', 'c');

2. What did you expect to see? (Required)

[HY000][1291] Column 'a' has duplicated value 'c' in SET

3. What did you see instead (Required)

success

mysql> show create table t;
+-------+------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                           |
+-------+------------------------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `a` set('a','b','c','c') DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

4. What is your TiDB version? (Required)

@xiongjiwei xiongjiwei added the type/bug The issue is confirmed as a bug. label Sep 4, 2020
@wjhuang2016 wjhuang2016 added the sig/sql-infra SIG: SQL Infra label Sep 5, 2020
@zimulala zimulala added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Sep 7, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Sep 17, 2020

Integrity check:
component severity RCA symptom affect_version fix_version fields are empty

Please comment /info to get template

@pingcap pingcap deleted a comment from ti-srebot Sep 17, 2020
@seiya-annie
Copy link

/info

@xiongjiwei
Copy link
Contributor Author

Please edit this comment to complete the following information

Bug

1. Root Cause Analysis (RCA)

Alter set/enum type column does not check constraint

2. Symptom

alter table t change a a set('a', 'b', 'c', 'c');  #success

3. Minimal steps to reproduce the bug (optional)

drop table if exists t;
create table t(a set('a', 'b', 'c'));
alter table t change a a set('a', 'b', 'c', 'c');

show create table t;
+-------+------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                           |
+-------+------------------------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `a` set('a','b','c','c') DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

4. Solution (optional)

  • check constraint for enum/set column type
  • check type compatible for set type

5. W/A (Workaround)

  • No

6. Affected versions

[v3.0.0:v3.0.18],[v4.0.0:v4.0.6]

7. Fixed versions

[v3.0.19], [v4.0.7]

@seiya-annie
Copy link

Please edit this comment to complete the following information

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)

Alter set/enum type column does not check constraint

2. Symptom

alter table t change a a set('a', 'b', 'c', 'c'); #success

3. All Trigger Conditions

drop table if exists t;
create table t(a set('a', 'b', 'c'));
alter table t change a a set('a', 'b', 'c', 'c');

show create table t;
+-------+------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+------------------------------------------------------------------------------------------------------------------------+
| t | CREATE TABLE t (
a set('a','b','c','c') DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

4. Workaround (optional)

5. Affected versions

[v3.0.0:v3.0.18],[v4.0.0:v4.0.6]

6. Fixed versions

[v3.0.19], [v4.0.7]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/infoschema help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants