Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-6307

Wrong result for IFNULL(FROM_UNIXTIME(..),0)+0

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 5.3.12, 5.5.37, 10.0.11, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8
    • 10.1, 10.3
    • None
    • 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;

      Attachments

        Activity

          People

            bar Alexander Barkov
            bar Alexander Barkov
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.