[MDEV-4882] Conversion of TIME to DATETIME works differently in MariaDB and MySQL Created: 2013-08-10 Updated: 2013-08-20 Resolved: 2013-08-10 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 10.0.4 |
| Fix Version/s: | 10.0.5 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Elena Stepanova | Assignee: | Alexander Barkov |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Description |
|
I haven't found this one among filed bugs, maybe it was just put in a different way; please feel free to close as a duplicate if so There was a change in MySQL 5.6.4:
It works in MySQL 5.6, but not in MariaDB 10.0.4 candidate:
|
| Comments |
| Comment by Sergei Golubchik [ 2013-08-10 ] | ||||
|
It was intentionally implemented deviation from MySQL behavior | ||||
| Comment by Elena Stepanova [ 2013-08-10 ] | ||||
|
Okay, but then I think we need a proper explanation why it was chosen this way, because people will be asking, and a deviation without a reason doesn't look good. I haven't found it in KB in types section, but maybe it's somewhere else? | ||||
| Comment by Alexander Barkov [ 2013-08-12 ] | ||||
|
IIRC, the SQL standard does not have implicit conversion from TIME to TIMESTAMP. "SQL:2011 Part 2 Foundation, section <cast specification>" says the following about cast from TIME to TIMESTAMP: > The fields year, month, and day of TV (the target value) are set to their I'd vote to apply the same rules to for CAST and for implicit conversion, Serg, what was the reason not to use these rules in MariaDB? | ||||
| Comment by Sergei Golubchik [ 2013-08-14 ] | ||||
|
Simply because we found it so weird and counter-intuitive that we intentionally diverged from the standard here. The notion that a result of a type cast depends not only on the original value and the desired type, but also on the current date? And produces non-repeatable results? That's a serious gotcha. I believe our approach is more logical, even if non-standard. | ||||
| Comment by Alexander Barkov [ 2013-08-20 ] | ||||
|
The way it's implemented now is make it depend on sql_mode, ----------------------------------
----------------------------------
---------------------------------- MariaDB [test]> set sql_mode=no_zero_date; MariaDB [test]> select cast(time'10:20:30' as datetime);
----------------------------------
---------------------------------- |