Comments - Datetime behavior in MariaDB vs MySQL

5 years, 11 months ago Ian Gilfillan

One of the issues listed on the compatibility page is that MariaDB performs stricter checking of date, datetime and timestamp values. If you look at the warnings with SHOW WARNINGS (with an S) you'll see different warnings on the insert as well.

 
5 years, 11 months ago Mark Kirk

Thanks for the reply Ian.

I saw this: "MariaDB performs stricter checking of date, datetime and timestamp values."

But if MariaDB is stricter why is it returning a zero date record with the warning while MySQL is returning an empty set and only warnings? I assume this is deliberate behavior and not due to any setting.

Thanks

 
5 years, 11 months ago Ian Gilfillan

MariaDB considers all badly formatted strings as '0000-00-00 00:00:00' for comparison purposes. Current versions of MySQL are inconsistent, in that they handle constants one way, and non-constants another way.

Consider the following example from MySQL, with confusing results:

SET sql_mode='';
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a FLOAT, b DATETIME, c TIME, d VARCHAR(10));
INSERT INTO t1 VALUES ( 111.222, '23Apr75', '05May99', 'a');
SELECT * FROM t1 WHERE b='31Jan1999';
SELECT * FROM t1 WHERE b=IF(RAND(),'31Jan1999','31Jan1999');

SELECT * FROM t1 WHERE b='31Jan1999';
Empty set, 2 warnings (0.00 sec)

SELECT * FROM t1 WHERE b=IF(RAND(),'31Jan1999','31Jan1999');
+---------+---------------------+----------+------+
| a       | b                   | c        | d    |
+---------+---------------------+----------+------+
| 111.222 | 0000-00-00 00:00:00 | 00:00:05 | a    |
+---------+---------------------+----------+------+
1 row in set, 1 warning (0.00 sec)
 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.