Skip to content

ddl : fix column collate should use table's if it has when create table or alter table. (#13119 & #12327)#13175

Merged
bb7133 merged 5 commits intopingcap:release-3.1from
sre-bot:release-3.1-8d545a180450
Nov 6, 2019
Merged

ddl : fix column collate should use table's if it has when create table or alter table. (#13119 & #12327)#13175
bb7133 merged 5 commits intopingcap:release-3.1from
sre-bot:release-3.1-8d545a180450

Conversation

@sre-bot
Copy link
Contributor

@sre-bot sre-bot commented Nov 6, 2019

cherry-pick #13119 and #12327 to release-3.1


What problem does this PR solve?

fix issue #13113
When creating a table, if we set a collate for this table, all columns in this table should use this collate instead of using default collates.
In MySQL:

mysql> show create table t;
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                                                                                 |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `id` int(11) NOT NULL,
  `c1` varchar(10) COLLATE utf8_slovak_ci DEFAULT NULL,
  `c2` varchar(20) COLLATE utf8_slovak_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_slovak_ci |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

In TiDB

mysql> create table t (id int(11) primary key ,c1 varchar(10) ,c2 varchar(20)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_slovak_ci;
Query OK, 0 rows affected (0.01 sec)

mysql> show create table t;
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                                                                     |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `id` int(11) NOT NULL,
  `c1` varchar(10) COLLATE utf8_bin DEFAULT NULL,
  `c2` varchar(20) COLLATE utf8_bin DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_slovak_ci |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

What is changed and how it works?

Table's collate should be passed into buildColumnsAndConstraints when in create table or alter table.

Check List

Tests

  • Unit test
  • Integration test

Code changes

  • add parameter for buildColumnsAndConstraints function.

Related changes

  • Need to cherry-pick to the release branch

Release note

  • fix column collate should use table's if it has when create table or alter table.

@sre-bot
Copy link
Contributor Author

sre-bot commented Nov 6, 2019

/run-all-tests

@bb7133
Copy link
Member

bb7133 commented Nov 6, 2019

/rebuild

@AilinKid
Copy link
Contributor

AilinKid commented Nov 6, 2019

/run-all-tests

Copy link
Member

@bb7133 bb7133 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bb7133 bb7133 added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 6, 2019
@bb7133 bb7133 changed the title ddl : fix column collate should use table's if it has when create table or alter table. (#13119) ddl : fix column collate should use table's if it has when create table or alter table. (#13119 & #12327) Nov 6, 2019
Copy link
Member

@wjhuang2016 wjhuang2016 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AilinKid AilinKid added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 6, 2019
@bb7133 bb7133 merged commit 724963c into pingcap:release-3.1 Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants