matrixorigin / matrixorigin/matrixone
[Compatibility]: UNCOMPRESSED_LENGTH omits corruption warnings for short invalid inputs
- Dominant language
- Go
- Stars
- 1.9k
- Forks
- 311
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 768
Description
### Problem
`UNCOMPRESSED_LENGTH()` silently returns `0` for nonempty inputs that are too short to contain a valid compressed value. MySQL returns the same numeric value but also emits warning 1259 (`ZLIB: Input data corrupted`). Applications that inspect diagnostics cannot distinguish corrupt data from a valid compressed empty string in MatrixOne.
### Reproduction
Run each expression separately so its warning count is not mixed with another function call:
```sql
SELECT UNCOMPRESSED_LENGTH(X'00') AS result;
SHOW COUNT(*) WARNINGS;
SHOW WARNINGS;
SELECT UNCOMPRESSED_LENGTH(X'000000') AS result;
SHOW COUNT(*) WARNINGS;
SHOW WARNINGS;
SELECT UNCOMPRESSED_LENGTH(X'00000000') AS result;
SHOW COUNT(*) WARNINGS;
SHOW WARNINGS;
SELECT UNCOMPRESSED_LENGTH(X'01000000') AS result;
SHOW COUNT(*) WARNINGS;
SHOW WARNINGS;
```
### MatrixOne result
Every expression returns `0` and `@@session.warning_count` remains `0`.
### MySQL 8.0.45 result
Every expression returns `0`, but each statement sets `@@session.warning_count` to `1`:
```text
Warning 1259 ZLIB: Input data corrupted
```
### Controls and scope
- `UNCOMPRESSED_LENGTH(X'')` returns `0` without a warning on both systems.
- `UNCOMPRESSED_LENGTH(COMPRESS(''))` returns `0` without a warning on both systems.
- `UNCOMPRESSED_LENGTH(COMPRESS('abc'))` returns `3` without a warning on both systems.
- `UNCOMPRESS()` already emits warning 1259 for the same corrupt inputs on current MatrixOne; the missing diagnostic is specific to `UNCOMPRESSED_LENGTH()`.
- One-, three-, and four-byte corrupt inputs and valid empty/nonempty compressed controls reproduced identically in three fresh runs on each database.
### Code location
`UncompressedLength` in `pkg/sql/plan/function/func_unary.go` returns `0` immediately when `len(data) <= 4` and has no warning accumulator. The current `Uncompress` path already maps invalid compressed data to MySQL-compatible warnings.
### Environment
- MatrixOne: official `main` commit `0c3a04f390adaf6281fd592a49778ea5b1155e67`
- MySQL control: 8.0.45
- Local single-node MatrixOne deployment
Contributor guide
Assessment
This issue has not been assessed yet.