[MDEV-20397] Support TIMESTAMP, DATETIME, TIME in ROUND() and TRUNCATE() Created: 2019-08-21 Updated: 2023-07-19 Resolved: 2019-08-22 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data types, Temporal Types |
| Fix Version/s: | 10.4.8 |
| Type: | Task | Priority: | Critical |
| Reporter: | Alexander Barkov | Assignee: | Alexander Barkov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||
| Description |
|
As of versions 10.3.x and 10.4.7, functions ROUND() and TRUNCATE() convert temporal input to double and then return a rounded/truncated double value. This behaviour is quite useless, because can return '60' at the end:
Therefore a rounded or truncated double value cannot be converted back to TIMESTAMP, DATETIME or TIME easily. In order to fix Let's change these functions to return:
Note, ROUND(timestamp) will return DATETIME for now. It should be fine in 99% cases, but won't work well near DST changes. Let's implement real native TIMESTAMP support in ROUND() in a separate change later. Note, the DATE data type is out of scope of this task. ROUND() and TRUNCATE() will still return a double result for a DATE input. Native DATE support for ROUND() and TRUNCATE() will be implemented separately, when needed. |