trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lium...@apache.org
Subject [4/5] incubator-trafodion git commit: fix for PR comments
Date Tue, 08 Nov 2016 09:25:11 GMT
fix for PR 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/63e53386
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/63e53386
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/63e53386

Branch: refs/heads/master
Commit: 63e533864d830e11488bdcf97a25b11238ff16fd
Parents: ece38ae
Author: Liu Ming <ovis_poly@sina.com>
Authored: Fri Nov 4 01:56:52 2016 -0400
Committer: Liu Ming <ovis_poly@sina.com>
Committed: Fri Nov 4 01:56:52 2016 -0400

----------------------------------------------------------------------
 core/sql/common/OperTypeEnum.h              |  1 -
 core/sql/exp/exp_clause.cpp                 |  5 ++---
 core/sql/exp/exp_clause.h                   |  3 +--
 core/sql/exp/exp_function.cpp               | 27 ++++++++++++------------
 core/sql/generator/GenItemFunc.cpp          |  1 -
 core/sql/optimizer/BindItemExpr.cpp         |  1 -
 core/sql/optimizer/SynthType.cpp            |  1 -
 core/sql/parser/sqlparser.y                 | 16 --------------
 core/sql/regress/compGeneral/EXPECTED006.SB | 20 ++++++++++++++++++
 core/sql/regress/compGeneral/TEST006        |  3 +++
 10 files changed, 40 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/63e53386/core/sql/common/OperTypeEnum.h
