tidb
tidb copied to clipboard
Binary literal not having the BINARY flag
MySQL:
mysql> SELECT _binary'string';
Field 1: `string`
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: VAR_STRING
Collation: binary (63)
Length: 6
Max_length: 6
Decimals: 31
Flags: NOT_NULL BINARY
+--------+
| string |
+--------+
| string |
+--------+
1 row in set (0.00 sec)
TiDB:
mysql> SELECT _binary'string';
Field 1: `string`
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: VAR_STRING
Collation: utf8_general_ci (33)
Length: 6
Max_length: 6
Decimals: 31
Flags:
+--------+
| string |
+--------+
| string |
+--------+
1 row in set (0.00 sec)
Nice catch, both Collation and Flags are different.
it seems like a same issue below
in case 1 it works as expected
MySQL [(none)]> SELECT LOWER(BINARY 'String');
Field 1: `LOWER(BINARY 'String')`
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: VAR_STRING
Collation: binary (63)
Length: 0
Max_length: 6
Decimals: 31
Flags: BINARY
+------------------------+
| LOWER(BINARY 'String') |
+------------------------+
| String |
+------------------------+
1 row in set (0.00 sec)
in case 2 the user variable doesn't work correctly
MySQL [(none)]> SET @str = BINARY 'String';
Query OK, 0 rows affected (0.01 sec)
MySQL [(none)]> SELECT LOWER(@str);
Field 1: `LOWER(@str)`
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: VAR_STRING
Collation: utf8_general_ci (33)
Length: 0
Max_length: 6
Decimals: 31
Flags:
+-------------+
| LOWER(@str) |
+-------------+
| string |
+-------------+
1 row in set (0.00 sec)