[MDEV-3607] LP:738096 - DATEDIFF with a 0000-00-00 argument produces different result in 5.1-micro Created: 2011-03-19 Updated: 2015-02-02 Resolved: 2012-10-04 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor |
| Reporter: | Philip Stoev (Inactive) | Assignee: | Sergei Golubchik |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | Launchpad | ||
| Attachments: |
|
| Description |
|
The following expression: SELECT DATEDIFF( '2004-08-07' , DATE ( '0000-00-00 00:00:00')); returns NULL in 5.1-micro and 732165 in mysql-5.1 In this case it seems safer and backward compatible to allow people to use the 0000-00-00 date in datediff calculations. It is plausible that such an expression can occur in a real life query. |
| Comments |
| Comment by Sergei Golubchik [ 2011-03-19 ] | ||||
|
Re: DATEDIFF with a 0000-00-00 argument produces different result in 5.1-micro mysql> select to_days(date('0000-00-00')), to_days('0000-00-00');
----------------------------
---------------------------- The first behavior is tested in the func_time.test. TO_DAYS() does not want its argument to be a zero date, and it uses TIME_NO_ZERO_DATE to indicate that: longlong Item_func_to_days::val_int() But DATE() function (which is Item_date_typecast::get_date()) was ignoring the second argument, basically violating caller's requirements. That's why it was possible to get a zero date via DATE(), but not from a string directly. The bug appeared because DATE() is now fixed to obey caller's requirements. I see two solutions for this bug:
| ||||
| Comment by Sergei Golubchik [ 2011-03-19 ] | ||||
|
Re: DATEDIFF with a 0000-00-00 argument produces different result in 5.1-micro | ||||
| Comment by Rasmus Johansson (Inactive) [ 2011-10-28 ] | ||||
|
Launchpad bug id: 738096 |