Bug #13820 Handling of logarithm math functions with negative values
Submitted: 6 Oct 2005 20:45 Modified: 27 Oct 2005 9:39
Reporter: Kristian Koehntopp Email Updates:
Status: Closed Impact on me:
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.13 OS:Linux (Suse Linux 9.3)
Assigned to: Alexey Botchkov CPU Architecture:Any

[6 Oct 2005 20:45] Kristian Koehntopp
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 ***************************
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 7: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:

[17 Oct 2005 13:38] Alexander Barkov
Ok to push.
[27 Oct 2005 9: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

Additional info:

Documented feature change in 5.0.16 changelog. Closed.