Bug #89041 collate info will lost if table define with charset=utf8 after collate=utf8_bin
Submitted: 23 Dec 2017 6:44 Modified: 24 Dec 2017 5:25
Reporter: dennis gao Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version:5.7.18 OS:Any
Assigned to: CPU Architecture:Any

[23 Dec 2017 6:44] dennis gao
Description:
When create a table, if we declare the collate info before the charset, the collate info will lost.

How to repeat:
As below example, the collate=utf8mb4_bin is lost:

mysql> create table t10013(c1 varchar(10) )collate=utf8mb4_bin charset=utf8mb4 engine=innodb;
Query OK, 0 rows affected (0.52 sec)

mysql> show create table t10013;
+--------+-------------------------------------------------------------------------------------------------+
| Table  | Create Table                                                                                    |
+--------+-------------------------------------------------------------------------------------------------+
| t10013 | CREATE TABLE `t10013` (
  `c1` varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+--------+-------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)
mysql> insert into t10013 values ("A"),("a");
Query OK, 2 rows affected (0.07 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> select * from t10013 where c1="a";
+------+
| c1   |
+------+
| A    |
| a    |
+------+
2 rows in set (0.01 sec)

And if we declare the charset info before collate, it works fine:

mysql> create table t10013(c1 varchar(10) ) charset=utf8mb4 collate=utf8mb4_bin engine=innodb;
Query OK, 0 rows affected (0.38 sec)

mysql> show create table t10013;
+--------+-----------------------------------------------------------------------------------------------------------------------------------------+
| Table  | Create Table                                                                                                                            |
+--------+-----------------------------------------------------------------------------------------------------------------------------------------+
| t10013 | CREATE TABLE `t10013` (
  `c1` varchar(10) COLLATE utf8mb4_bin DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+--------+-----------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

mysql> insert into t10013 values ("A"),("a");
Query OK, 2 rows affected (0.07 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> select * from t10013 where c1="a";
+------+
| c1   |
+------+
| a    |
+------+
1 row in set (0.02 sec)

mysql> drop table t10013;
Query OK, 0 rows affected (0.15 sec)

Suggested fix:
None.
[24 Dec 2017 5:25] MySQL Verification Team
Hello dennis gao,

Thank you for the report.
This is duplicate of Bug #32571, please see Bug #32571

Thanks,
Umesh