matrixorigin / matrixorigin/matrixone
[Bug]: binary strings report utf8mb4 charset/collation instead of binary
- Dominant language
- Go
- Stars
- 1.9k
- Forks
- 311
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 768
Description
## Bug Report
### Description
MatrixOne reports `_binary` literals, `BINARY` operator results, `VARBINARY` columns, and `UNHEX()` results as `utf8mb4 / utf8mb4_general_ci` in `CHARSET()` / `COLLATION()`. MySQL reports these values as `binary / binary`.
### Steps to Reproduce
```sql
select charset(_binary 'abc') as cs_bin_lit, collation(_binary 'abc') as coll_bin_lit;
select charset(binary 'abc') as cs_binary_op, collation(binary 'abc') as coll_binary_op;
select charset(concat(_binary 'a', 'b')) as cs_concat_bin, collation(concat(_binary 'a', 'b')) as coll_concat_bin;
select charset(unhex('41')) as cs_unhex, collation(unhex('41')) as coll_unhex;
create table t_charset_func (
id int primary key,
vc varchar(20),
vb varbinary(20)
);
insert into t_charset_func values (1, 'abc', 'abc');
select charset(vb) as cs_vb,
collation(vb) as coll_vb,
charset(concat(vb, 'x')) as cs_concat_vb,
collation(concat(vb, 'x')) as coll_concat_vb
from t_charset_func;
```
### MySQL Result
```text
cs_bin_lit coll_bin_lit
binary binary
cs_binary_op coll_binary_op
binary binary
cs_concat_bin coll_concat_bin
binary binary
cs_unhex coll_unhex
binary binary
cs_vb coll_vb cs_concat_vb coll_concat_vb
binary binary binary binary
```
### MatrixOne Result
Tested on latest `main` at `200bfa7e0efb`.
```text
cs_bin_lit coll_bin_lit
utf8mb4 utf8mb4_general_ci
cs_binary_op coll_binary_op
utf8mb4 utf8mb4_general_ci
cs_concat_bin coll_concat_bin
utf8mb4 utf8mb4_general_ci
cs_unhex coll_unhex
utf8mb4 utf8mb4_general_ci
cs_vb coll_vb cs_concat_vb coll_concat_vb
utf8mb4 utf8mb4_general_ci utf8mb4 utf8mb4_general_ci
```
### Expected Behavior
Binary strings should have character set `binary` and collation `binary`, and binary arguments should propagate binary result metadata where MySQL does.
### Notes
Found during active MySQL compatibility exploration, Module 4: String / Charset / Collation. I searched existing issues for binary charset/collation metadata and did not find a duplicate. This is related to, but different from, `CHAR_LENGTH(_binary ...)` byte-count issue #25295.
Contributor guide
Assessment
This issue has not been assessed yet.