matrixorigin / matrixorigin/matrixone

[Compatibility]: string numeric-result functions materialize incompatible width or signedness

Open
#28,909 2 comments 0 reactions 1 assignee Claimed by @XuPeng-SH View on GitHub
area/compatibility kind/bug needs-triage
Dominant language
Go
Stars
1.9k
Forks
311
Avg merge
1d 3h
Merged PRs (30d)
768

Description

### Problem

Several numeric-result string functions are materialized with incompatible width or signedness in MatrixOne Views and CTAS tables:

- `FIND_IN_SET` becomes `BIGINT UNSIGNED` instead of signed `INT`;
- `STRCMP` becomes `TINYINT` instead of signed `INT`;
- `CHAR_LENGTH` becomes `BIGINT UNSIGNED` instead of signed `BIGINT`.

### Reproduction

```sql
drop database if exists find_in_set_type_repro;
create database find_in_set_type_repro;
use find_in_set_type_repro;

create table src(id int primary key,needle varchar(20),csv varchar(100));
insert into src values
(1,'b','a,b,,c'),
(2,'','a,b,,c'),
(3,'中','甲,中,乙'),
(4,null,null);

create view v as
select id,
find_in_set(needle,csv) pos,
strcmp(needle,'a') cmp,
char_length(csv) chars
from src;
create table ctas as select * from v;

select table_name,column_name,data_type,column_type,is_nullable,
numeric_precision,numeric_scale
from information_schema.columns
where table_schema=database() and table_name in ('v','ctas')
order by table_name,ordinal_position;
```

### MatrixOne result

In both the View and CTAS table:

- `pos` is `BIGINT UNSIGNED`;
- `cmp` is `TINYINT`;
- `chars` is `BIGINT UNSIGNED`.

### MySQL 8.0.45 result

In both the View and CTAS table:

- `pos` and `cmp` are signed `INT`;
- `chars` is signed `BIGINT`.

Scalar values agree when inputs use relations that both systems implement identically. Collation-sensitive value differences are tracked separately in #25096; this issue concerns the persisted numeric schema contract.

### Protocol control

A direct constant expression is exposed through the wire protocol as `LONGLONG` by both systems, but MatrixOne sets the `UNSIGNED` flag and reports display length 64, while MySQL reports a signed numeric result with display length 3. View/CTAS inspection is the stable DDL-level reproduction above.

Incorrect signedness and width propagate into CTAS schemas, generated client models, and connectors that derive types from `INFORMATION_SCHEMA`.

### Scope

Direct SQL, table columns, View, CTAS, PreparedStatement, empty element, missing value, UTF-8 input, and NULL are covered. Controls for `LENGTH`, `OCTET_LENGTH`, `BIT_LENGTH`, `ASCII`, `ORD`, `LOCATE`, `INSTR`, and `POSITION` materialize with compatible base types. Three independent executions produced identical results on each database.

### Environment

- MatrixOne: official `main` commit `0c3a04f390adaf6281fd592a49778ea5b1155e67`
- MySQL control: 8.0.45
- Local single-node MatrixOne deployment

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.