Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support GBK for builtin function concat #28356

Closed
Tracked by #26816
zimulala opened this issue Sep 26, 2021 · 0 comments · Fixed by #29905
Closed
Tracked by #26816

Support GBK for builtin function concat #28356

zimulala opened this issue Sep 26, 2021 · 0 comments · Fixed by #29905
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.

Comments

@zimulala
Copy link
Contributor

zimulala commented Sep 26, 2021

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) |
+-----------------------+
| 中文中文              |
+-----------------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
Projects
None yet
2 participants