Skip to content

Support GBK for builtin function concat #28356

@zimulala

Description

@zimulala

The built-in function concat() is not fully compatible with MySQL.

According to MySQL's concat() document:

If the arguments include any binary strings, the result is a binary string.

drop table if exists t;
create table t (a char(255) charset gbk, b binary(8));
insert into t values ('中文', 0x35);
select concat(a, b) from t;

Excepted result(MySQL 8.0.25):

mysql> select concat(a, b) from t;
+----------------------------+
| concat(a, b)               |
+----------------------------+
| 0xD6D0CEC43500000000000000 |
+----------------------------+

Note that the first bytes are D6D0CEC4, which is GBK encoding bytes for 中文.

This special handling for binary literal also applies to input:

select concat(a, 0xd6d0cec4) from t;

+-----------------------+
| concat(a, 0xd6d0cec4) |
+-----------------------+
| 中文中文              |
+-----------------------+

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions