Bug #118591 empty string parse to 0 in SET statement, which is different from that in the SELECT query

Submitted: 7 Jul 2025 11:28 Modified: 10 Jul 2025 7:11
Reporter: chi zhang (OCA) Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Data Types Severity:S1 (Critical)
Version:9.3.0 OS:Any
Assigned to: CPU Architecture:Any

[7 Jul 2025 11:28] chi zhang
Description:
Hi,

there are two equivalent queries and the first one is a normal SELECT and the second one is a prepared statement, but they return different result.

```
CREATE TABLE IF NOT EXISTS t0(c0 FLOAT) ;
INSERt INTO t0(c0) VALUES(NULL), (0);
SELECT COALESCE(CAST(t0.c0 AS SIGNED), '') AS ref0 FROM t0;  -- '', 0

SET @a = '';
PREPARE prepare_query FROM 'SELECT COALESCE(CAST(t0.c0 AS SIGNED), ?) AS ref0 FROM t0';
EXECUTE prepare_query USING @a; -- 0, 0
```

How to repeat:
this is the workload

```
CREATE TABLE IF NOT EXISTS t0(c0 FLOAT) ;
INSERt INTO t0(c0) VALUES(NULL), (0);
SELECT COALESCE(CAST(t0.c0 AS SIGNED), '') AS ref0 FROM t0;  -- '', 0

SET @a = '';
PREPARE prepare_query FROM 'SELECT COALESCE(CAST(t0.c0 AS SIGNED), ?) AS ref0 FROM t0';
EXECUTE prepare_query USING @a; -- 0, 0
```
[10 Jul 2025 7:11] MySQL Verification Team
Hello Chi Zhang,

Thank you for the bug report.
Imho this is duplicate of Bug #118595, please see Bug #118595.

Regards,
Ashwini Patil

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.