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

Bad result for LEAST/GREATEST(datetime_alike_string, time)

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.5, 10.0, 10.1, 10.2, 10.3
    • Fix Version/s: 10.3.5
    • Component/s: Temporal Types
    • Labels:
      None

      Description

      This query returns bad results:

      SELECT
        GREATEST('2010-01-01 10:10:10',TIME('-20:20:20')),
        GREATEST('2010-01-01 10:10:10',TIME('20:20:20')),
        LEAST('2010-01-01 10:10:10',TIME('-20:20:20')),
        LEAST('2010-01-01 10:10:10',TIME('20:20:20'))\G
      

      GREATEST('2010-01-01 10:10:10',TIME('-20:20:20')): 802:10:10.000000
       GREATEST('2010-01-01 10:10:10',TIME('20:20:20')): 802:10:10.000000
         LEAST('2010-01-01 10:10:10',TIME('-20:20:20')): -20:20:20.000000
          LEAST('2010-01-01 10:10:10',TIME('20:20:20')): 20:20:20.000000
      

      Implicit conversion from the string literal '2010-01-01 10:10:10' to TIME does not seem to work well inside LEAST/GREATEST.

      The expected behavior would be to return results similar to this query (with explicit CAST added around the string):

      SELECT
        GREATEST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('-20:20:20')),
        GREATEST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('20:20:20')),
        LEAST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('-20:20:20')),
        LEAST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('20:20:20'))\G
      

      GREATEST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('-20:20:20')): 10:10:10.000000
       GREATEST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('20:20:20')): 20:20:20.000000
         LEAST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('-20:20:20')): -20:20:20.000000
          LEAST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('20:20:20')): 10:10:10.000000
      

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: