trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lium...@apache.org
Subject [1/5] incubator-trafodion git commit: [TRAFODION-2229] add hashing functions, commit set 1
Date Tue, 08 Nov 2016 09:25:08 GMT
Repository: incubator-trafodion
Updated Branches:
  refs/heads/master 964370049 -> 7a9000e00


[TRAFODION-2229] add hashing functions, commit set 1


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

Branch: refs/heads/master
Commit: 4c4dfc4d02f618966f32e6db042a1cb1ff73fc9d
Parents: 7092997
Author: Liu Ming <ovis_poly@sina.com>
Authored: Fri Oct 28 22:38:37 2016 -0400
Committer: Liu Ming <ovis_poly@sina.com>
Committed: Fri Oct 28 22:38:37 2016 -0400

----------------------------------------------------------------------
 core/sql/common/OperTypeEnum.h      |  4 ++++
 core/sql/exp/ExpPackDefs.cpp        |  7 ++++++-
 core/sql/exp/exp_clause.cpp         |  6 ++++++
 core/sql/exp/exp_clause.h           |  3 ++-
 core/sql/exp/exp_function.cpp       | 17 +++++++++++++++++
 core/sql/exp/exp_function.h         | 29 +++++++++++++++++++++++++++++
 core/sql/generator/GenItemFunc.cpp  |  9 +++++++++
 core/sql/optimizer/BindItemExpr.cpp |  4 ++++
 core/sql/optimizer/SynthType.cpp    | 12 +++++++++++-
 core/sql/parser/ParKeyWords.cpp     |  6 +++++-
 core/sql/parser/sqlparser.y         | 12 ++++++++++++
 11 files changed, 105 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c4dfc4d/core/sql/common/OperTypeEnum.h