----------------------------------------------------------------------
diff --git a/core/sql/common/OperTypeEnum.h b/core/sql/common/OperTypeEnum.h
index 4f1bd1e..cb755df 100644
--- a/core/sql/common/OperTypeEnum.h
+++ b/core/sql/common/OperTypeEnum.h
@@ -791,7 +791,6 @@ enum OperatorTypeEnum {
                         ITM_MD5       = 2635,
                         ITM_SHA1      = 2636,
                         ITM_SHA2      = 2637,
-                        ITM_SHA       = 2638,
 
                         // Items for needed for Translating to UCS2 output strings
                         ITM_DATEFMT     = 2990,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/63e53386/core/sql/exp/exp_clause.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_clause.cpp b/core/sql/exp/exp_clause.cpp
index 2f8f9be..c527c77 100644
--- a/core/sql/exp/exp_clause.cpp
+++ b/core/sql/exp/exp_clause.cpp
@@ -338,9 +338,8 @@ ex_clause::ex_clause(clause_type type,
 	case ITM_CURR_TRANSID:
 	  setClassID(FUNC_CURR_TRANSID_ID);
 	  break;
-        case ITM_SHA:
         case ITM_SHA1:
-          setClassID(FUNC_SHA_ID);
+          setClassID(FUNC_SHA1_ID);
           break;
         case ITM_SHA2:
           setClassID(FUNC_SHA2_ID);
@@ -1003,7 +1002,7 @@ NA_EIDPROC char *ex_clause::findVTblPtr(short classID)
     case ex_clause::FUNC_HBASE_VERSION:
       GetVTblPtr(vtblPtr, ExFunctionHbaseVersion);
       break;
-    case ex_clause::FUNC_SHA_ID:
+    case ex_clause::FUNC_SHA1_ID:
       GetVTblPtr(vtblPtr, ExFunctionSha);
       break;
     case ex_clause::FUNC_SHA2_ID:

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/63e53386/core/sql/exp/exp_clause.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_clause.h b/core/sql/exp/exp_clause.h
index 1e9b926..275914b 100644
--- a/core/sql/exp/exp_clause.h
+++ b/core/sql/exp/exp_clause.h
@@ -207,8 +207,7 @@ public:
     FUNC_CRC32_ID            = 122,
     FUNC_MD5_ID              = 123,
     FUNC_SHA1_ID             = 124,
-    FUNC_SHA2_ID             = 125,
-    FUNC_SHA_ID              = 126
+    FUNC_SHA2_ID             = 125
   };
 
   // max number of operands (including result) in a clause.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/63e53386/core/sql/exp/exp_function.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_function.cpp b/core/sql/exp/exp_function.cpp
index 439e944..22fef99 100644
--- a/core/sql/exp/exp_function.cpp
+++ b/core/sql/exp/exp_function.cpp
@@ -41,7 +41,7 @@
 
 #include <math.h>
 #include <zlib.h>
-#include "openssl/md5.h"
+#include <openssl/md5.h>
 #include <openssl/sha.h>  
 
 #define MathSqrt(op, err) sqrt(op)
@@ -7968,19 +7968,19 @@ ex_expr::exp_return_type ExFunctionSha2::eval(char * op_data[],
   Lng32 slen = srcAttr->getLength(op_data[-MAX_OPERANDS+1]);
   Lng32 rlen = resultAttr->getLength();
 
-  memset(op_data[0], 0, rlen);
+  str_pad(op_data[0], rlen, ' ');
 
   SHA256_CTX  sha_ctx;
 
   SHA256_Init(&sha_ctx);  
   SHA256_Update(&sha_ctx, op_data[1], slen);
   SHA256_Final((unsigned char*) sha,&sha_ctx); 
-  char tmp[2];
+  char tmp[3];
   for(int i=0; i < SHA256_DIGEST_LENGTH; i++ )
   {
-    tmp[0]=tmp[1]='0';
+    tmp[0]=tmp[1]=tmp[2]='0';
     sprintf(tmp, "%.2x", (int)sha[i]);
-    memcpy(op_data[0]+i*2, tmp, 2);
+    str_cpy_all(op_data[0]+i*2, tmp, 2);
   }
    
   return ex_expr::EXPR_OK;
@@ -7997,19 +7997,19 @@ ex_expr::exp_return_type ExFunctionSha::eval(char * op_data[],
   Attributes *srcAttr   = getOperand(1);
   Lng32 slen = srcAttr->getLength(op_data[-MAX_OPERANDS+1]);
   Lng32 rlen = resultAttr->getLength();
-  memset(op_data[0], 0, rlen);
+  str_pad(op_data[0], rlen , ' ');
 
   SHA_CTX  sha_ctx;
 
   SHA1_Init(&sha_ctx);  
   SHA1_Update(&sha_ctx, op_data[1], slen);
   SHA1_Final((unsigned char*) sha,&sha_ctx); 
-  char tmp[2];
+  char tmp[3];
   for(int i=0; i < SHA_DIGEST_LENGTH ; i++ )
   {
-    tmp[0]=tmp[1]='0';
+    tmp[0]=tmp[1]=tmp[2]='0';
     sprintf(tmp, "%.2x", (int)sha[i]);
-    memcpy(op_data[0]+i*2, tmp, 2);
+    str_cpy_all(op_data[0]+i*2, tmp, 2);
   }
    
   return ex_expr::EXPR_OK;
@@ -8027,18 +8027,19 @@ ex_expr::exp_return_type ExFunctionMd5::eval(char * op_data[],
   Lng32 slen = srcAttr->getLength(op_data[-MAX_OPERANDS+1]);
   Lng32 rlen = resultAttr->getLength();
 
-  memset(op_data[0], 0, rlen);
+  str_pad(op_data[0], rlen, ' ');
   MD5_CTX  md5_ctx;
 
   MD5_Init(&md5_ctx);  
   MD5_Update(&md5_ctx, op_data[1], slen);
   MD5_Final((unsigned char*) md5,&md5_ctx); 
-  char tmp[2];
+
+  char tmp[3];
   for(int i=0; i < 16; i++ )
   {
-    tmp[0]=tmp[1]='0';
+    tmp[0]=tmp[1]=tmp[2]='0';
     sprintf(tmp, "%.2x", (int)md5[i]);
-    memcpy(op_data[0]+i*2, tmp, 2);
+    str_cpy_all(op_data[0]+i*2, tmp, 2);
   }
    
   return ex_expr::EXPR_OK;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/63e53386/core/sql/generator/GenItemFunc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenItemFunc.cpp b/core/sql/generator/GenItemFunc.cpp
index 685fa6f..77d9913 100644
--- a/core/sql/generator/GenItemFunc.cpp
+++ b/core/sql/generator/GenItemFunc.cpp
@@ -218,7 +218,6 @@ short BuiltinFunction::codeGen(Generator * generator)
       
       break;
 
-   case ITM_SHA:
    case ITM_SHA1:
       {
          function_clause =

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/63e53386/core/sql/optimizer/BindItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindItemExpr.cpp b/core/sql/optimizer/BindItemExpr.cpp
index f24f318..32f84c4 100644
--- a/core/sql/optimizer/BindItemExpr.cpp
+++ b/core/sql/optimizer/BindItemExpr.cpp
@@ -3165,7 +3165,6 @@ ItemExpr *BuiltinFunction::bindNode(BindWA *bindWA)
     case ITM_ISIPV6:
     case ITM_MD5:
     case ITM_CRC32:
-    case ITM_SHA:
     case ITM_SHA1:
     case ITM_SHA2:
       {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/63e53386/core/sql/optimizer/SynthType.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/SynthType.cpp b/core/sql/optimizer/SynthType.cpp
index 7373d3c..8c78d85 100644
--- a/core/sql/optimizer/SynthType.cpp
+++ b/core/sql/optimizer/SynthType.cpp
@@ -1010,7 +1010,6 @@ const NAType *BuiltinFunction::synthesizeType()
 	    SQLChar(maxLength, typ1.supportsSQLnull());
       }
     break;
-    case ITM_SHA:
     case ITM_SHA1:
     case ITM_SHA2:
       {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/63e53386/core/sql/parser/sqlparser.y
----------------------------------------------------------------------
diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y
index 399f9fb..79511d0 100755
--- a/core/sql/parser/sqlparser.y
+++ b/core/sql/parser/sqlparser.y
@@ -9716,22 +9716,6 @@ misc_function :
                 }
 
 
-     | TOK_SHA1 '(' value_expression ')'
-                {
-                    $$ = new (PARSERHEAP())
-                    BuiltinFunction(ITM_SHA1,
-                            CmpCommon::statementHeap(),
-                            1, $3);
-                }
-
-     | TOK_SHA2 '(' value_expression ')'
-                {
-                    $$ = new (PARSERHEAP())
-                    BuiltinFunction(ITM_SHA2,
-                            CmpCommon::statementHeap(),
-                            1, $3);
-                }
-
      | TOK_GREATEST '(' value_expression ',' value_expression ')'
                   {
                     $$ = new (PARSERHEAP())

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/63e53386/core/sql/regress/compGeneral/EXPECTED006.SB
----------------------------------------------------------------------
diff --git a/core/sql/regress/compGeneral/EXPECTED006.SB b/core/sql/regress/compGeneral/EXPECTED006.SB
index e798c58..2afa934 100644
--- a/core/sql/regress/compGeneral/EXPECTED006.SB
+++ b/core/sql/regress/compGeneral/EXPECTED006.SB
@@ -1655,4 +1655,24 @@ Sheldon     ship                5500.00     4000.00
 
 --- 19 row(s) selected.
 >>
+>>select md5('10'), crc32(10), sha('10') from dual;
+
+(EXPR)                            (EXPR)      (EXPR)
+--------------------------------  ----------  --------------------------------------------------------------------------------------------------------------------------------
+
+d3d9446802a44259755d38e6d163e820   852952723  b1d5781111d84f7b3fe45a0852e59758cd7a87e5
+
+--- 1 row(s) selected.
+>>select md5(10) from dual;
+
+*** ERROR[4067] The operands of function MD5 must be character data types.
+
+*** ERROR[8822] The statement was not prepared.
+
+>>select sha1(10) from dual;
+
+*** ERROR[4067] The operands of function SHA must be character data types.
+
+*** ERROR[8822] The statement was not prepared.
+
 >>log;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/63e53386/core/sql/regress/compGeneral/TEST006
----------------------------------------------------------------------
diff --git a/core/sql/regress/compGeneral/TEST006 b/core/sql/regress/compGeneral/TEST006
index c50d797..96d6508 100644
--- a/core/sql/regress/compGeneral/TEST006
+++ b/core/sql/regress/compGeneral/TEST006
@@ -636,3 +636,6 @@ select emp_name, dept_name, salary_amt,
 lag(salary_amt, 3) over (partition by dept_name order by emp_name)
 from T006_EMPLOYEES <<+ cardinality 10e6 >> order by emp_name;
 
+select md5('10'), crc32(10), sha('10') from dual;
+select md5(10) from dual;
+select sha1(10) from dual;


Mime
View raw message