fix review comments

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

Branch: refs/heads/master
Commit: 2e70db6b1b990beac4ebe4dcc73233209529b133
Parents: ba17bd3
Author: Liu Ming <ovis_p...@sina.com>
Authored: Thu Sep 15 11:22:44 2016 +0000
Committer: Liu Ming <ovis_p...@sina.com>
Committed: Thu Sep 15 11:22:44 2016 +0000

----------------------------------------------------------------------
 core/sql/exp/exp_function.cpp    | 30 +++++++++---------------------
 core/sql/exp/exp_math_func.cpp   |  2 +-
 core/sql/optimizer/SynthType.cpp |  2 +-
 3 files changed, 11 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/2e70db6b/core/sql/exp/exp_function.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_function.cpp b/core/sql/exp/exp_function.cpp
index 21d3351..e0134de 100644
--- a/core/sql/exp/exp_function.cpp
+++ b/core/sql/exp/exp_function.cpp
@@ -45,11 +45,6 @@
 #include <ctype.h>
 #include <string.h>
 #include <stdio.h>
-/*
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-*/
 
 #include "NLSConversion.h"
 #include "nawstring.h"
@@ -7768,11 +7763,11 @@ static Lng32 string2ipv4(char *srcData, Lng32 slen, 
unsigned int *inet_addr)
 
    if(srcData[0] == ' ')
    { 
-     leadingspace++;
-     for(i=1; i< slen; i++)
+     char * next = srcData;
+     while (*next == ' ')
      {
-       if(srcData[i] == ' ') leadingspace++;
-       else break; 
+       leadingspace++;
+       next++;
      }
    }
    
@@ -7889,14 +7884,10 @@ ex_expr::exp_return_type ExFunctionInetNtoa::eval(char 
* op_data[],
    Attributes *resultAttr = getOperand(0);
    const unsigned char *ipv4_bytes= (const unsigned char *) &addr;
 
-   if( ipv4_bytes[0] > 255 || 
-       ipv4_bytes[1] > 255 ||
-       ipv4_bytes[2] > 255 ||
-       ipv4_bytes[3] > 255 ||
-       addr > 4294967295 )
+   if( addr > 4294967295 ) 
    {
-      ExRaiseSqlError(heap, diags, EXE_INVALID_CHARACTER);
-      *(*diags) << DgString0("IP value") << DgString1("INET_NTOA FUNCTION"); 
+      ExRaiseSqlError(heap, diags, EXE_BAD_ARG_TO_MATH_FUNC);
+      *(*diags) << DgString0("INET_NTOA"); 
       return ex_expr::EXPR_ERROR;
    }
 
@@ -7955,16 +7946,13 @@ ex_expr::exp_return_type ExFunctionIsIP::eval(char * 
op_data[],
     //cannot start with single :
     if (*ptr == ':')
     {
-      ++ptr;
-
-      if (*ptr != ':')
+      if (*(ptr+1) != ':')
       {
         *(Int16 *)op_data[0] = 0;
         return ex_expr::EXPR_OK;
       }
     }
-
-    if (*ptr == ' ')
+    else if (*ptr == ' ')
     {
       while(*ptr==' ') ptr++;
     }     

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/2e70db6b/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 0ed9251..c5209fd 100644
--- a/core/sql/exp/exp_math_func.cpp
+++ b/core/sql/exp/exp_math_func.cpp
@@ -349,7 +349,7 @@ ex_expr::exp_return_type ExFunctionMath::eval(char 
*op_data[],
          return ex_expr::EXPR_ERROR;
        }
       
-      *(double *)op_data[0] = MathLog2(*(double *)op_data[1], err);
+      *(double *)op_data[0] = MathLog10(*(double *)op_data[1], err);
       break;
 
     case ITM_LOG2:

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/2e70db6b/core/sql/optimizer/SynthType.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/SynthType.cpp b/core/sql/optimizer/SynthType.cpp
index e4ee01e..48c2c22 100644
--- a/core/sql/optimizer/SynthType.cpp
+++ b/core/sql/optimizer/SynthType.cpp
@@ -1078,7 +1078,7 @@ const NAType *BuiltinFunction::synthesizeType()
 
        retType = new HEAP
          SQLVarChar(15, FALSE);
-           SQLInt(FALSE, FALSE);
+
        if (typ1.supportsSQLnull())
          {
            retType->setNullable(TRUE);

Reply via email to