Bug #61224 | function pow is wrong | ||
---|---|---|---|
Submitted: | 19 May 2011 10:13 | Modified: | 23 May 2011 1:45 |
Reporter: | YanHui Wang | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: DML | Severity: | S3 (Non-critical) |
Version: | 5.5.12 | OS: | Windows (XP) |
Assigned to: | CPU Architecture: | Any | |
Tags: | pow, regression |
[19 May 2011 10:13]
YanHui Wang
[19 May 2011 11:03]
Valeriy Kravchuk
Can you give specific example of wrong value returned? I do not see any problem: mysql> select power(2,3); +------------+ | power(2,3) | +------------+ | 8 | +------------+ 1 row in set (0.11 sec) mysql> select power(-2,3); +-------------+ | power(-2,3) | +-------------+ | -8 | +-------------+ 1 row in set (0.02 sec)
[21 May 2011 2:38]
YanHui Wang
The SQL below run in MySQL Community Server 5.5.12, select pow(-1, 1/2); Error Code: 1690 DOUBLE value is out of range in 'pow(-(2),(1 / 2))' if the SQL run in MySQL Community Server 5.1, it is OK.
[21 May 2011 7:11]
Valeriy Kravchuk
Indeed, in 5.1.x we get NULL (there is no real number as a result of pow(-1, 1/2)), while in 5.5 we get error message that looks misleading: macbook-pro:5.5 openxs$ bin/mysql -uroot test Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.15-debug Source distribution Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> select pow(-2, (1/2)); ERROR 1690 (22003): DOUBLE value is out of range in 'pow(-(2),(1 / 2))' mysql> select pow(-1, 1/2); ERROR 1690 (22003): DOUBLE value is out of range in 'pow(-(1),(1 / 2))'
[23 May 2011 1:45]
YanHui Wang
Thanks for your reply.
[11 Feb 2018 13:48]
Roy Lyseng
Posted by developer: Reporting an error is in this case is correct according to SQL standard. However, the error message is misleading and could be improved.