Bug #95964 Compare that uses UNSIGNED cast and function malfunctions in the MEMORY engine
Submitted: 24 Jun 2019 22:23 Modified: 30 Mar 2020 15:38
Reporter: Manuel Rigger Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Memory storage engine Severity:S3 (Non-critical)
Version:8.0.16, 5.7.26, 5.6.44 OS:Ubuntu
Assigned to: CPU Architecture:x86

[24 Jun 2019 22:23] Manuel Rigger
Description:
When using the MEMORY engine in the example below, the row is not fetched.

How to repeat:
CREATE TABLE t0(c0 INT);
CREATE TABLE t1(c0 INT) ENGINE = MEMORY;
INSERT INTO t0(c0) VALUES(0);
INSERT INTO t1(c0) VALUES(-1);
SELECT * FROM t0, t1 WHERE (CAST(t1.c0 AS UNSIGNED)) > (IFNULL("u", t0.c0)); -- expected: row is fetched, actual: no row is fetched
SELECT (CAST(t1.c0 AS UNSIGNED)) > (IFNULL("u", t0.c0)) FROM t0, t1; -- 1

Note that the bug is only triggered when fetching from both a table handled by the MEMORY engine, and a table handled by another engine. If ENGINE = MEMORY is removed from t1, the query fetches a row as expected. The query also fetches a row if ENGINE = MEMORY is added to t0. The bug can also be triggered with, for example, COALESCE().
[25 Jun 2019 5:34] MySQL Verification Team
Hello Manuel Rigger,

Thank you for the report.

regards,
Umesh
[5 Aug 2019 19:15] Oleksandr Peresypkin
A patch for version 5.6

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: 95964-v5.6.patch (application/octet-stream, text), 2.48 KiB.

[5 Aug 2019 19:16] Oleksandr Peresypkin
A patch for version 5.7

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: 95964-v5.7.patch (application/octet-stream, text), 2.48 KiB.

[5 Aug 2019 19:16] Oleksandr Peresypkin
A patch for version 8.0

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: 95964-v8.0.patch (application/octet-stream, text), 2.54 KiB.

[30 Mar 2020 15:38] Manuel Rigger
I found that this bug can no longer be reproduced on version 8.0.19. Thanks for fixing this!