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

Controversial comparison behaviour of decimal literals with scale >30

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 5.3.12, 5.5.37, 10.0.11
    • 10.1(EOL)
    • None
    • None

    Description

      Two decimal literals:
      0.1111111111222222222233333333334444444444
      and
      0.111111111122222222223333333333
      are considered as non-equal by "=",
      but considered as equal for UNION DISTINCT:

      MariaDB [test]> SELECT 0.1111111111222222222233333333334444444444 = 0.111111111122222222223333333333 AS cmp;
      +-----+
      | cmp |
      +-----+
      |   0 |
      +-----+
      1 row in set (0.00 sec)
       
      MariaDB [test]> SELECT 0.1111111111222222222233333333334444444444 AS a UNION SELECT 0.111111111122222222223333333333;
      +----------------------------------+
      | a                                |
      +----------------------------------+
      | 0.111111111122222222223333333333 |
      +----------------------------------+
      1 row in set (0.01 sec)

      Comparison in "=" and comparison in UNION DISTINCT should use the same rules.

      The problem most likely happens because we don't support fields with decimal
      scale > 30. UNION uses a temporary table and creates a field,
      while '=' does not need a field and compares the two numbers directly.

      Literals should probably be fixed not to support more than 30 fractional as well.

      Attachments

        Issue Links

          Activity

            bar Alexander Barkov created issue -
            bar Alexander Barkov made changes -
            Field Original Value New Value
            Summary Controverial comparison behaviour of decimal literals with scale >30 Controversial comparison behaviour of decimal literals with scale >30
            bar Alexander Barkov made changes -
            Description Two decimal literals:
            0.1111111111222222222233333333334444444444
            and
             0.111111111122222222223333333333
            are considered as non-equal by "=",
            but considered as equal for UNION DISTINCT:

            {noformat}
            MariaDB [test]> SELECT 0.1111111111222222222233333333334444444444 = 0.111111111122222222223333333333 AS cmp;
            +-----+
            | cmp |
            +-----+
            | 0 |
            +-----+
            1 row in set (0.00 sec)

            MariaDB [test]> SELECT 0.1111111111222222222233333333334444444444 AS a UNION SELECT 0.111111111122222222223333333333;
            +----------------------------------+
            | a |
            +----------------------------------+
            | 0.111111111122222222223333333333 |
            +----------------------------------+
            1 row in set (0.01 sec)
            {noformat}

            Comparison in "=" and comparison in UNION DISTINCT should use the same rules.

            The problem most likely happens because we don't support fields with decimal
            scale > 30. UNION uses a temporary table and create a field, while
            '=' does not need a field and compares the two numbers directly.

            Literals should probably be fixed not to support more than 30 fractional as well.
            Two decimal literals:
            0.1111111111222222222233333333334444444444
            and
             0.111111111122222222223333333333
            are considered as non-equal by "=",
            but considered as equal for UNION DISTINCT:

            {noformat}
            MariaDB [test]> SELECT 0.1111111111222222222233333333334444444444 = 0.111111111122222222223333333333 AS cmp;
            +-----+
            | cmp |
            +-----+
            | 0 |
            +-----+
            1 row in set (0.00 sec)

            MariaDB [test]> SELECT 0.1111111111222222222233333333334444444444 AS a UNION SELECT 0.111111111122222222223333333333;
            +----------------------------------+
            | a |
            +----------------------------------+
            | 0.111111111122222222223333333333 |
            +----------------------------------+
            1 row in set (0.01 sec)
            {noformat}

            Comparison in "=" and comparison in UNION DISTINCT should use the same rules.

            The problem most likely happens because we don't support fields with decimal
            scale > 30. UNION uses a temporary table and creates a field,
            while '=' does not need a field and compares the two numbers directly.

            Literals should probably be fixed not to support more than 30 fractional as well.
            serg Sergei Golubchik made changes -
            Fix Version/s 10.0.13 [ 16000 ]
            Fix Version/s 5.5.39 [ 15800 ]
            serg Sergei Golubchik made changes -
            Workflow defaullt [ 42100 ] MariaDB v2 [ 44335 ]
            bar Alexander Barkov made changes -
            Fix Version/s 5.5 [ 15800 ]
            serg Sergei Golubchik made changes -
            Assignee Alexander Barkov [ bar ] Sergei Golubchik [ serg ]
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ] Alexander Barkov [ bar ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.1 [ 16100 ]
            Fix Version/s 10.0 [ 16000 ]
            bar Alexander Barkov made changes -
            Priority Major [ 3 ] Minor [ 4 ]
            ratzpo Rasmus Johansson (Inactive) made changes -
            Workflow MariaDB v2 [ 44335 ] MariaDB v3 [ 66878 ]
            monty Michael Widenius made changes -
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 66878 ] MariaDB v4 [ 139657 ]

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              1 Vote for this issue
              Watchers:
              4 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.