[MDEV-7041] COLLATION(CAST('a' AS CHAR BINARY)) returns a wrong result Created: 2014-11-07  Updated: 2015-03-11  Resolved: 2015-03-11

Status: Closed
Project: MariaDB Server
Component/s: Character Sets, Parser
Affects Version/s: 5.5.40, 10.0.14
Fix Version/s: 10.1.3

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: None


 Description   

mysql> SELECT COLLATION(CAST('a' AS CHAR BINARY));
+-------------------------------------+
| COLLATION(CAST('a' AS CHAR BINARY)) |
+-------------------------------------+
| utf8_general_ci                     |
+-------------------------------------+
1 row in set (0.00 se

The expected result is utf8_bin.
It would be inline with the same syntax in CREATE TABLE:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a CHAR BINARY) CHARSET=utf8;
SHOW CREATE TABLE t1;

+-------+-------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                            |
+-------+-------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `a` char(1) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+-------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)


Generated at Thu Feb 08 07:16:31 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.