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

Bad result for LEAST/GREATEST(datetime_alike_string, time)

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.5, 10.0, 10.1, 10.2, 10.3
    • 10.3.5
    • Temporal Types
    • 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

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

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.