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

UNION with different data types can give wrong result

Details

    Description

      Consider this SELECT with UNIONs using different data types for the same column:

      SELECT 20 AS x UNION SELECT null UNION SELECT 2.2;
      

      Gives:

      +------+
      | x    |
      +------+
      | 9.9  |
      | NULL |
      | 2.2  |
      +------+
      

      It seems somewhat non-intuitive that 9.9 becomes 20 ...!

      The issue was first reported here:
      https://dba.stackexchange.com/questions/204757/problem-with-union-casting-integer-to-ceilingdecimal

      Attachments

        Activity

          karll Karl Levik created issue -
          elenst Elena Stepanova added a comment - - edited

          It appears to have been fixed in 10.3, specifically 10.3.1. I can't point at the exact patch right away, but there was a major refactoring work and various bugfixes in the area – MDEV-9495, MDEV-9497, etc.

          Could you please check whether current 10.3 works okay for you?

          elenst Elena Stepanova added a comment - - edited It appears to have been fixed in 10.3, specifically 10.3.1. I can't point at the exact patch right away, but there was a major refactoring work and various bugfixes in the area – MDEV-9495 , MDEV-9497 , etc. Could you please check whether current 10.3 works okay for you?
          elenst Elena Stepanova made changes -
          Field Original Value New Value
          Fix Version/s 10.3.1 [ 22532 ]
          Affects Version/s 10.2 [ 14601 ]
          Affects Version/s 5.5 [ 15800 ]
          Affects Version/s 10.0 [ 16000 ]
          Affects Version/s 10.1 [ 16100 ]
          Labels datatype datatype upstream
          elenst Elena Stepanova made changes -
          Labels datatype upstream datatype need_feedback upstream
          karll Karl Levik added a comment -

          Thank you, yes, this works on my installation of 10.3.6.

          karll Karl Levik added a comment - Thank you, yes, this works on my installation of 10.3.6.
          elenst Elena Stepanova made changes -
          Labels datatype need_feedback upstream datatype upstream
          elenst Elena Stepanova made changes -
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Closed [ 6 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 86749 ] MariaDB v4 [ 154233 ]

          People

            Unassigned Unassigned
            karll Karl Levik
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.