diff options
author | unknown <peter@mysql.com> | 2002-07-17 12:11:48 +0400 |
---|---|---|
committer | unknown <peter@mysql.com> | 2002-07-17 12:11:48 +0400 |
commit | c78629effba2b232c5afada4b2e839a1580c0ea8 (patch) | |
tree | 34ee74d8b2d1d25c28e7b9895fdc0a9bbd5d04ad /sql/item_func.cc | |
parent | 6b3e98d505297e6cbd0cbd22d4f46eacb091d924 (diff) | |
download | mariadb-git-c78629effba2b232c5afada4b2e839a1580c0ea8.tar.gz |
Arjens LOG functions changes with small changes and tests added to mysql-test
Docs/manual.texi:
Manual changes to doccument new functions and function changes
mysql-test/r/func_math.result:
Extend tests for LOG family functions
mysql-test/t/func_math.test:
Extend tests for LOG family functions
sql/gen_lex_hash.cc:
Lex hash changes
sql/item_create.cc:
Rename old log function to ln
sql/item_create.h:
More log functions
sql/item_func.cc:
Implementation of new log function behavior
sql/item_func.h:
Class definition for new functions
sql/lex.h:
Function names
sql/sql_yacc.yy:
Symbols for new LOG function
tests/function.res:
One more test result change
tests/function.tst:
One more test change
BitKeeper/etc/logging_ok:
Logging to logging@openlogging.org accepted
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r-- | sql/item_func.cc | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index 4ec4377509f..807f023b308 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -437,14 +437,43 @@ void Item_func_abs::fix_length_and_dec() hybrid_type= args[0]->result_type() == INT_RESULT ? INT_RESULT : REAL_RESULT; } +/* Gateway to natural LOG function */ +double Item_func_ln::val() +{ + double value=args[0]->val(); + if ((null_value=(args[0]->null_value || value <= 0.0))) + return 0.0; + return log(value); +} + +/* + Extended but so slower LOG function + We have to check if all values are > zero and first one is not one + as these are the cases then result is not a number. +*/ double Item_func_log::val() { double value=args[0]->val(); if ((null_value=(args[0]->null_value || value <= 0.0))) - return 0.0; /* purecov: inspected */ + return 0.0; + if (arg_count == 2) + { + double value2= args[1]->val(); + if ((null_value=(args[1]->null_value || value2 <= 0.0 || value == 1.0))) + return 0.0; + return log(value2) / log(value); + } return log(value); } +double Item_func_log2::val() +{ + double value=args[0]->val(); + if ((null_value=(args[0]->null_value || value <= 0.0))) + return 0.0; + return log(value) / log(2.0); +} + double Item_func_log10::val() { double value=args[0]->val(); |