merge [TRAFODION-3147] 
diff --git a/core/sql/common/NAString.cpp b/core/sql/common/NAString.cpp
index 107e620..5a8fad7 100644
--- a/core/sql/common/NAString.cpp
+++ b/core/sql/common/NAString.cpp
@@ -1213,6 +1213,7 @@
 	"STDDEV ",             // Tandem-extension
 	"SUBSTRING ",          // ANSI
 	"SUM ",                // ANSI
+	"SYS_GUID ",           // Oracle-extension
 	"TAN ",                // Tandem-extension
 	"TANH ",               // Tandem-extension
 	"TIME ",               // Datatype with scales/precisions/length
diff --git a/core/sql/common/OperTypeEnum.h b/core/sql/common/OperTypeEnum.h
index 6bda946..dda4074 100644
--- a/core/sql/common/OperTypeEnum.h
+++ b/core/sql/common/OperTypeEnum.h
@@ -729,6 +729,7 @@
                         ITM_ANY_CAST = 2457,
 
                         ITM_UNIQUE_ID = 2458,
+                        ITM_UNIQUE_ID_SYS_GUID = 2459,
 
                        // Do not do any conversion. Just interpret source as the specified type.
                         ITM_CAST_TYPE,
diff --git a/core/sql/exp/exp_clause.cpp b/core/sql/exp/exp_clause.cpp
index 7c908d1..d8708d0 100644
--- a/core/sql/exp/exp_clause.cpp
+++ b/core/sql/exp/exp_clause.cpp
@@ -509,6 +509,7 @@
 	  setClassID(FUNC_QUERYID_EXTRACT);
 	  break;
 	case ITM_UNIQUE_ID:
+	case ITM_UNIQUE_ID_SYS_GUID:
 	case ITM_UNIQUE_SHORT_ID:
 	  setClassID(FUNC_UNIQUE_ID);
 	  break;
@@ -1514,6 +1515,7 @@
 
     case ITM_LAST_ITEM_OP: return "ITM_LAST_ITEM_OP";
     case ITM_UNIQUE_ID: return "ITM_UNIQUE_ID";
+    case ITM_UNIQUE_ID_SYS_GUID: return "ITM_UNIQUE_ID_SYS_GUID";
     case ITM_UNIQUE_SHORT_ID: return "ITM_UNIQUE_SHORT_ID";
     case ITM_ROWNUM: return "ITM_ROWNUM";
     case ITM_HBASE_COLUMN_LOOKUP: return "ITM_HBASE_COLUMN_LOOKUP";
diff --git a/core/sql/exp/exp_function.cpp b/core/sql/exp/exp_function.cpp
index ecd904b..b859956 100644
--- a/core/sql/exp/exp_function.cpp
+++ b/core/sql/exp/exp_function.cpp
@@ -7195,6 +7195,12 @@
     uuid_unparse(uu, str);
     str_cpy_all(result, str, 36);
   }
+  else if(getOperType() == ITM_UNIQUE_ID_SYS_GUID)
+  {
+    uuid_t uu;
+    uuid_generate( uu ); 
+    str_cpy_all(result, (char*)&uu,sizeof(uu));
+  }
   else //at present , it must be ITM_UUID_SHORT_ID
   { 
     Int64 uniqueUID;
diff --git a/core/sql/generator/GenItemFunc.cpp b/core/sql/generator/GenItemFunc.cpp
index f653c03..5594136 100644
--- a/core/sql/generator/GenItemFunc.cpp
+++ b/core/sql/generator/GenItemFunc.cpp
@@ -665,6 +665,7 @@
     break;
 
     case ITM_UNIQUE_ID:
+    case ITM_UNIQUE_ID_SYS_GUID:
     case ITM_UNIQUE_SHORT_ID:
       {
 	function_clause =
diff --git a/core/sql/optimizer/ItemExpr.cpp b/core/sql/optimizer/ItemExpr.cpp
index f0c3825..b1638d4 100644
--- a/core/sql/optimizer/ItemExpr.cpp
+++ b/core/sql/optimizer/ItemExpr.cpp
@@ -7627,6 +7627,8 @@
       return "unique_short_id";
     case ITM_UNIQUE_ID:
       return "unique_id";
+    case ITM_UNIQUE_ID_SYS_GUID:
+      return "sys_guid";
     case ITM_HBASE_COLUMN_LOOKUP:
       return "hbase_column_lookup";
     case ITM_HBASE_COLUMNS_DISPLAY:
diff --git a/core/sql/optimizer/SynthType.cpp b/core/sql/optimizer/SynthType.cpp
index 9efcb41..13f87da 100644
--- a/core/sql/optimizer/SynthType.cpp
+++ b/core/sql/optimizer/SynthType.cpp
@@ -1347,6 +1347,11 @@
         //please check the ExFunctionUniqueId::eval if the size is changed
 	retType = new HEAP SQLChar(HEAP, 36, FALSE);
       }
+    case ITM_UNIQUE_ID_SYS_GUID:
+      {
+        //please check the ExFunctionUniqueId::eval if the size is changed
+	retType = new HEAP SQLChar(HEAP, 16, FALSE);
+      }
       break;
     case ITM_UNIQUE_SHORT_ID:
       {
diff --git a/core/sql/parser/ParKeyWords.cpp b/core/sql/parser/ParKeyWords.cpp
index df891ce..85b97e7 100644
--- a/core/sql/parser/ParKeyWords.cpp
+++ b/core/sql/parser/ParKeyWords.cpp
@@ -1117,6 +1117,7 @@
   ParKeyWord("SYNONYM",            TOK_SYNONYM,     POTANS_|RESWORD_),
   ParKeyWord("SYNONYMS",           TOK_SYNONYMS,    NONRESTOKEN_),
   ParKeyWord("SYSDATE",            TOK_SYSDATE,     NONRESTOKEN_),
+  ParKeyWord("SYS_GUID",           TOK_SYS_GUID,     NONRESTOKEN_),
   ParKeyWord("SYSTEM",             TOK_SYSTEM,      NONRESTOKEN_),
   ParKeyWord("SYSTIMESTAMP",            TOK_SYSTIMESTAMP,     NONRESTOKEN_),
   ParKeyWord("SYSTEM_USER",        IDENTIFIER,      ANS_|RESWORD_),
diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y
index 74a6b03..b053fb6 100755
--- a/core/sql/parser/sqlparser.y
+++ b/core/sql/parser/sqlparser.y
@@ -735,6 +735,7 @@
 %token <tokval> TOK_INOUT
 %token <tokval> TOK_INSTR
 %token <tokval> TOK_NOT_IN
+%token <tokval> TOK_SYS_GUID
 %token <tokval> TOK_INCLUSIVE
 %token <tokval> TOK_INDICATOR
 %token <tokval> TOK_INITIALIZATION // MV 
@@ -8720,10 +8721,18 @@
                                    ItemExpr * ie = new (PARSERHEAP()) UnixTimestamp($3);
                                    $$ = new (PARSERHEAP()) Cast(ie, type);
 				}
+    | TOK_SYS_GUID '(' ')'
+              {
+                  ItemExpr * uniqueId =  new (PARSERHEAP()) BuiltinFunction(ITM_UNIQUE_ID_SYS_GUID, PARSERHEAP());
+                  ItemExpr *conv = new (PARSERHEAP()) ConvertHex(ITM_CONVERTTOHEX, uniqueId);
+                  NAType * type;
+                  type = new (PARSERHEAP())
+                       SQLVarChar(PARSERHEAP() , 32, FALSE);
+                  $$ = new (PARSERHEAP()) Cast(conv,type);
+              }
     | TOK_UUID '(' ')'
               {
                   ItemExpr * uniqueId =  new (PARSERHEAP()) BuiltinFunction(ITM_UNIQUE_ID, PARSERHEAP());
-                  //ItemExpr *conv = new (PARSERHEAP()) ConvertHex(ITM_CONVERTTOHEX, uniqueId);
                   NAType * type;
                   type = new (PARSERHEAP())
                        SQLVarChar(PARSERHEAP() , 36, FALSE);
@@ -8732,7 +8741,6 @@
     | TOK_UUID_SHORT '(' ')'
               {
                   ItemExpr * uniqueId =  new (PARSERHEAP()) BuiltinFunction(ITM_UNIQUE_SHORT_ID, PARSERHEAP());
-                  //ItemExpr *conv = new (PARSERHEAP()) ConvertHex(ITM_CONVERTTOHEX, uniqueId);
                   NAType * type;
                   type = new (PARSERHEAP())
                        SQLVarChar(PARSERHEAP() , 36, FALSE);
@@ -34541,6 +34549,7 @@
 			//                      | TOK_UPSERT
                       | TOK_UNIQUE_ID
                       | TOK_UUID
+                      | TOK_SYS_GUID
 		      | TOK_USERNAMEINTTOEXT
                       | TOK_VARIANCE
                       | TOK_WEEK
diff --git a/core/sql/regress/core/EXPECTED037.SB b/core/sql/regress/core/EXPECTED037.SB
index a14770c..6649293 100755
--- a/core/sql/regress/core/EXPECTED037.SB
+++ b/core/sql/regress/core/EXPECTED037.SB
@@ -205,6 +205,7 @@
 +>, STORE int not null 
 +>, SUBCLASS_ORIGIN int not null 
 +>, SUBSYSTEM_ID int not null 
++>, SYS_GUID int not null 
 +>, system_name int not null 
 +>, TABLE_NAME int not null 
 +>, TYPE int not null 
@@ -285,6 +286,7 @@
   , STORE                            INT NO DEFAULT NOT NULL NOT DROPPABLE
   , SUBCLASS_ORIGIN                  INT NO DEFAULT NOT NULL NOT DROPPABLE
   , SUBSYSTEM_ID                     INT NO DEFAULT NOT NULL NOT DROPPABLE
+  , SYS_GUID                         INT NO DEFAULT NOT NULL NOT DROPPABLE
   , SYSTEM_NAME                      INT NO DEFAULT NOT NULL NOT DROPPABLE
   , TABLE_NAME                       INT NO DEFAULT NOT NULL NOT DROPPABLE
   , TYPE                             INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -4873,6 +4875,11 @@
 --- SQL command prepared.
 >>
 >>-- Expect success
+>>prepare s1 from SELECT SYS_GUID SYS_GUID from (values(0)) SYS_GUID (SYS_GUID);
+
+--- SQL command prepared.
+>>
+>>-- Expect success
 >>prepare s1 from SELECT T T from (values(0)) T(T);
 
 --- SQL command prepared.
diff --git a/core/sql/regress/core/TEST037 b/core/sql/regress/core/TEST037
index c7c51c5..1fb152f 100755
--- a/core/sql/regress/core/TEST037
+++ b/core/sql/regress/core/TEST037
@@ -171,6 +171,7 @@
 , STORE int not null 
 , SUBCLASS_ORIGIN int not null 
 , SUBSYSTEM_ID int not null 
+, SYS_GUID int not null 
 , system_name int not null 
 , TABLE_NAME int not null 
 , TYPE int not null 
@@ -1889,6 +1890,9 @@
 prepare s1 from SELECT SUBSYSTEM_ID SUBSYSTEM_ID from (values(0)) SUBSYSTEM_ID(SUBSYSTEM_ID);
 
 -- Expect success
+prepare s1 from SELECT SYS_GUID SYS_GUID from (values(0)) SYS_GUID (SYS_GUID);
+
+-- Expect success
 prepare s1 from SELECT T T from (values(0)) T(T);
 
 -- Expect success
diff --git a/core/sql/regress/executor/EXPECTED002.SB b/core/sql/regress/executor/EXPECTED002.SB
index cb581bd..4ad0058 100644
--- a/core/sql/regress/executor/EXPECTED002.SB
+++ b/core/sql/regress/executor/EXPECTED002.SB
@@ -6910,6 +6910,14 @@
   1000 
 
 --- 1 row(s) selected.
+>>select distinct(count(sys_guid())) from T002T1K;
+
+(EXPR)
+----------
+
+  1000 
+
+--- 1 row(s) selected.
 >>drop table t002timert;
 
 --- SQL operation complete.
diff --git a/core/sql/regress/executor/FILTER002 b/core/sql/regress/executor/FILTER002
index 1b5f042..1e37216 100755
--- a/core/sql/regress/executor/FILTER002
+++ b/core/sql/regress/executor/FILTER002
@@ -31,7 +31,6 @@
 fi
 sed "
 s/\.[ ]*\*\*\*/\. \*\*\*/g
-s/^uuidrow.*$/uuid/
 s/^sleeptimetest002.*$/good/
 s/^unixtimestamp.*$/unixtimestamp/
 " $fil
diff --git a/core/sql/regress/executor/TEST002 b/core/sql/regress/executor/TEST002
index d66b483..69c6866 100755
--- a/core/sql/regress/executor/TEST002
+++ b/core/sql/regress/executor/TEST002
@@ -1218,6 +1218,7 @@
 insert into t002timert select 2, sleep(5) , unix_timestamp() from t002tmp1;
 select 'sleeptimetest002', di from (select ( max(c2) - min(c2)) as di from t002timert ) where di between 5 and 9;
 select distinct(count(uuid())) from T002T1K;
+select distinct(count(sys_guid())) from T002T1K;
 drop table t002timert;
 drop table t002tmp1;
 ------------------------------------------------------------------------