matrixorigin / matrixorigin/matrixone

[Bug]: CHAR column retrieval preserves trailing spaces unlike MySQL

Open
#25,240 2 comments 0 reactions 1 assignee Claimed by @daviszhen View on GitHub
ai-medium deferred kind/bug
Dominant language
Go
Stars
1.9k
Forks
311
Avg merge
1d 3h
Merged PRs (30d)
768

Description

### Environment

- Branch: latest `main`
- Commit: `33e96877604ad4b847ea7d5c55eb09429de1a5b6`
- MySQL oracle: 8.0.45
- MO: `8.0.30-MatrixOne-v1.3.0`

### Steps to Reproduce

```sql
drop database if exists mysql_compat_char_probe;
create database mysql_compat_char_probe;
use mysql_compat_char_probe;
create table t (id int primary key, ch char(8), vc varchar(8));
insert into t values (1, 'a', 'a'), (2, 'a ', 'a '), (3, 'a ', 'a ');
select id, hex(ch) as ch_hex, length(ch) as ch_len,
hex(vc) as vc_hex, length(vc) as vc_len
from t order by id;
drop database mysql_compat_char_probe;
```

### MySQL Result

```text
id ch_hex ch_len vc_hex vc_len
1 61 1 61 1
2 61 1 6120 2
3 61 1 612020 3
```

### MatrixOne Result

```text
id ch_hex ch_len vc_hex vc_len
1 61 1 61 1
2 6120 2 6120 2
3 612020 3 612020 3
```

### Expected Behavior

When retrieving `CHAR(N)` values, MySQL trims trailing spaces from the returned value, while `VARCHAR` preserves them. MatrixOne currently preserves the trailing spaces for `CHAR` retrieval.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.