← Back to team overview

maria-developers team mailing list archive

Sprint 10.0: MDEV-8205 timediff returns null when comparing decimal time to time string value

 

Hi Sergei,


I'm not sure what to do with this:

MariaDB [test]> select
    -> timediff('2014-01-01 00:00:00' , '2014-01-01 01:00:00' ),
    ->     timediff(20140101000000.000 , 20140101010000.000  ),
    -> timediff(20140101000000.000 , '2014-01-01 01:00:00' ),
    -> datediff('2014-01-01 00:00:00' , '2014-01-02 01:00:00' ),
    ->     datediff(20140101000000.000 , 20140102010000.000  ),
    -> datediff(20140101000000.000 , '2014-01-02 01:00:00' )\G
*************************** 1. row ***************************
timediff('2014-01-01 00:00:00' , '2014-01-01 01:00:00' ): -01:00:00
     timediff(20140101000000.000 , 20140101010000.000  ): -01:00:00.000
   timediff(20140101000000.000 , '2014-01-01 01:00:00' ): NULL
datediff('2014-01-01 00:00:00' , '2014-01-02 01:00:00' ): -1
     datediff(20140101000000.000 , 20140102010000.000  ): -1
   datediff(20140101000000.000 , '2014-01-02 01:00:00' ): -1
1 row in set (0.03 sec)

Notice, it returns NULL in one case.

The problem is in this piece of the code:

  if (args[0]->get_time(&l_time1) ||
      args[1]->get_time(&l_time2) ||
      l_time1.time_type != l_time2.time_type)
    return (null_value= 1);

get_time() forces decimal-to-time conversion to truncate the date part
and return MYSQL_TIMESTAMP_TIME.

get_time() does not force string-to-time conversion to truncate the date part. It still returns the full MYSQL_TIMESTAMP_DATETIME.

I'm afraid a lot of the code rely in this behavior.
If we fix string-to-time conversion, mtr will start to fail in other cases.

Any ideas what to do?


Follow ups