Bug #120256 CREATE VIEW materialization turns zero datetime values into runtime timestamps in UNION ALL output
| Submitted: | 13 Apr 11:44 | Modified: | 13 Apr 12:47 |
|---|---|---|---|
| Reporter: | Peiyuan Liu | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) |
| Version: | 8.4.8 | OS: | Any |
| Assigned to: | CPU Architecture: | Any |
[13 Apr 12:47]
Chaithra Marsur Gopala Reddy
Hi Peiyuan Liu, Thank you for test case. Verified as described.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.049 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.
Description: Materializing an aggregated `TIME` value as a view changes a zero datetime value into a runtime timestamp when the value is later combined with a `DATE` branch through `UNION ALL`. The transformed query should preserve the original zero datetime row, but instead returns a row with a different datetime value. How to repeat: DROP DATABASE IF EXISTS t1; CREATE DATABASE t1; USE t1; CREATE TABLE t3 ( c5 TIME ); INSERT INTO t3 VALUES ('00:00:00'); SELECT MIN(cuc28.c5) AS col_1 FROM t3 AS cuc28 UNION ALL SELECT DATE('2025-01-01') AS col_1; CREATE VIEW V_cuc28_fe3c0f30 AS SELECT MIN(cuc28.c5) AS col_1 FROM t3 AS cuc28; SELECT V_cuc28_fe3c0f30.col_1 AS col_1 FROM V_cuc28_fe3c0f30 UNION ALL SELECT DATE('2025-01-01') AS col_1; Original result: +---------------------+ | col_1 | +---------------------+ | 0000-00-00 00:00:00 | | 2025-01-01 00:00:00 | +---------------------+ After create view, result: +---------------------+ | col_1 | +---------------------+ | 2026-04-13 00:00:00 | | 2025-01-01 00:00:00 | +---------------------+