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

Controversial comparison behaviour of decimal literals with scale >30

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 5.3.12, 5.5.37, 10.0.11
    • 10.1
    • 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

            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.