Bug #117058 Inconsistent Results When Using COALESCE
Submitted: 27 Dec 2024 13:01 Modified: 27 Dec 2024 13:08
Reporter: Aaditya Dubey Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:8.4.3, 8.0.40 OS:Any
Assigned to: CPU Architecture:Any

[27 Dec 2024 13:01] Aaditya Dubey
Description:
There is an inconsistency in the results when using the COALESCE function.

How to repeat:
1. Set up table t0:

CREATE TABLE t0 (c0 BIT, c1 BIT);
INSERT INTO t0 VALUES (0, 1);

2. Use COALESCE in a SELECT query:

SELECT (COALESCE(t0.c0, t0.c1)) AS c0 FROM t0;
--Result: 0x30

3. Store the result of COALESCE in another table t1 and SELECT FROM t1:

CREATE TABLE t1 AS (SELECT (COALESCE(t0.c0, t0.c1)) AS c0 FROM t0);
SELECT * FROM t1;
--Result: 0

The result should be consistent regardless of whether the result is directly selected or stored in another table.

Suggested fix:
The result should be consistent regardless of whether the result is directly selected or stored in another table.
[27 Dec 2024 13:08] MySQL Verification Team
Hello Aaditya,

Thank you for the report and feedback.
Verified as described.

regards,
Umesh