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

TIME() returns NULL directly but evaluates as equal to its numeric argument in comparison context

    XMLWordPrintable

Details

    Description

      On MariaDB 12.3.3, TIME(190794907) returns NULL when selected directly, but comparing it with its numeric argument returns TRUE. Adding +0 to the TIME() expression makes the comparison return NULL.

      SELECT
        TIME(190794907) AS direct,
        190794907 = TIME(190794907) AS comparison,
        190794907 = (TIME(190794907) + 0) AS numeric_comparison;
       
      +--------+------------+--------------------+
      | direct | comparison | numeric_comparison |
      +--------+------------+--------------------+
      | NULL   |          1 | NULL               |
      +--------+------------+--------------------+
      

      Expected result:

      +--------+------------+--------------------+
      | direct | comparison | numeric_comparison |
      +--------+------------+--------------------+
      | NULL   | NULL       | NULL               |
      +--------+------------+--------------------+
      

      Since TIME(190794907) evaluates to NULL, an ordinary equality comparison with that result should also evaluate to NULL, rather than TRUE.

      The result suggests that TIME() is evaluated differently in temporal comparison context than when selected directly or used in numeric context.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:

                Git Integration

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