----------------------------------------------------------------------
diff --git a/core/sql/common/OperTypeEnum.h b/core/sql/common/OperTypeEnum.h
index f2099b3..6e3981a 100644
--- a/core/sql/common/OperTypeEnum.h
+++ b/core/sql/common/OperTypeEnum.h
@@ -782,6 +782,10 @@ enum OperatorTypeEnum {
                         ITM_ISIPV6 = 2631,
                         ITM_INET_ATON = 2632,
                         ITM_INET_NTOA = 2633,
+                        ITM_CRC32     = 2634,
+                        ITM_MD5       = 2635,
+                        ITM_SHA1      = 2636,
+                        ITM_SHA2      = 2637,
 
                         // Items for needed for Translating to UCS2 output strings
                         ITM_DATEFMT     = 2990,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c4dfc4d/core/sql/exp/ExpPackDefs.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpPackDefs.cpp b/core/sql/exp/ExpPackDefs.cpp
index e319328..3bfea00 100644
--- a/core/sql/exp/ExpPackDefs.cpp
+++ b/core/sql/exp/ExpPackDefs.cpp
@@ -583,8 +583,13 @@ Long ExHeaderClause::pack(void * space)
 {
   return packClause(space, sizeof(ExHeaderClause));
 }  
-NA_EIDPROC Long ExFunctionIsIP::pack(void * space)
 
+NA_EIDPROC Long ExFunctionCrc32::pack(void * space)
+{
+  return packClause(space, sizeof(ExFunctionCrc32));
+}
+
+NA_EIDPROC Long ExFunctionIsIP::pack(void * space)
 {
   return packClause(space, sizeof(ExFunctionIsIP));
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c4dfc4d/core/sql/exp/exp_clause.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_clause.cpp b/core/sql/exp/exp_clause.cpp
index ca018ab..79c42cc 100644
--- a/core/sql/exp/exp_clause.cpp
+++ b/core/sql/exp/exp_clause.cpp
@@ -338,6 +338,9 @@ ex_clause::ex_clause(clause_type type,
 	case ITM_CURR_TRANSID:
 	  setClassID(FUNC_CURR_TRANSID_ID);
 	  break;
+        case ITM_CRC32:
+          setClassID(FUNC_CRC32_ID);
+          break; 
 	case ITM_ISIPV4:
 	case ITM_ISIPV6:
 	  setClassID(FUNC_ISIP_ID);
@@ -984,6 +987,9 @@ NA_EIDPROC char *ex_clause::findVTblPtr(short classID)
     case ex_clause::FUNC_HBASE_VERSION:
       GetVTblPtr(vtblPtr, ExFunctionHbaseVersion);
       break;
+    case ex_clause::FUNC_CRC32_ID:
+      GetVTblPtr(vtblPtr, ExFunctionCrc32);
+      break;
     case ex_clause::FUNC_ISIP_ID:
       GetVTblPtr(vtblPtr, ExFunctionIsIP);
       break;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c4dfc4d/core/sql/exp/exp_clause.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_clause.h b/core/sql/exp/exp_clause.h
index 4fc36d2..0ce3b51 100644
--- a/core/sql/exp/exp_clause.h
+++ b/core/sql/exp/exp_clause.h
@@ -202,7 +202,8 @@ public:
     FUNC_HBASE_VERSION       = 117,
     FUNC_ISIP_ID             = 118,
     FUNC_INETATON_ID         = 119,
-    FUNC_INETNTOA_ID         = 120
+    FUNC_INETNTOA_ID         = 120,
+    FUNC_CRC32_ID            = 121
   };
 
   // max number of operands (including result) in a clause.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c4dfc4d/core/sql/exp/exp_function.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_function.cpp b/core/sql/exp/exp_function.cpp
index e0134de..f819165 100644
--- a/core/sql/exp/exp_function.cpp
+++ b/core/sql/exp/exp_function.cpp
@@ -202,6 +202,7 @@ ExFunctionPack::ExFunctionPack(){};
 ExUnPackCol::ExUnPackCol(){};
 ExFunctionRangeLookup::ExFunctionRangeLookup(){};
 ExAuditImage::ExAuditImage(){};
+ExFunctionCrc32::ExFunctionCrc32(){};
 ExFunctionIsIP::ExFunctionIsIP(){};
 ExFunctionInetAton::ExFunctionInetAton(){};
 ExFunctionInetNtoa::ExFunctionInetNtoa(){};
@@ -219,6 +220,13 @@ ExFunctionChar::ExFunctionChar(OperatorTypeEnum oper_type,
   
 };
 
+ExFunctionCrc32::ExFunctionCrc32(OperatorTypeEnum oper_type,
+			       Attributes ** attr, Space * space)
+     : ex_function_clause(oper_type, 2, attr, space)
+{
+  
+};
+
 ExFunctionIsIP::ExFunctionIsIP(OperatorTypeEnum oper_type,
 			       Attributes ** attr, Space * space)
      : ex_function_clause(oper_type, 2, attr, space)
@@ -7900,6 +7908,15 @@ ex_expr::exp_return_type ExFunctionInetNtoa::eval(char * op_data[],
    return ex_expr::EXPR_OK;
 }
 
+ex_expr::exp_return_type ExFunctionCrc32::eval(char * op_data[],
+                                                        CollHeap *heap,
+                                                        ComDiagsArea **diags)
+{
+    *(ULng32*)op_data[0] = 0; 
+//stub for now
+    return ex_expr::EXPR_OK;
+}
+
 ex_expr::exp_return_type ExFunctionIsIP::eval(char * op_data[],
                                                         CollHeap *heap,
                                                         ComDiagsArea **diags)

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c4dfc4d/core/sql/exp/exp_function.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_function.h b/core/sql/exp/exp_function.h
index 918182b..22ef8c9 100644
--- a/core/sql/exp/exp_function.h
+++ b/core/sql/exp/exp_function.h
@@ -856,6 +856,35 @@ public:
   // ---------------------------------------------------------------------
 };
 
+class SQLEXP_LIB_FUNC ExFunctionCrc32: public ex_function_clause {
+public:
+  NA_EIDPROC ExFunctionCrc32(OperatorTypeEnum oper_type,
+				Attributes ** attr,
+				Space * space);
+  NA_EIDPROC ExFunctionCrc32();
+
+  NA_EIDPROC ex_expr::exp_return_type eval(char *op_data[], CollHeap*, 
+					   ComDiagsArea** = 0);  
+  NA_EIDPROC Long pack(void *);
+
+  // ---------------------------------------------------------------------
+  // Redefinition of methods inherited from NAVersionedObject.
+  // ---------------------------------------------------------------------
+  NA_EIDPROC virtual unsigned char getClassVersionID()
+  {
+    return 1;
+  }
+
+  NA_EIDPROC virtual void populateImageVersionIDArray()
+  {
+    setImageVersionID(2,getClassVersionID());
+    ex_function_clause::populateImageVersionIDArray();
+  }
+
+  NA_EIDPROC virtual short getClassSize() { return (short)sizeof(*this); }
+  // ---------------------------------------------------------------------
+};
+
 class SQLEXP_LIB_FUNC ExFunctionIsIP : public ex_function_clause {
 public:
   NA_EIDPROC ExFunctionIsIP(OperatorTypeEnum oper_type,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c4dfc4d/core/sql/generator/GenItemFunc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenItemFunc.cpp b/core/sql/generator/GenItemFunc.cpp
index bf08ca8..d025c22 100644
--- a/core/sql/generator/GenItemFunc.cpp
+++ b/core/sql/generator/GenItemFunc.cpp
@@ -218,6 +218,15 @@ short BuiltinFunction::codeGen(Generator * generator)
       
       break;
 
+   case ITM_CRC32:
+      {
+         function_clause =
+           new(generator->getSpace()) ExFunctionCrc32(getOperatorType(),
+                                                         attr, space);
+      }
+     
+      break;
+
    case ITM_ISIPV4:
    case ITM_ISIPV6:
       {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c4dfc4d/core/sql/optimizer/BindItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindItemExpr.cpp b/core/sql/optimizer/BindItemExpr.cpp
index af6a46d..32f84c4 100644
--- a/core/sql/optimizer/BindItemExpr.cpp
+++ b/core/sql/optimizer/BindItemExpr.cpp
@@ -3163,6 +3163,10 @@ ItemExpr *BuiltinFunction::bindNode(BindWA *bindWA)
     {
     case ITM_ISIPV4:
     case ITM_ISIPV6:
+    case ITM_MD5:
+    case ITM_CRC32:
+    case ITM_SHA1:
+    case ITM_SHA2:
       {
          break;
       }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c4dfc4d/core/sql/optimizer/SynthType.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/SynthType.cpp b/core/sql/optimizer/SynthType.cpp
index 477e2cc..1566219 100644
--- a/core/sql/optimizer/SynthType.cpp
+++ b/core/sql/optimizer/SynthType.cpp
@@ -1010,7 +1010,17 @@ const NAType *BuiltinFunction::synthesizeType()
 	    SQLChar(maxLength, typ1.supportsSQLnull());
       }
     break;
- 
+    case ITM_CRC32:
+      {
+        const NAType &typ1 = child(0)->getValueId().getType();
+        retType = new HEAP
+           SQLInt(FALSE, FALSE); //unsigned int
+        if (typ1.supportsSQLnull())
+          {
+            retType->setNullable(TRUE);
+          }
+      } 
+    break;
     case ITM_ISIPV4:
     case ITM_ISIPV6:
       {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c4dfc4d/core/sql/parser/ParKeyWords.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/ParKeyWords.cpp b/core/sql/parser/ParKeyWords.cpp
index c838bf7..c996b0c 100644
--- a/core/sql/parser/ParKeyWords.cpp
+++ b/core/sql/parser/ParKeyWords.cpp
@@ -257,6 +257,7 @@ ParKeyWord ParKeyWords::keyWords_[] = {
   ParKeyWord("COPY",               TOK_COPY,        NONRESTOKEN_),
   ParKeyWord("CPU",                TOK_CPU,         NONRESTOKEN_),
   ParKeyWord("CQD",                TOK_CQD,         NONRESTOKEN_),
+  ParKeyWord("CRC32",              TOK_CRC32,       NONRESTOKEN_),
   ParKeyWord("CREATE",             TOK_CREATE,      ANS_|RESWORD_),
   ParKeyWord("CREATE_LIBRARY",     TOK_CREATE_LIBRARY,   NONRESTOKEN_),
   ParKeyWord("CREATE_MV",          TOK_CREATE_MV,   NONRESTOKEN_),
@@ -636,7 +637,8 @@ ParKeyWord ParKeyWords::keyWords_[] = {
   ParKeyWord("MAXEXTENTS",         TOK_MAXEXTENTS,  NONRESTOKEN_),
   ParKeyWord("MAXIMUM",            TOK_MAX,         NONRESTOKEN_),
   ParKeyWord("MAXRUNTIME",         TOK_MAXRUNTIME,  SECOND_|NONRESTOKEN_),
-  ParKeyWord("MAXVALUE",           TOK_MAXVALUE,   NONRESTOKEN_),
+  ParKeyWord("MAXVALUE",           TOK_MAXVALUE,    NONRESTOKEN_),
+  ParKeyWord("MD5",                TOK_MD5,         NONRESTOKEN_),
   ParKeyWord("MEMORY",             TOK_MEMORY,      NONRESTOKEN_),
   ParKeyWord("MERGE",              TOK_MERGE,       ANS_|RESWORD_),
   ParKeyWord("MESSAGE",            TOK_MESSAGE,     NONRESTOKEN_),
@@ -970,6 +972,8 @@ ParKeyWord ParKeyWords::keyWords_[] = {
   ParKeyWord("SET",                TOK_SET,         ANS_|RESWORD_|MPWORD_),
   ParKeyWord("SETS",               TOK_SETS,        COMPAQ_|RESWORD_),
   ParKeyWord("SG_TABLE",           TOK_SG_TABLE,    NONRESTOKEN_),
+  ParKeyWord("SHA1",               TOK_SHA1,        NONRESTOKEN_),
+  ParKeyWord("SHA2",               TOK_SHA2,        NONRESTOKEN_),
   ParKeyWord("SHAPE",              TOK_SHAPE,       NONRESTOKEN_),
   ParKeyWord("SHARE",              TOK_SHARE,       NONRESTOKEN_),
   ParKeyWord("SHARED",             TOK_SHARED,      NONRESTOKEN_),

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4c4dfc4d/core/sql/parser/sqlparser.y
----------------------------------------------------------------------
diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y
index 8bd9a0b..2fd5209 100755
--- a/core/sql/parser/sqlparser.y
+++ b/core/sql/parser/sqlparser.y
@@ -556,6 +556,7 @@ static void enableMakeQuotedStringISO88591Mechanism()
 %token <tokval> TOK_COSH
 %token <tokval> TOK_COST
 %token <tokval> TOK_COUNT
+%token <tokval> TOK_CRC32
 %token <tokval> TOK_CQD
 %token <tokval> TOK_CROSS
 %token <tokval> TOK_CURDATE             /* ODBC extension  */ 
@@ -828,6 +829,7 @@ static void enableMakeQuotedStringISO88591Mechanism()
 %token <tokval> TOK_MEMORY
 %token <tokval> TOK_MERGE
 %token <tokval> TOK_METADATA
+%token <tokval> TOK_MD5
 %token <tokval> TOK_MIN
 %token <tokval> TOK_MINIMAL
 %token <tokval> TOK_MINUTE
@@ -1034,6 +1036,8 @@ static void enableMakeQuotedStringISO88591Mechanism()
 %token <tokval> TOK_SET
 %token <tokval> TOK_SETS
 %token <tokval> TOK_SG_TABLE
+%token <tokval> TOK_SHA1
+%token <tokval> TOK_SHA2
 %token <tokval> TOK_SHAPE
 %token <tokval> TOK_SHARE               /* Tandem extension non-reserved word */
 %token <tokval> TOK_SHARED              /* Tandem extension non-reserved word */
@@ -9632,6 +9636,14 @@ misc_function :
 				{
 				  $$ = $2;
 				}
+     | TOK_CRC32 '(' value_expression ')'
+                {
+                    $$ = new (PARSERHEAP())
+                    BuiltinFunction(ITM_CRC32,
+                            CmpCommon::statementHeap(),
+                            1, $3);
+                }
+
 
      | TOK_GREATEST '(' value_expression ',' value_expression ')'
                   {


Mime
View raw message