You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by li...@apache.org on 2016/11/30 23:31:42 UTC

[2/3] incubator-trafodion git commit: Add tests for builtin function LOG() of any base

Add tests for builtin function LOG() of any base


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/df1f430a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/df1f430a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/df1f430a

Branch: refs/heads/master
Commit: df1f430ae2aaaa22fda7931b938be267096bebba
Parents: 1f9071a
Author: ryzuo <jo...@gmail.com>
Authored: Mon Nov 28 08:39:45 2016 +0000
Committer: ryzuo <jo...@gmail.com>
Committed: Tue Nov 29 05:25:56 2016 +0000

----------------------------------------------------------------------
 core/sql/exp/exp_math_func.cpp              | 18 +++++-----
 core/sql/regress/compGeneral/EXPECTED006.SB | 42 ++++++++++++++++++++++++
 core/sql/regress/compGeneral/TEST006        |  7 ++++
 3 files changed, 58 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/df1f430a/core/sql/exp/exp_math_func.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_math_func.cpp b/core/sql/exp/exp_math_func.cpp
index c477c53..6978430 100644
--- a/core/sql/exp/exp_math_func.cpp
+++ b/core/sql/exp/exp_math_func.cpp
@@ -340,19 +340,19 @@ ex_expr::exp_return_type ExFunctionMath::eval(char *op_data[],
 	}
 
       if(3 == getNumOperands())
-    {
-        double power = *(double *)op_data[2];
-        double radix = *(double *)op_data[1];
-        if(power <= 0 || 1 == radix)
-        {
+	{
+          double power = *(double *)op_data[2];
+          double radix = *(double *)op_data[1];
+          if(power <= 0 || radix <= 0 || 1 == radix)
+          {
             ExRaiseSqlError(heap, diagsArea, EXE_BAD_ARG_TO_MATH_FUNC);
             **diagsArea << DgString0("LOG");
             return ex_expr::EXPR_ERROR;
+          }
+
+          *(double *)op_data[0] = MathLogX(radix, power, err);
         }
-        
-        *(double *)op_data[0] = MathLogX(radix, power, err);
-    }
-    else  
+      else
         *(double *)op_data[0] = MathLog(*(double *)op_data[1], err);
       break;
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/df1f430a/core/sql/regress/compGeneral/EXPECTED006.SB
----------------------------------------------------------------------
diff --git a/core/sql/regress/compGeneral/EXPECTED006.SB b/core/sql/regress/compGeneral/EXPECTED006.SB
index 741b6dc..58bfdfe 100644
--- a/core/sql/regress/compGeneral/EXPECTED006.SB
+++ b/core/sql/regress/compGeneral/EXPECTED006.SB
@@ -1825,4 +1825,46 @@ bc0050f3ff7a540c74a42664c53a7f9fd485622374a43eb4a62cd84e48f483237bed50f6562f8c6e
 18091a172d94aae1ae530ced02bde7f022229f446348f5d3b36989c2e6fd59f5252c7a7f8ecb71a74cb724448243ff71651f87aed155aee7340fad1b02567b60
 
 --- 1 row(s) selected.
+>>
+>>-- Test LOG() for any radix with 2 parameters
+>>select log(2,8) from dual;
+
+(EXPR)                   
+-------------------------
+
+ 3.00000000000000000E+000
+
+--- 1 row(s) selected.
+>>select log(5,10) from dual;
+
+(EXPR)                   
+-------------------------
+
+ 1.43067655807339328E+000
+
+--- 1 row(s) selected.
+>>select log(10,100) from dual;
+
+(EXPR)                   
+-------------------------
+
+ 2.00000000000000000E+000
+
+--- 1 row(s) selected.
+>>select log(2) from dual;
+
+(EXPR)                   
+-------------------------
+
+ 6.93147180559945344E-001
+
+--- 1 row(s) selected.
+>>select log(2.71828) from dual;
+
+(EXPR)                   
+-------------------------
+
+ 9.99999327347282176E-001
+
+--- 1 row(s) selected.
 >>log;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/df1f430a/core/sql/regress/compGeneral/TEST006
----------------------------------------------------------------------
diff --git a/core/sql/regress/compGeneral/TEST006 b/core/sql/regress/compGeneral/TEST006
index edee936..2c9e2d1 100644
--- a/core/sql/regress/compGeneral/TEST006
+++ b/core/sql/regress/compGeneral/TEST006
@@ -679,3 +679,10 @@ select sha2('the original data', 224) from dual;
 select sha2('the original data', 256) from dual;
 select sha2('the original data', 384) from dual;
 select sha2('the original data', 512) from dual;
+
+-- Test LOG() for any radix with 2 parameters
+select log(2,8) from dual;
+select log(5,10) from dual;
+select log(10,100) from dual;
+select log(2) from dual;
+select log(2.71828) from dual;