Bug #13820 Handling of logarithm math functions with negative values
Submitted: 6 Oct 2005 22:45 Modified: 27 Oct 2005 11:39
Reporter: Kristian Koehntopp
Status: Closed
Category:Server Severity:S3 (Non-critical)
Version:5.0.13 OS:Linux (Suse Linux 9.3)
Assigned to: Alexey Botchkov Target Version:

[6 Oct 2005 22:45] Kristian Koehntopp
Description:
Logarithm functions are undefined for negative values. Using them produces a NULL, but no
warning or error, not even in strict mode. This differs from handling 1/0 (division by
zero), but is a similar situation.

How to repeat:
mysql> select version()\G
*************************** 1. row ***************************
version(): 5.0.13-rc-max
1 row in set (0.00 sec)

mysql> select @@sql_mode\G
*************************** 1. row ***************************
@@sql_mode:
STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_Z
ERO,TRADITIONAL,NO_AUTO_CREATE_USER
1 row in set (0.00 sec)
mysql> select ln(-3)\G
*************************** 1. row ***************************
ln(-3): NULL
1 row in set (0.00 sec)

mysql> select log10(-3)\G
*************************** 1. row ***************************
log10(-3): NULL
1 row in set (0.00 sec)

Suggested fix:
Handle such values in a manner consistent with 1/0, produce a warning when
ERROR_FOR_DIVISION_BY_ZERO or something equivalent is set, and promote the warning to
error when STRICT_TRANS_TABLES or STRICT_ALL_TABLES is set.
[17 Oct 2005 9:16] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/31162
[17 Oct 2005 15:38] Alexander Barkov
Ok to push.
[27 Oct 2005 11:39] Jon Stephens
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Documented feature change in 5.0.16 changelog. Closed.