[MDEV-17776] CAST(x AS INTERVAL DAY_SECOND(N)) Created: 2018-11-20  Updated: 2018-11-21  Resolved: 2018-11-20

Status: Closed
Project: MariaDB Server
Component/s: Temporal Types
Fix Version/s: 10.4.1

Type: Task Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-16991 Rounding vs truncation for TIME, DATE... Closed
Relates
relates to MDEV-17351 Wrong results for GREATEST,TIMESTAMP,... Closed
relates to MDEV-17740 Extend EXTRACT(x AS DAY*) to understa... Closed

 Description   

To write mtr tests easier, we'll add CAST(x AS INTERVAL DAY_SECOND(N)).
For now it will return a VARCHAR with a specific format:

[+][DD ]hh:mm:ss[.ffffff]

It will be helpful to write tests with functions that now understand long time intervals:

  • TIMESTMP(ts, time_interval)
  • ADDTIME(ts, time_interval)
  • EXTRACT(DAY FROM src)

So in this query:

SELECT
  CAST(1223344.123456 AS INTERVAL DAY_SECOND(6)) AS cast_itds,
  EXTRACT(DAY FROM 1223344.123456) AS d,
  EXTRACT(HOUR FROM 1223344.123456) AS h;

+-------------------+------+------+
| cast_itds         | d    | h    |
+-------------------+------+------+
| 5 02:33:44.123456 |    5 |    2 |
+-------------------+------+------+

it will be clear how the day and the hour value are calculated.


Generated at Thu Feb 08 08:39:01 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.