| Bug #31017 | GREATEST() and LEAST() implicitly converts the wrong way if used with mixed args | ||
|---|---|---|---|
| Submitted: | 14 Sep 2007 4:21 | Modified: | 27 Sep 2007 8:53 |
| Reporter: | Tobias Asplund | Email Updates: | |
| Status: | Won't fix | Impact on me: | |
| Category: | MySQL Server | Severity: | S4 (Feature request) |
| Version: | 5.0.45 | OS: | MacOS |
| Assigned to: | CPU Architecture: | Any | |
[14 Sep 2007 5:00]
Valeriy Kravchuk
Thank you for a reasonable feature request. Indeed, this:
mysql> SELECT GREATEST('B', 'C', 1);
+-----------------------+
| GREATEST('B', 'C', 1) |
+-----------------------+
| 1 |
+-----------------------+
1 row in set, 2 warnings (0.00 sec)
mysql> show warnings;
+---------+------+---------------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------------+
| Warning | 1292 | Truncated incorrect DOUBLE value: 'B' |
| Warning | 1292 | Truncated incorrect DOUBLE value: 'C' |
+---------+------+---------------------------------------+
2 rows in set (0.02 sec)
is not the best way. It should be processed as GREATEST('B', 'C', '1') by default.
[27 Sep 2007 8:53]
Sergei Golubchik
This is questionable.
What about GREATEST('000100', ' 2', 1) ?
Besides, the current behavior is clearly documented, see
http://dev.mysql.com/doc/refman/5.0/en/type-conversion.html

Description: When mixing data types in GREATEST() and LEAST() the server should use a common data-type (such as a string based) instead of trying to convert everything to doubles. How to repeat: -- Those two work as expected SELECT GREATEST(2, 1, 3); SELECT GREATEST('B', 'C', 'A'); -- But change to mixed mode: SELECT GREATEST('B', 'C', 1); -- This works as expected, but my argument is the server should -- pick this up itself. SELECT GREATEST('B', 'C', '1');