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

            People

            • Assignee:
              Unassigned
              Reporter:
              karll Karl Levik
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: