Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-17776

CAST(x AS INTERVAL DAY_SECOND(N))

    XMLWordPrintable

    Details

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bar Alexander Barkov
              Reporter:
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: