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

CAST(TIME'10:10:10' AS DATE) - regression

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 10.0.8
    • Fix Version/s: 10.0
    • Component/s: None
    • Labels:
      None

      Description

      CAST(TIME'10:10:10' AS DATE) returns '2010-10-10' in MariaDB-5.5 and
      in MySQL.

      MariaDB-10.0 returns '0000-00-00'.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            serg Sergei Golubchik added a comment -

            Is that bad? I think the new result is ok. The date part of TIME'10:10:10' is DATE'0000-00-00'. You can see that explicitly when casting to datetime, it'll be DATETIME'0000-00-00 10:10:10'.

            There's no logical explanation why the date part of TIME'10:10:10' shoud be '2010-10-10'. And I don't consider "because we internally cast time to a string and then to date" a particularly convincing explanation.

            Compare, for example, with double→integer cast:

            MariaDB [test]> select concat(1e15), cast(1e15 as unsigned);
            +--------------+------------------------+
            | concat(1e15) | cast(1e15 as unsigned) |
            +--------------+------------------------+
            | 1e15         |       1000000000000000 |
            +--------------+------------------------+
            

            when casted to a string, it's "1e15". If you cast this string to an integer, you get "1". But double→integer cast is not using strings, that's you get the correct result — the integer part of the floating-point number.

            Show
            serg Sergei Golubchik added a comment - Is that bad? I think the new result is ok. The date part of TIME'10:10:10' is DATE'0000-00-00'. You can see that explicitly when casting to datetime, it'll be DATETIME'0000-00-00 10:10:10'. There's no logical explanation why the date part of TIME'10:10:10' shoud be '2010-10-10'. And I don't consider "because we internally cast time to a string and then to date" a particularly convincing explanation. Compare, for example, with double→integer cast: MariaDB [test]> select concat(1e15), cast(1e15 as unsigned); +--------------+------------------------+ | concat(1e15) | cast(1e15 as unsigned) | +--------------+------------------------+ | 1e15 | 1000000000000000 | +--------------+------------------------+ when casted to a string, it's "1e15". If you cast this string to an integer, you get "1". But double→integer cast is not using strings, that's you get the correct result — the integer part of the floating-point number.

              People

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

                Dates

                • Created:
                  Updated: