trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lium...@apache.org
Subject [1/3] trafodion git commit: first check in, must switch to other task
Date Thu, 23 Aug 2018 10:11:42 GMT
Repository: trafodion
Updated Branches:
  refs/heads/master bd3facc68 -> 31cab907a


first check in, must switch to other task


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

Branch: refs/heads/master
Commit: cadd9e90526a5b857912805894d17d2bb1f5e8de
Parents: 5e8bfc7
Author: Liu Ming <ovis_poly@sina.com>
Authored: Sun Aug 19 08:49:07 2018 +0000
Committer: Liu Ming <ovis_poly@sina.com>
Committed: Sun Aug 19 08:49:07 2018 +0000

----------------------------------------------------------------------
 core/sql/exp/exp_clause_derived.h |  8 ++++++++
 core/sql/exp/exp_like.cpp         | 12 +++++++-----
 2 files changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/cadd9e90/core/sql/exp/exp_clause_derived.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_clause_derived.h b/core/sql/exp/exp_clause_derived.h
index f478cd7..ee6afc3 100644
--- a/core/sql/exp/exp_clause_derived.h
+++ b/core/sql/exp/exp_clause_derived.h
@@ -41,9 +41,12 @@
 #ifndef EXP_CLAUSE_DERIVED_H
 #define EXP_CLAUSE_DERIVED_H
 
+#include <sys/types.h>
+#include <regex.h>
 #include "exp_clause.h"
 #include "exp_like.h"
 #include <byteswap.h>
+#include "NAStringDef.h"
 
 
 #define instrAndText(a) a, #a
@@ -2546,6 +2549,7 @@ public:
   // Construction
   //
   ExRegexpClauseChar() {};
+  ~ExRegexpClauseChar() {  };
   ExRegexpClauseChar(OperatorTypeEnum oper_type, 
 			    short num_operands,
 			    Attributes ** attr,
@@ -2584,6 +2588,10 @@ public:
   virtual short getClassSize() { return (short)sizeof(*this); }
   // ---------------------------------------------------------------------
 
+  regex_t reg;
+
+  NAString rpattern_;
+
 private:
 
   // ---------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafodion/blob/cadd9e90/core/sql/exp/exp_like.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_like.cpp b/core/sql/exp/exp_like.cpp
index 4cd365f..d235be8 100644
--- a/core/sql/exp/exp_like.cpp
+++ b/core/sql/exp/exp_like.cpp
@@ -498,11 +498,10 @@ ex_expr::exp_return_type ExRegexpClauseChar::eval(char *op_data[],
   NABoolean matchFlag = true;
   Lng32 len1 = getOperand(1)->getLength(op_data[-MAX_OPERANDS+1]);
   Lng32 len2 = getOperand(2)->getLength(op_data[-MAX_OPERANDS+2]);
-  regex_t reg;
+  char * pattern;
   regmatch_t pm[1];
   const size_t nmatch = 1;
   Lng32 cflags, z;
-  char * pattern;
   char *srcStr= new (exHeap) char[len1+1];
   char ebuf[128];
 
@@ -513,8 +512,12 @@ ex_expr::exp_return_type ExRegexpClauseChar::eval(char *op_data[],
 
   str_cpy_all(pattern, op_data[2], len2);
   str_cpy_all(srcStr, op_data[1], len1);
-
-  z = regcomp(&reg, pattern, cflags);
+  if(rpattern_ != pattern)
+  {
+    if(rpattern_ != "") regfree(&reg);
+    rpattern_ = pattern;
+    z = regcomp(&reg, pattern, cflags);
+  }
 
   if (z != 0){
     //ERROR
@@ -538,7 +541,6 @@ ex_expr::exp_return_type ExRegexpClauseChar::eval(char *op_data[],
   
 
   *(Lng32 *)op_data[0] = (Lng32)matchFlag;
-  regfree(&reg);
 
   NADELETEBASIC(pattern, exHeap);
   NADELETEBASIC(srcStr, exHeap);


Mime
View raw message