[MDEV-6307] Wrong result for IFNULL(FROM_UNIXTIME(..),0)+0 Created: 2014-06-05  Updated: 2022-12-01

Status: Confirmed
Project: MariaDB Server
Component/s: None
Affects Version/s: 5.3.12, 5.5.37, 10.0.11, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8
Fix Version/s: 10.1, 10.3

Type: Bug Priority: Minor
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 1
Labels: None


 Description   

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
SELECT a, FROM_UNIXTIME(CONCAT(a,'10')) AS f1, IFNULL(FROM_UNIXTIME(CONCAT(a,'10')),0)+0  AS f2 FROM t1;

returns

+------------+---------------------+------+
| a          | f1                  | f2   |
+------------+---------------------+------+
| 2005-05-04 | 1970-01-01 03:33:25 | 1970 |
| 2000-02-23 | 1970-01-01 03:33:20 | 1970 |
+------------+---------------------+------+

The expected result for f2 is 19700101033325 and 19700101033330.

The same problem happens with IF:

SELECT a, FROM_UNIXTIME(CONCAT(a,'10')) AS f1, IF(1,FROM_UNIXTIME(CONCAT(a,'10')),0)+0  AS f2 FROM t1;



 Comments   
Comment by Alexander Barkov [ 2014-07-29 ]

The problem is that IFNULL(temporal,int) returns a VARCHAR result.
It should return an INT or DECIMAL result.

Comment by Alexander Barkov [ 2014-07-29 ]

Removing 5.3 and 5.5 from fixVersion, as agreed with Sergei on IRC.

Generated at Thu Feb 08 07:10:54 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.