| Bug #119444 | Union with bound variable silently trims result | ||
|---|---|---|---|
| Submitted: | 22 Nov 2025 11:32 | Modified: | 5 Feb 20:32 |
| Reporter: | Michal Vorisek | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) |
| Version: | any | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | bind value, corrupt, trimmed, UNION | ||
[22 Nov 2025 11:32]
Michal Vorisek
[22 Nov 2025 11:34]
Michal Vorisek
The repro script currently outputs:
```
expected:
Array
(
[0] => Array
(
[v] => xxx...65540*...xxx
)
[1] => Array
(
[v] => yxxx...65540*...xxx
)
)
actual using mysqli driver:
Array
(
[0] => Array
(
[v] => xxx...65535*...xxx
)
[1] => Array
(
[v] => yxxx...65534*...xxx
)
)
bool(false)
actual using PDO driver:
Array
(
[0] => Array
(
[v] => xxx...65535*...xxx
)
[1] => Array
(
[v] => yxxx...65534*...xxx
)
)
bool(false)
```
[5 Feb 20:32]
Roy Lyseng
Thank you for the bug report. However, I don't think this is a bug. The default type for a dynamic parameter when no type information is present is VARCHAR(<64 kbytes>); Thus, it is impossible to return more than 64 kb in such expressions. It is possible to use a CAST to set a different type in such cases. Ideally, it should be possible to do CAST(? AS LONGTEXT), but LONGTEXT is not a valid CAST type. It is however possible to do CAST(? AS CHAR(1000000)) which assigns a LONGTEXT type when size is greater than what is supported for VARCHAR.
