[MDEV-15999] UNION with different data types can give wrong result Created: 2018-04-24  Updated: 2018-04-24  Resolved: 2018-04-24

Status: Closed
Project: MariaDB Server
Component/s: Data types
Affects Version/s: 5.5, 10.0, 10.1, 10.2
Fix Version/s: 10.3.1

Type: Bug Priority: Major
Reporter: Karl Levik Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: datatype, upstream


 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



 Comments   
Comment by Elena Stepanova [ 2018-04-24 ]

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?

Comment by Karl Levik [ 2018-04-24 ]

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

Generated at Thu Feb 08 08:25:36 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.