Merge branch 'master' of https://github.com/apache/trafodion into TRAFODION-3147
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/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;
------------------------------------------------------------------------