Bug #116892 Inconsistent Query Results Between Materialized Table and View with FROM_UNIXTIME

Submitted: 6 Dec 2024 8:39 Modified: 6 Dec 2024 9:39
Reporter: Wenqian Deng Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:9.0, 8.0.40 OS:Any
Assigned to: CPU Architecture:Any

[6 Dec 2024 8:39] Wenqian Deng
Description:
In MySQL, a query using the FROM_UNIXTIME function and a NOT condition behaves inconsistently between a materialized table and a view with the same definition.

How to repeat:
1. Set up table t0:
CREATE TABLE t0 (c0 SMALLINT, c1 BOOLEAN, c2 INT);
INSERT INTO t0 (c0, c1, c2) VALUES (-30011, 68, -1948448895);
INSERT INTO t0 (c0, c1, c2) VALUES (-1007, 127, 2078435568);
INSERT INTO t0 (c0, c1, c2) VALUES (11406, 125, 684249916);
INSERT INTO t0 (c0, c1, c2) VALUES (-9955, -42, -403124655);
INSERT INTO t0 (c0, c1, c2) VALUES (2654, -17, -110740575);
INSERT INTO t0 (c0, c1, c2) VALUES (17815, 52, 525250067);
INSERT INTO t0 (c0, c1, c2) VALUES (24384, -55, 875534766);
INSERT INTO t0 (c0, c1, c2) VALUES (-9483, 4, 615742521);
INSERT INTO t0 (c0, c1, c2) VALUES (-11317, -35, 1781339192);
INSERT INTO t0 (c0, c1, c2) VALUES (-11633, 39, -1363181180);
INSERT INTO t0 (c0, c1, c2) VALUES (1638, -57, 1211495430);
INSERT INTO t0 (c0, c1, c2) VALUES (-18167, -52, 1452061860);

2. Create materialized table t1 and query it:
CREATE TABLE t1 AS (SELECT (FROM_UNIXTIME(c0)) AS c0 , c1 AS c1, c2 AS c2 FROM t0 );
SELECT (c0), c2 FROM t1 WHERE NOT c0 <= 116 ORDER BY c1 DESC, (c0) DESC;
Empty set (0.00 sec)

3. Create view t1 instead and query it:
CREATE VIEW t1 AS (SELECT (FROM_UNIXTIME(c0)) AS c0 , c1 AS c1, c2 AS c2 FROM t0 );
SELECT (c0), c2 FROM t1 WHERE NOT c0 <= 116 ORDER BY c1 DESC, (c0) DESC;
+---------------------+------------+
| c0                  | c2         |
+---------------------+------------+
| 1970-01-01 03:10:06 |  684249916 |
| 1970-01-01 04:56:55 |  525250067 |
| 1970-01-01 00:44:14 | -110740575 |
| 1970-01-01 06:46:24 |  875534766 |
| 1970-01-01 00:27:18 | 1211495430 |
+---------------------+------------+
5 rows in set (0.00 sec)

Expected Behavior:

Both the materialized table and the view should return consistent results based on the query conditions.
[6 Dec 2024 9:39] MySQL Verification Team
Hello Wenqian Deng,

Thank you for the report and test case.
Verified as described.

regards,
Umesh

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

Page generated in 0.050 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.