You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by li...@apache.org on 2018/04/06 23:09:12 UTC

[1/6] trafodion git commit: [TRAFODION-2335] support some functions as column default, part1 commit

Repository: trafodion
Updated Branches:
  refs/heads/master ee2cff973 -> 995e8a090


[TRAFODION-2335] support some functions as column default, part1 commit


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

Branch: refs/heads/master
Commit: 6b800c34a4f9cb4386223067ff7c3801bdbec002
Parents: 75c7b39
Author: Liu Ming <ov...@sina.com>
Authored: Wed Mar 14 09:07:42 2018 +0000
Committer: Liu Ming <ov...@sina.com>
Committed: Wed Mar 14 09:07:42 2018 +0000

----------------------------------------------------------------------
 core/sql/common/ComSmallDefs.h           | 12 ++++++++
 core/sql/exp/exp_attrs.cpp               |  2 ++
 core/sql/exp/exp_attrs.h                 |  2 +-
 core/sql/generator/GenExpGenerator.cpp   | 14 +++++++++
 core/sql/optimizer/BindRelExpr.cpp       |  4 ++-
 core/sql/optimizer/ColStatDesc.cpp       |  4 +++
 core/sql/optimizer/ValueDesc.cpp         |  2 +-
 core/sql/parser/ElemDDLCol.cpp           | 41 +++++++++++++++++++++++++--
 core/sql/parser/ElemDDLColDef.h          | 17 +++++++++++
 core/sql/parser/ElemDDLColDefault.h      | 17 +++++++++++
 core/sql/parser/sqlparser.y              | 29 +++++++++++++++----
 core/sql/regress/seabase/TEST020         | 17 +++++++++++
 core/sql/sqlcomp/CmpDescribe.cpp         |  6 +++-
 core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp | 25 +++++++++++++++-
 core/sql/sqlcomp/CmpSeabaseDDLtable.cpp  | 15 ++++++++++
 core/sql/sqlcomp/CmpSeabaseDDLutil.cpp   |  6 ++++
 16 files changed, 200 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/6b800c34/core/sql/common/ComSmallDefs.h
----------------------------------------------------------------------
diff --git a/core/sql/common/ComSmallDefs.h b/core/sql/common/ComSmallDefs.h
index b6baf11..b1dd91a 100644
--- a/core/sql/common/ComSmallDefs.h
+++ b/core/sql/common/ComSmallDefs.h
@@ -609,47 +609,59 @@ enum ComColumnClass { COM_UNKNOWN_CLASS
 #define COM_ALTERED_USER_COLUMN_LIT         "C "
 
 enum ComColumnDefaultClass { COM_CURRENT_DEFAULT
+                           , COM_CURRENT_UT_DEFAULT
                            , COM_NO_DEFAULT
                            , COM_NULL_DEFAULT
                            , COM_USER_DEFINED_DEFAULT
                            , COM_USER_FUNCTION_DEFAULT
+                           , COM_UUID_DEFAULT
                            , COM_IDENTITY_GENERATED_BY_DEFAULT
                            , COM_IDENTITY_GENERATED_ALWAYS
                            , COM_ALWAYS_COMPUTE_COMPUTED_COLUMN_DEFAULT
                            , COM_ALWAYS_DEFAULT_COMPUTED_COLUMN_DEFAULT
+                           , COM_FUNCTION_DEFINED_DEFAULT
                            };
 
 #define COM_CURRENT_DEFAULT_LIT                     "CD"
+#define COM_CURRENT_UT_DEFAULT_LIT                  "UT"
+#define COM_FUNCTION_DEFINED_DEFAULT_LIT            "FD"
 #define COM_NO_DEFAULT_LIT                          "  "
 #define COM_NULL_DEFAULT_LIT                        "ND"
 #define COM_USER_DEFINED_DEFAULT_LIT                "UD"
 #define COM_USER_FUNCTION_DEFAULT_LIT               "UF"
+#define COM_UUID_DEFAULT_LIT                        "UI"
 #define COM_IDENTITY_GENERATED_BY_DEFAULT_LIT       "ID"
 #define COM_IDENTITY_GENERATED_ALWAYS_LIT           "IA"
 #define COM_ALWAYS_COMPUTE_COMPUTED_COLUMN_DEFAULT_LIT "AC"
 #define COM_ALWAYS_DEFAULT_COMPUTED_COLUMN_DEFAULT_LIT "AD"
 
 enum ComParamDefaultClass { COM_CURRENT_PARAM_DEFAULT        = COM_CURRENT_DEFAULT
+                          , COM_CURRENT_UT_PARAM_DEFAULT     = COM_CURRENT_UT_DEFAULT
                           , COM_NO_PARAM_DEFAULT 
                                                              = COM_NO_DEFAULT
                           , COM_NULL_PARAM_DEFAULT           = COM_NULL_DEFAULT
                           , COM_USER_DEFINED_PARAM_DEFAULT   = COM_USER_DEFINED_DEFAULT
                           , COM_USER_FUNCTION_PARAM_DEFAULT  = COM_USER_FUNCTION_DEFAULT
+                          , COM_UUID_PARAM_DEAULT            = COM_UUID_DEFAULT
                             // IDENTITY GENERATED BY DEFAULT not applicable
                             // IDENTITY GENERATED ALWAYS     not applicable
                           , COM_ALWAYS_COMPUTE_COMPUTED_PARAM_DEFAULT // for future internal use only
                                                              = COM_ALWAYS_COMPUTE_COMPUTED_COLUMN_DEFAULT
                           , COM_ALWAYS_DEFAULT_COMPUTED_PARAM_DEFAULT // for future internal use only
                                                              = COM_ALWAYS_DEFAULT_COMPUTED_COLUMN_DEFAULT
+                          , COM_FUNCTION_DEFINED_PARAM_DEFAULT
+                                                             = COM_FUNCTION_DEFINED_DEFAULT
                           };
 
 #define COM_NO_PARAM_DEFAULT_LIT                      "  "
 #define COM_CURRENT_PARAM_DEFAULT_LIT                 "CD"
+#define COM_CURRENT_UT_PARAM_DEFAULT_LIT              "UT"
 #define COM_NULL_PARAM_DEFAULT_LIT                    "ND"
 #define COM_USER_DEFINED_PARAM_DEFAULT_LIT            "UD"
 #define COM_USER_FUNCTION_PARAM_DEFAULT_LIT           "UF"
 #define COM_ALWAYS_COMPUTE_COMPUTED_PARAM_DEFAULT_LIT "AC"
 #define COM_ALWAYS_DEFAULT_COMPUTED_PARAM_DEFAULT_LIT "AD"
+#define COM_FUNCTION_DEFINED_PARAM_DEFAULT_LIT        "FD"
 
 // Represents the kind of string value stored in TEXT table.  Note
 // that changing existing values will require an UPGRADE of the

http://git-wip-us.apache.org/repos/asf/trafodion/blob/6b800c34/core/sql/exp/exp_attrs.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_attrs.cpp b/core/sql/exp/exp_attrs.cpp
index 8ded216..cc2a91d 100644
--- a/core/sql/exp/exp_attrs.cpp
+++ b/core/sql/exp/exp_attrs.cpp
@@ -482,6 +482,8 @@ NABoolean SimpleType::operator==(const Attributes& other) const
 	   : (scale_ == otherAttr.scale_)) &&
 	  ((thisAttr.getDefaultClass() == DEFAULT_NULL || 
 	    thisAttr.getDefaultClass() == NO_DEFAULT ||
+	    thisAttr.getDefaultClass() == DEFAULT_UUID ||
+	    thisAttr.getDefaultClass() == DEFAULT_CURRENT_UT ||
 	    thisAttr.getDefaultClass() == DEFAULT_CURRENT) ||
 	   (thisAttr.getDefaultValue() && otherAttr.getDefaultValue() &&
 	    (str_cmp(thisAttr.getDefaultValue(), 

http://git-wip-us.apache.org/repos/asf/trafodion/blob/6b800c34/core/sql/exp/exp_attrs.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_attrs.h b/core/sql/exp/exp_attrs.h
index 32a818d..745374b 100644
--- a/core/sql/exp/exp_attrs.h
+++ b/core/sql/exp/exp_attrs.h
@@ -102,7 +102,7 @@ public:
   enum DefaultClass
   {
     NO_DEFAULT, DEFAULT_NULL, DEFAULT_CURRENT, 
-    DEFAULT_USER, DEFAULT_USER_FUNCTION, DEFAULT_IDENTITY,
+    DEFAULT_USER, DEFAULT_USER_FUNCTION, DEFAULT_IDENTITY,DEFAULT_CURRENT_UT, DEFAULT_UUID, DEFAULT_FUNCTION,
     INVALID_DEFAULT
   };
 

http://git-wip-us.apache.org/repos/asf/trafodion/blob/6b800c34/core/sql/generator/GenExpGenerator.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenExpGenerator.cpp b/core/sql/generator/GenExpGenerator.cpp
index 2fcc85d..7084147 100644
--- a/core/sql/generator/GenExpGenerator.cpp
+++ b/core/sql/generator/GenExpGenerator.cpp
@@ -423,6 +423,12 @@ Attributes::DefaultClass ExpGenerator::getDefaultClass(const NAColumn * col)
   {
     case COM_CURRENT_DEFAULT:
       dc = Attributes::DEFAULT_CURRENT; break;
+    case COM_CURRENT_UT_DEFAULT:
+      dc = Attributes::DEFAULT_CURRENT_UT; break;
+    case COM_UUID_DEFAULT:
+      dc = Attributes::DEFAULT_UUID; break;
+    case COM_FUNCTION_DEFINED_DEFAULT:
+      dc = Attributes::DEFAULT_FUNCTION; break;
     case COM_NO_DEFAULT:
     case COM_ALWAYS_COMPUTE_COMPUTED_COLUMN_DEFAULT:
     case COM_ALWAYS_DEFAULT_COMPUTED_COLUMN_DEFAULT:
@@ -482,6 +488,11 @@ short ExpGenerator::addDefaultValue(NAColumn * col, Attributes * attr,
       // For new rows compiler will produce a node with CURRENT exp
       castStr = new(wHeap()) NAString("CAST(TIMESTAMP '0001-01-01:12:00:00.000000' AS ", wHeap());
       break;
+    case Attributes::DEFAULT_CURRENT_UT:
+      // This value is for the old rows before the alter table with add column
+      // For new rows compiler will produce a node with CURRENT exp
+      castStr = new(wHeap()) NAString("CAST( 0 AS ", wHeap());
+      break;
     case Attributes::DEFAULT_NULL:
       if (attr->getNullFlag())
       {
@@ -528,6 +539,9 @@ short ExpGenerator::addDefaultValue(NAColumn * col, Attributes * attr,
       // IDENTITY column, it is Ok. to cast it to zero.
       castStr = new(wHeap()) NAString("CAST(0 AS ", wHeap());
       break;
+    case Attributes::DEFAULT_FUNCTION:
+      castStr = new(wHeap()) NAString("CAST( \' \' AS ", wHeap());
+      break;
 
     case Attributes::NO_DEFAULT:
     default:

http://git-wip-us.apache.org/repos/asf/trafodion/blob/6b800c34/core/sql/optimizer/BindRelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindRelExpr.cpp b/core/sql/optimizer/BindRelExpr.cpp
index 7beaf9e..f8543e9 100644
--- a/core/sql/optimizer/BindRelExpr.cpp
+++ b/core/sql/optimizer/BindRelExpr.cpp
@@ -10398,7 +10398,6 @@ RelExpr *Insert::bindNode(BindWA *bindWA)
           ULng32 savedParserFlags = Get_SqlParser_Flags (0xFFFFFFFF);
           Set_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL);
           Set_SqlParser_Flags(ALLOW_VOLATILE_SCHEMA_IN_TABLE_NAME);
-
           defaultValueExpr = parser.getItemExprTree(defaultValueStr);
           CMPASSERT(defaultValueExpr);
 
@@ -10454,6 +10453,9 @@ RelExpr *Insert::bindNode(BindWA *bindWA)
             Assign(target.getItemExpr(), defaultValueExpr,
                     FALSE /*Not user Specified */);
           if ((nacol->getDefaultClass() != COM_CURRENT_DEFAULT) &&
+              (nacol->getDefaultClass() != COM_CURRENT_UT_DEFAULT) &&
+              (nacol->getDefaultClass() != COM_FUNCTION_DEFINED_DEFAULT) &&
+              (nacol->getDefaultClass() != COM_UUID_DEFAULT) &&
               (nacol->getDefaultClass() != COM_USER_FUNCTION_DEFAULT))
              assign->setToBeSkipped(TRUE);
           assign->bindNode(bindWA);

http://git-wip-us.apache.org/repos/asf/trafodion/blob/6b800c34/core/sql/optimizer/ColStatDesc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ColStatDesc.cpp b/core/sql/optimizer/ColStatDesc.cpp
index 8623526..2f256b1 100644
--- a/core/sql/optimizer/ColStatDesc.cpp
+++ b/core/sql/optimizer/ColStatDesc.cpp
@@ -1708,6 +1708,8 @@ ColStatDesc::selForRelativeRange (const OperatorTypeEnum op,
 	   OR (operand->getOperatorType() == ITM_CACHE_PARAM)
 	   OR (operand->getOperatorType() == ITM_CURRENT_USER)
 	   OR (operand->getOperatorType() == ITM_CURRENT_TIMESTAMP)
+	   OR (operand->getOperatorType() == ITM_UNIQUE_ID)
+	   OR (operand->getOperatorType() == ITM_UNIX_TIMESTAMP)
 	   OR (operand->getOperatorType() == ITM_SESSION_USER)
 	   OR (operand->getOperatorType() == ITM_GET_TRIGGERS_STATUS)
 	   OR (operand->getOperatorType() == ITM_UNIQUE_EXECUTE_ID))
@@ -8580,6 +8582,8 @@ ColStatDescList::getColStatsPtrForVEGGroup(const ValueIdSet& VEGGroup) const
 	case ITM_CURRENT_USER:
 	case ITM_SESSION_USER:
         case ITM_CURRENT_TIMESTAMP:
+        case ITM_UNIX_TIMESTAMP:
+	case ITM_UNIQUE_ID:
 	case ITM_GET_TRIGGERS_STATUS:
 	case ITM_UNIQUE_EXECUTE_ID:
 	  continue;

http://git-wip-us.apache.org/repos/asf/trafodion/blob/6b800c34/core/sql/optimizer/ValueDesc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ValueDesc.cpp b/core/sql/optimizer/ValueDesc.cpp
index 605118b..16e1fcc 100644
--- a/core/sql/optimizer/ValueDesc.cpp
+++ b/core/sql/optimizer/ValueDesc.cpp
@@ -549,7 +549,7 @@ NABoolean ValueId::isColumnWithNonNullNonCurrentDefault() const{
   default:
       break;
   }
-  if (nac &&  nac->getDefaultValue() && nac->getDefaultClass()!=COM_NULL_DEFAULT && nac->getDefaultClass()!=COM_CURRENT_DEFAULT)
+  if (nac &&  nac->getDefaultValue() && nac->getDefaultClass()!=COM_NULL_DEFAULT && nac->getDefaultClass()!=COM_CURRENT_DEFAULT && nac->getDefaultClass()!=COM_CURRENT_UT_DEFAULT)
       return TRUE;
   else
       return FALSE;

http://git-wip-us.apache.org/repos/asf/trafodion/blob/6b800c34/core/sql/parser/ElemDDLCol.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLCol.cpp b/core/sql/parser/ElemDDLCol.cpp
index a18c317..3229f74 100644
--- a/core/sql/parser/ElemDDLCol.cpp
+++ b/core/sql/parser/ElemDDLCol.cpp
@@ -313,7 +313,7 @@ ElemDDLColDef::setDefaultAttribute(ElemDDLNode * pColDefaultNode)
         case ElemDDLColDefault::COL_DEFAULT:
           {
             defaultClauseStatus_ = DEFAULT_CLAUSE_SPEC;
-            
+
             if (pColDefault->getSGOptions())
               {
                 isIdentityColumn = TRUE;
@@ -524,6 +524,39 @@ ElemDDLColDef::setDefaultAttribute(ElemDDLNode * pColDefaultNode)
               }
           }
           break;
+        case ElemDDLColDefault::COL_FUNCTION_DEFAULT:
+          {
+            defaultClauseStatus_ = DEFAULT_CLAUSE_SPEC;
+            defaultExprString_= pColDefault->getDefaultExprString();
+    
+            ComASSERT(pColDefault->getDefaultValueExpr() NEQ NULL);
+            pDefault_ = pColDefault->getDefaultValueExpr();
+            
+            ItemExpr *itr = pDefault_; 
+            NABoolean valid = TRUE;
+            //Only support to_char(cast (currenttimestamp ))
+            if( pDefault_->getOperatorType() != ITM_DATEFORMAT)
+              valid = FALSE;
+            else 
+            {
+              //next should be CAST
+              itr = pDefault_->child(0)->castToItemExpr();
+              if(itr->getOperatorType() != ITM_CAST)
+                valid = FALSE;
+              else
+              {
+                itr = itr->child(0)->castToItemExpr();
+                if(itr->getOperatorType() !=  ITM_CURRENT_TIMESTAMP)
+                 valid = FALSE;
+              }
+            }
+            if( valid == FALSE )
+            {
+              *SqlParser_Diags << DgSqlCode(-1084)
+                               << DgColumnName(ToAnsiIdentifier(getColumnName()));
+            }
+          }
+          break;
         case ElemDDLColDefault::COL_COMPUTED_DEFAULT:
           {
             defaultClauseStatus_ = DEFAULT_CLAUSE_SPEC;
@@ -734,7 +767,7 @@ ElemDDLColDef::setColumnAttribute(ElemDDLNode * pColAttr)
 	if(TRUE == isColDefaultSpec_)
 	  {
 	    // Duplicate DEFAULT attrs in column definition.
-            *SqlParser_Diags << DgSqlCode(-3052)
+	    *SqlParser_Diags << DgSqlCode(-3052)
                              << DgString0("DEFAULT")
                              << DgColumnName(ToAnsiIdentifier(getColumnName()));
 	  }
@@ -1046,6 +1079,7 @@ ElemDDLColDefault::displayLabel1() const
   switch (getColumnDefaultType())
   {
   case COL_DEFAULT :
+  case COL_FUNCTION_DEFAULT :
     return NAString("Type: Default");
   case COL_NO_DEFAULT :
     return NAString("Type: No Default");
@@ -1058,7 +1092,8 @@ ElemDDLColDefault::displayLabel1() const
 const NAString
 ElemDDLColDefault::displayLabel2() const
 {
-  if (getColumnDefaultType() EQU COL_DEFAULT)
+  if ((getColumnDefaultType() EQU COL_DEFAULT)
+      || getColumnDefaultType() EQU COL_FUNCTION_DEFAULT)
   {
     return (NAString("Default value: ") +
             getDefaultValueExpr()->getText());

http://git-wip-us.apache.org/repos/asf/trafodion/blob/6b800c34/core/sql/parser/ElemDDLColDef.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLColDef.h b/core/sql/parser/ElemDDLColDef.h
index 2f275d0..25dd0a3 100644
--- a/core/sql/parser/ElemDDLColDef.h
+++ b/core/sql/parser/ElemDDLColDef.h
@@ -127,12 +127,14 @@ public:
         // 3. The DEFAULT clause appears.
   
   inline ItemExpr * getDefaultValueExpr() const;
+  inline Int32 getErrorCode() const;
   
         // returns the default value specified in the DEFAULT
         // clause; returns the NULL pointer value if NO DEFAULT
         // clause appears or the DEFAULT clause does not appear.
   
   inline const NAString & getComputedDefaultExpr() const;
+  inline const NAString & getDefaultExprString() const;
   inline const NAString & getHeading() const;
   inline const NABoolean getIsConstraintNotNullSpecified() const;
   inline const NABoolean getIsConstraintPKSpecified() const;
@@ -239,6 +241,7 @@ private:
   NABoolean  isNewAdjustedDefaultConstValueNode_;
   ItemExpr * pDefault_; // points to a ConstValue parse node
   NAString   computedDefaultExpr_;
+  NAString   defaultExprString_;
   ElemDDLSGOptions * pSGOptions_;
   NAString * pSGLocation_;
 
@@ -309,6 +312,8 @@ private:
   NABoolean seabaseSerialized_;
 
   NABoolean isColDefaultSpec_;
+
+  Int32 errCode_;
 }; // class ElemDDLColDef
 
 // -----------------------------------------------------------------------
@@ -403,6 +408,12 @@ ElemDDLColDef::getDefaultValueExpr() const
   return pDefault_;
 }
 
+inline Int32
+ElemDDLColDef::getErrorCode() const
+{
+  return errCode_;
+}
+
 inline const NAString &
 ElemDDLColDef::getComputedDefaultExpr() const
 {
@@ -410,6 +421,12 @@ ElemDDLColDef::getComputedDefaultExpr() const
 }
 
 inline const NAString &
+ElemDDLColDef::getDefaultExprString() const
+{
+  return defaultExprString_;
+}
+
+inline const NAString &
 ElemDDLColDef::getHeading() const
 {
   return heading_;

http://git-wip-us.apache.org/repos/asf/trafodion/blob/6b800c34/core/sql/parser/ElemDDLColDefault.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLColDefault.h b/core/sql/parser/ElemDDLColDefault.h
index 3ba4074..e435400 100644
--- a/core/sql/parser/ElemDDLColDefault.h
+++ b/core/sql/parser/ElemDDLColDefault.h
@@ -63,6 +63,7 @@ public:
 
   enum colDefaultTypeEnum { COL_NO_DEFAULT,
                             COL_DEFAULT,
+                            COL_FUNCTION_DEFAULT,
                             COL_COMPUTED_DEFAULT };
 
   // default constructor
@@ -74,6 +75,7 @@ public:
 	  columnDefaultType_(columnDefaultType),
 	  defaultValueExpr_(defaultValueExpr),
 	  sgOptions_(sgOptions),
+	  defaultExprString_(""),
           sgLocation_(NULL)
   {}
 
@@ -93,6 +95,7 @@ public:
   inline colDefaultTypeEnum getColumnDefaultType() const;
 
   inline ItemExpr * getDefaultValueExpr() const;
+  inline const NAString &getDefaultExprString() const;
 
         // returns the pointer to the (only) child parse node
         // pointing to an ItemExpr node representing the
@@ -105,6 +108,7 @@ public:
   // mutator
   virtual void setChild(Lng32 index, ExprNode * pChildNode);
   inline  void setDefaultValueExpr(ItemExpr * pDefaultValueExpr);
+  inline  void setDefaultExprString(NAString &str);
   inline void  setSGOptions(ElemDDLSGOptions * pSGOptions);
   inline void setSGLocation(NAString *pLocation);
   inline void setComputedDefaultExpr(const NAString &computedDefaultExpr);
@@ -126,6 +130,7 @@ private:
 
   ItemExpr * defaultValueExpr_;
   NAString computedDefaultExpr_;
+  NAString defaultExprString_;
 
   ElemDDLSGOptions * sgOptions_;
   NAString * sgLocation_;
@@ -160,6 +165,12 @@ ElemDDLColDefault::setDefaultValueExpr(ItemExpr * pDefaultValueExpr)
 }
 
 inline void
+ElemDDLColDefault::setDefaultExprString(NAString &str)
+{
+  defaultExprString_ = str;
+}
+
+inline void
 ElemDDLColDefault::setSGOptions(ElemDDLSGOptions * pSGOptions)
 {
   sgOptions_ = pSGOptions;
@@ -194,4 +205,10 @@ ElemDDLColDefault::getComputedDefaultExpr() const
 {
   return computedDefaultExpr_;
 }
+
+inline const NAString &
+ElemDDLColDefault::getDefaultExprString() const
+{
+  return defaultExprString_;
+}
 #endif // ELEMDDLCOLDEFAULT_H

http://git-wip-us.apache.org/repos/asf/trafodion/blob/6b800c34/core/sql/parser/sqlparser.y
----------------------------------------------------------------------
diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y
index 69df367..dedd03f 100755
--- a/core/sql/parser/sqlparser.y
+++ b/core/sql/parser/sqlparser.y
@@ -2589,6 +2589,8 @@ static void enableMakeQuotedStringISO88591Mechanism()
 %type <pElemDDL>                   datatype_option
 %type <item>      		datetime_value_function
 %type <item>      		datetime_misc_function
+%type <item>      		datetime_misc_function_used_as_default
+%type <item>      	        sequence_as_default	
 %type <stringval>  		format_attributes
 %type <pElemDDL>  		optional_constraint_attributes
 %type <pElemDDL>  		constraint_attributes
@@ -8245,6 +8247,8 @@ value_function :
 
      | datetime_misc_function
 
+     | datetime_misc_function_used_as_default
+
      | datetime_value_function
 
      | math_function
@@ -8735,6 +8739,14 @@ datetime_value_function : TOK_CURDATE '(' ')'
               }
 
 /* type item */
+datetime_misc_function_used_as_default:      TOK_TO_CHAR '(' value_expression ',' character_string_literal ')'
+                               {
+
+                                $$ = new (PARSERHEAP()) 
+                                   DateFormat($3, *$5, DateFormat::FORMAT_TO_CHAR);
+                               }
+
+/* type item */
 datetime_misc_function : TOK_CONVERTTIMESTAMP '(' value_expression ')'
 				{
 				  $$ = new (PARSERHEAP())
@@ -8851,11 +8863,6 @@ datetime_misc_function : TOK_CONVERTTIMESTAMP '(' value_expression ')'
 
                                 $$ = new (PARSERHEAP()) Cast ($3, dt);
                                 }
-    | TOK_TO_CHAR '(' value_expression ',' character_string_literal ')'
-                               {
-				 $$ = new (PARSERHEAP()) 
-                                   DateFormat($3, *$5, DateFormat::FORMAT_TO_CHAR);
-			       }
     | TOK_TO_CHAR '(' value_expression ')'
                                {
                                  $$ = new (PARSERHEAP()) DateFormat
@@ -25800,6 +25807,18 @@ col_def_default_clause_argument : literal_negatable
                                        $1 /*datetime_value_function*/);
                                 }
 
+                      | datetime_misc_function_used_as_default
+                                {
+                                  $$ = new (PARSERHEAP())
+				    ElemDDLColDefault(
+                                       ElemDDLColDefault::COL_FUNCTION_DEFAULT);
+                                  ItemExpr * firstItem = $1;
+                                  NAString unparsed(PARSERHEAP());
+                                  firstItem->unparse(unparsed); // expression as ascii string
+
+                                  ((ElemDDLColDefault *)$$)->setDefaultExprString(unparsed);
+                                  ((ElemDDLColDefault *)$$)->setDefaultValueExpr($1);
+                                }
                       | builtin_function_user
                                 {
                                   $$ = new (PARSERHEAP())

http://git-wip-us.apache.org/repos/asf/trafodion/blob/6b800c34/core/sql/regress/seabase/TEST020
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST020 b/core/sql/regress/seabase/TEST020
index 6f68b54..d435747 100755
--- a/core/sql/regress/seabase/TEST020
+++ b/core/sql/regress/seabase/TEST020
@@ -41,6 +41,7 @@ obey TEST020(test_10_030916_9668);
 obey TEST020(test_LP_1360493);
 obey TEST020(trafodion_1700_and_1847);
 obey TEST020(trafodion_2247);
+obey TEST020(trafodion_2335);
 log;
 obey TEST020(clean_up);
 exit;
@@ -93,6 +94,7 @@ drop table test020t41 cascade;
 drop table test020t42 cascade;
 drop table test020t43 cascade;
 drop table test020t44;
+drop table test020t45;
 
 ?section tests
 create table  test020t1 (c1 int not null primary key,
@@ -929,3 +931,18 @@ cqd traf_upsert_mode 'merge';
 upsert into test020t44 (a,c) values ('AAAA', 2);
 select * from test020t44;
 
+?section trafodion_2335
+--create seqence test020_seq;
+create table test020t45(a  largeint not null default unix_timestamp(),
+                        b  char(36) not null default uuid(),
+                        c  varchar(10) default to_char(sysdate,'YYYYMMDD'),
+                        --support sequence as default in next check-in
+                        --d  int not null default testi020_seq.nextval,
+                        e  int );
+insert into test020t45(e) values(1),(2),(3);
+select * from test020t45;
+--negative tests
+--the function is not variable-free, so should fail
+create table test020t45(a  largeint not null default unix_timestamp(),
+                        b  varchar(10) default to_char(test020t45.c,'YYYYMMDD'),
+                        e  int );

http://git-wip-us.apache.org/repos/asf/trafodion/blob/6b800c34/core/sql/sqlcomp/CmpDescribe.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpDescribe.cpp b/core/sql/sqlcomp/CmpDescribe.cpp
index 26b9b3c..5a08a91 100644
--- a/core/sql/sqlcomp/CmpDescribe.cpp
+++ b/core/sql/sqlcomp/CmpDescribe.cpp
@@ -2641,9 +2641,13 @@ short cmpDisplayColumn(const NAColumn *nac,
     defVal = "DEFAULT NULL";
   else if (nac->getDefaultClass() == COM_CURRENT_DEFAULT)
     defVal = "DEFAULT CURRENT";
+  else if (nac->getDefaultClass() == COM_CURRENT_UT_DEFAULT)
+    defVal = "DEFAULT CURRENT UNIXTIME";
   else if (nac->getDefaultClass() == COM_USER_FUNCTION_DEFAULT)
     defVal = "DEFAULT USER";
-  else if (nac->getDefaultClass() == COM_USER_DEFINED_DEFAULT)
+  else if (nac->getDefaultClass() == COM_UUID_DEFAULT)
+    defVal = "DEFAULT UUID";
+  else if (nac->getDefaultClass() == COM_USER_DEFINED_DEFAULT || nac->getDefaultClass() == COM_FUNCTION_DEFINED_DEFAULT)
     {
       defVal = "DEFAULT ";
       

http://git-wip-us.apache.org/repos/asf/trafodion/blob/6b800c34/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
index e767cec..3e602e8 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
@@ -3168,8 +3168,13 @@ short CmpSeabaseDDL::getColInfo(ElemDDLColDef * colNode,
             defaultClass = COM_IDENTITY_GENERATED_BY_DEFAULT;
         }
       else if (ie == NULL)
-        if (colNode->getComputedDefaultExpr().isNull())
+        if (colNode->getComputedDefaultExpr().isNull() && colNode->getDefaultExprString().isNull())
           defaultClass = COM_NO_DEFAULT;
+        else if(!colNode->getDefaultExprString().isNull())
+          {
+            defaultClass = COM_FUNCTION_DEFINED_DEFAULT;
+            defVal = colNode->getDefaultExprString();
+          }
         else
           {
             defaultClass = COM_ALWAYS_COMPUTE_COMPUTED_COLUMN_DEFAULT;
@@ -3190,6 +3195,24 @@ short CmpSeabaseDDL::getColInfo(ElemDDLColDef * colNode,
         {
           defaultClass = COM_CURRENT_DEFAULT;
         }
+      else if (ie->getOperatorType() == ITM_UNIX_TIMESTAMP)
+        {
+          defaultClass = COM_CURRENT_UT_DEFAULT;
+        }
+      else if ((ie->getOperatorType() == ITM_CAST) &&
+               (ie->getChild(0)->castToItemExpr()->getOperatorType() == ITM_UNIX_TIMESTAMP))
+        {
+          defaultClass = COM_CURRENT_UT_DEFAULT;
+        }
+      else if (ie->getOperatorType() == ITM_UNIQUE_ID)
+        {
+          defaultClass = COM_UUID_DEFAULT;
+        }
+      else if ((ie->getOperatorType() == ITM_CAST) &&
+               (ie->getChild(0)->castToItemExpr()->getOperatorType() == ITM_UNIQUE_ID))
+        {
+          defaultClass = COM_UUID_DEFAULT;
+        }
       else if ((ie->getOperatorType() == ITM_USER) ||
                (ie->getOperatorType() == ITM_CURRENT_USER) ||
                (ie->getOperatorType() == ITM_SESSION_USER))

http://git-wip-us.apache.org/repos/asf/trafodion/blob/6b800c34/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
index 248deef..6aa6760 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
@@ -5424,6 +5424,8 @@ void CmpSeabaseDDL::alterSeabaseTableAddColumn(
       if ((pDefVal) &&
           (pDefVal->origOpType() != ITM_CURRENT_USER) &&
           (pDefVal->origOpType() != ITM_CURRENT_TIMESTAMP) &&
+          (pDefVal->origOpType() != ITM_UNIX_TIMESTAMP) &&
+          (pDefVal->origOpType() != ITM_UNIQUE_ID) &&
           (pDefVal->origOpType() != ITM_CAST))
         {
           if (pDefVal->isNull()) 
@@ -11356,6 +11358,11 @@ Lng32 CmpSeabaseDDL::getSeabaseColumnInfo(ExeCliInterface *cliInterface,
                 tableIsSalted = TRUE;
             }
         }
+      else if (colInfo.defaultClass == COM_FUNCTION_DEFINED_DEFAULT)
+        {
+          oi->get(14, data, len);
+          tempDefVal =  data ;
+        }
       else if (colInfo.defaultClass == COM_NULL_DEFAULT)
         {
           tempDefVal = "NULL";
@@ -11368,6 +11375,14 @@ Lng32 CmpSeabaseDDL::getSeabaseColumnInfo(ExeCliInterface *cliInterface,
         {
           tempDefVal = "CURRENT_TIMESTAMP";
         }
+      else if (colInfo.defaultClass == COM_CURRENT_UT_DEFAULT)
+        {
+          tempDefVal = "UNIX_TIMESTAMP()";
+        }
+      else if (colInfo.defaultClass == COM_UUID_DEFAULT)
+        {
+          tempDefVal = "UUID()";
+        }
       else if ((colInfo.defaultClass == COM_IDENTITY_GENERATED_BY_DEFAULT) ||
                (colInfo.defaultClass == COM_IDENTITY_GENERATED_ALWAYS))
         {

http://git-wip-us.apache.org/repos/asf/trafodion/blob/6b800c34/core/sql/sqlcomp/CmpSeabaseDDLutil.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLutil.cpp b/core/sql/sqlcomp/CmpSeabaseDDLutil.cpp
index 4b1fd68..c208424 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLutil.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLutil.cpp
@@ -315,6 +315,9 @@ const literalAndEnumStruct ColumnDefaultClassXlateArray [] =
   {COM_USER_DEFINED_DEFAULT, COM_USER_DEFINED_DEFAULT_LIT},
   {COM_USER_FUNCTION_DEFAULT, COM_USER_FUNCTION_DEFAULT_LIT},
   {COM_CURRENT_DEFAULT, COM_CURRENT_DEFAULT_LIT},
+  {COM_CURRENT_UT_DEFAULT, COM_CURRENT_UT_DEFAULT_LIT},
+  {COM_UUID_DEFAULT, COM_UUID_DEFAULT_LIT},
+  {COM_FUNCTION_DEFINED_DEFAULT, COM_FUNCTION_DEFINED_DEFAULT_LIT},
   {COM_IDENTITY_GENERATED_BY_DEFAULT, COM_IDENTITY_GENERATED_BY_DEFAULT_LIT},
   {COM_IDENTITY_GENERATED_ALWAYS, COM_IDENTITY_GENERATED_ALWAYS_LIT},
   {COM_ALWAYS_COMPUTE_COMPUTED_COLUMN_DEFAULT, COM_ALWAYS_COMPUTE_COMPUTED_COLUMN_DEFAULT_LIT},
@@ -330,6 +333,9 @@ const literalAndEnumStruct ParamDefaultClassXlateArray [] =
 {
   {COM_NO_PARAM_DEFAULT, COM_NO_PARAM_DEFAULT_LIT},  // the default
   {COM_CURRENT_PARAM_DEFAULT, COM_CURRENT_PARAM_DEFAULT_LIT},              // e.g. DEFAULT CURRENT DATE
+  {COM_CURRENT_UT_PARAM_DEFAULT, COM_CURRENT_UT_PARAM_DEFAULT_LIT},              // e.g. DEFAULT CURRENT DATE
+  {COM_UUID_PARAM_DEFAULT, COM_UUID_PARAM_DEFAULT_LIT},              // e.g. DEFAULT CURRENT DATE
+  {COM_FUNCTION_DEFINED_PARAM_DEFAULT, COM_FUNCTION_DEFINED_PARAM_DEFAULT_LIT},              // e.g. DEFAULT CURRENT DATE
   {COM_NULL_PARAM_DEFAULT, COM_NULL_PARAM_DEFAULT_LIT},                    // i.e. DEFAULT NULL
   {COM_USER_DEFINED_PARAM_DEFAULT, COM_USER_DEFINED_PARAM_DEFAULT_LIT},    // e.g. DEFAULT 'a-string-literal'
   {COM_USER_FUNCTION_PARAM_DEFAULT, COM_USER_FUNCTION_PARAM_DEFAULT_LIT},  // e.g. DEFAULT CURRENT USER


[3/6] trafodion git commit: add upsert test cases

Posted by li...@apache.org.
add upsert test cases


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

Branch: refs/heads/master
Commit: 27952401f3a2b7ca4d4fdd05a77d0a2e120ae182
Parents: 5f58cd9
Author: Liu Ming <ov...@sina.com>
Authored: Tue Mar 20 23:59:09 2018 +0000
Committer: Liu Ming <ov...@sina.com>
Committed: Tue Mar 20 23:59:09 2018 +0000

----------------------------------------------------------------------
 core/sql/parser/ElemDDLColDef.h      | 8 --------
 core/sql/regress/seabase/EXPECTED020 | 8 +++++++-
 core/sql/regress/seabase/TEST020     | 2 ++
 3 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/27952401/core/sql/parser/ElemDDLColDef.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLColDef.h b/core/sql/parser/ElemDDLColDef.h
index 25dd0a3..4b78484 100644
--- a/core/sql/parser/ElemDDLColDef.h
+++ b/core/sql/parser/ElemDDLColDef.h
@@ -127,7 +127,6 @@ public:
         // 3. The DEFAULT clause appears.
   
   inline ItemExpr * getDefaultValueExpr() const;
-  inline Int32 getErrorCode() const;
   
         // returns the default value specified in the DEFAULT
         // clause; returns the NULL pointer value if NO DEFAULT
@@ -313,7 +312,6 @@ private:
 
   NABoolean isColDefaultSpec_;
 
-  Int32 errCode_;
 }; // class ElemDDLColDef
 
 // -----------------------------------------------------------------------
@@ -408,12 +406,6 @@ ElemDDLColDef::getDefaultValueExpr() const
   return pDefault_;
 }
 
-inline Int32
-ElemDDLColDef::getErrorCode() const
-{
-  return errCode_;
-}
-
 inline const NAString &
 ElemDDLColDef::getComputedDefaultExpr() const
 {

http://git-wip-us.apache.org/repos/asf/trafodion/blob/27952401/core/sql/regress/seabase/EXPECTED020
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED020 b/core/sql/regress/seabase/EXPECTED020
index 3396b6d..32c151d 100644
--- a/core/sql/regress/seabase/EXPECTED020
+++ b/core/sql/regress/seabase/EXPECTED020
@@ -3958,12 +3958,18 @@ AAAA                       ?            2
 >>insert into test020t45(e) values(1),(2),(3);
 
 --- 3 row(s) inserted.
+>>upsert into test020t45(e) values(4),(5);
+
+--- 2 row(s) inserted.
+>>upsert using load into test020t45(e) values (6);
+
+--- 1 row(s) inserted.
 >>select count(*) from test020t45 where c = to_char(sysdate,'YYYYMMDD');
 
 (EXPR)              
 --------------------
 
-                   3
+                   6
 
 --- 1 row(s) selected.
 >>--negative tests

http://git-wip-us.apache.org/repos/asf/trafodion/blob/27952401/core/sql/regress/seabase/TEST020
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST020 b/core/sql/regress/seabase/TEST020
index 80681ae..deb6583 100755
--- a/core/sql/regress/seabase/TEST020
+++ b/core/sql/regress/seabase/TEST020
@@ -940,6 +940,8 @@ create table test020t45(a  largeint not null default unix_timestamp(),
                         --d  int not null default testi020_seq.nextval,
                         e  int );
 insert into test020t45(e) values(1),(2),(3);
+upsert into test020t45(e) values(4),(5);
+upsert using load into test020t45(e) values (6); 
 select count(*) from test020t45 where c = to_char(sysdate,'YYYYMMDD');
 --negative tests
 --the function is not variable-free, so should fail


[6/6] trafodion git commit: merge [TRAFODION-2335]

Posted by li...@apache.org.
merge [TRAFODION-2335] 


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

Branch: refs/heads/master
Commit: 995e8a0904e8fdb9195ecc1b4346b89a20aa7d63
Parents: ee2cff9 fce62f8
Author: Liu Ming <ov...@sina.com>
Authored: Fri Apr 6 17:55:28 2018 +0000
Committer: Liu Ming <ov...@sina.com>
Committed: Fri Apr 6 17:55:28 2018 +0000

----------------------------------------------------------------------
 core/sql/common/ComSmallDefs.h           |  38 ++++++---
 core/sql/exp/exp_attrs.cpp               |   2 +
 core/sql/exp/exp_attrs.h                 |   2 +-
 core/sql/generator/GenExpGenerator.cpp   |  14 ++++
 core/sql/optimizer/BindItemExpr.cpp      |   1 +
 core/sql/optimizer/BindRelExpr.cpp       |   7 +-
 core/sql/optimizer/ColStatDesc.cpp       |   4 +
 core/sql/optimizer/ItemExpr.cpp          |   2 +
 core/sql/optimizer/ItemFunc.h            |   6 ++
 core/sql/optimizer/ValueDesc.cpp         |   2 +-
 core/sql/parser/ElemDDLCol.cpp           |  41 +++++++++-
 core/sql/parser/ElemDDLColDef.h          |   9 +++
 core/sql/parser/ElemDDLColDefault.h      |  17 ++++
 core/sql/parser/sqlparser.y              |  42 ++++++++--
 core/sql/regress/seabase/EXPECTED020     | 109 ++++++++++++++++++++++++++
 core/sql/regress/seabase/TEST020         |  38 +++++++++
 core/sql/sqlcomp/CmpDescribe.cpp         |   6 +-
 core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp |  23 ++++++
 core/sql/sqlcomp/CmpSeabaseDDLtable.cpp  |  15 ++++
 core/sql/sqlcomp/CmpSeabaseDDLutil.cpp   |   6 ++
 20 files changed, 362 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/995e8a09/core/sql/exp/exp_attrs.cpp
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafodion/blob/995e8a09/core/sql/exp/exp_attrs.h
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafodion/blob/995e8a09/core/sql/generator/GenExpGenerator.cpp
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafodion/blob/995e8a09/core/sql/optimizer/BindItemExpr.cpp
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafodion/blob/995e8a09/core/sql/optimizer/BindRelExpr.cpp
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafodion/blob/995e8a09/core/sql/optimizer/ItemExpr.cpp
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafodion/blob/995e8a09/core/sql/optimizer/ItemFunc.h
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafodion/blob/995e8a09/core/sql/optimizer/ValueDesc.cpp
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafodion/blob/995e8a09/core/sql/parser/sqlparser.y
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafodion/blob/995e8a09/core/sql/sqlcomp/CmpDescribe.cpp
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafodion/blob/995e8a09/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafodion/blob/995e8a09/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
----------------------------------------------------------------------


[5/6] trafodion git commit: take care of merge value

Posted by li...@apache.org.
take care of merge value


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

Branch: refs/heads/master
Commit: fce62f89e5bd07764fb00e3b0503dfab1998a8e8
Parents: 007dcc6
Author: Liu Ming <ov...@sina.com>
Authored: Sun Mar 25 17:40:01 2018 +0000
Committer: Liu Ming <ov...@sina.com>
Committed: Sun Mar 25 17:40:01 2018 +0000

----------------------------------------------------------------------
 core/sql/common/ComSmallDefs.h       | 36 ++++++++-----
 core/sql/optimizer/BindRelExpr.cpp   |  3 +-
 core/sql/optimizer/ItemExpr.cpp      |  2 +
 core/sql/regress/seabase/EXPECTED020 | 88 ++++++++++++++++++++++++++++---
 core/sql/regress/seabase/TEST020     | 29 ++++++++--
 5 files changed, 130 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/fce62f89/core/sql/common/ComSmallDefs.h
----------------------------------------------------------------------
diff --git a/core/sql/common/ComSmallDefs.h b/core/sql/common/ComSmallDefs.h
index 54d0cbf..29a0e0f 100644
--- a/core/sql/common/ComSmallDefs.h
+++ b/core/sql/common/ComSmallDefs.h
@@ -609,18 +609,22 @@ enum ComColumnClass { COM_UNKNOWN_CLASS
 #define COM_MV_SYSTEM_ADDED_COLUMN_LIT      "M "
 #define COM_ALTERED_USER_COLUMN_LIT         "C "
 
-enum ComColumnDefaultClass { COM_CURRENT_DEFAULT
-                           , COM_CURRENT_UT_DEFAULT
-                           , COM_NO_DEFAULT
-                           , COM_NULL_DEFAULT
-                           , COM_USER_DEFINED_DEFAULT
-                           , COM_USER_FUNCTION_DEFAULT
-                           , COM_UUID_DEFAULT
-                           , COM_IDENTITY_GENERATED_BY_DEFAULT
-                           , COM_IDENTITY_GENERATED_ALWAYS
-                           , COM_ALWAYS_COMPUTE_COMPUTED_COLUMN_DEFAULT
-                           , COM_ALWAYS_DEFAULT_COMPUTED_COLUMN_DEFAULT
-                           , COM_FUNCTION_DEFINED_DEFAULT
+/* This enum will be saved as integer in metadata tables
+ * If you change it, that will affect the existing values
+ * Make sure to add new values at the end
+ */
+enum ComColumnDefaultClass { COM_CURRENT_DEFAULT = 0
+                           , COM_NO_DEFAULT = 1
+                           , COM_NULL_DEFAULT = 2
+                           , COM_USER_DEFINED_DEFAULT = 3
+                           , COM_USER_FUNCTION_DEFAULT = 4
+                           , COM_IDENTITY_GENERATED_BY_DEFAULT = 5
+                           , COM_IDENTITY_GENERATED_ALWAYS =6
+                           , COM_ALWAYS_COMPUTE_COMPUTED_COLUMN_DEFAULT = 7
+                           , COM_ALWAYS_DEFAULT_COMPUTED_COLUMN_DEFAULT = 8
+                           , COM_UUID_DEFAULT = 9 
+                           , COM_CURRENT_UT_DEFAULT = 10
+                           , COM_FUNCTION_DEFINED_DEFAULT = 11
                            };
 
 #define COM_CURRENT_DEFAULT_LIT                     "CD"
@@ -636,20 +640,24 @@ enum ComColumnDefaultClass { COM_CURRENT_DEFAULT
 #define COM_ALWAYS_COMPUTE_COMPUTED_COLUMN_DEFAULT_LIT "AC"
 #define COM_ALWAYS_DEFAULT_COMPUTED_COLUMN_DEFAULT_LIT "AD"
 
+/* This enum will be saved as integer in metadata tables
+ * If you change it, that will affect the existing values
+ * Make sure to add new values at the end
+ */
 enum ComParamDefaultClass { COM_CURRENT_PARAM_DEFAULT        = COM_CURRENT_DEFAULT
-                          , COM_CURRENT_UT_PARAM_DEFAULT     = COM_CURRENT_UT_DEFAULT
                           , COM_NO_PARAM_DEFAULT 
                                                              = COM_NO_DEFAULT
                           , COM_NULL_PARAM_DEFAULT           = COM_NULL_DEFAULT
                           , COM_USER_DEFINED_PARAM_DEFAULT   = COM_USER_DEFINED_DEFAULT
                           , COM_USER_FUNCTION_PARAM_DEFAULT  = COM_USER_FUNCTION_DEFAULT
-                          , COM_UUID_PARAM_DEAULT            = COM_UUID_DEFAULT
                             // IDENTITY GENERATED BY DEFAULT not applicable
                             // IDENTITY GENERATED ALWAYS     not applicable
                           , COM_ALWAYS_COMPUTE_COMPUTED_PARAM_DEFAULT // for future internal use only
                                                              = COM_ALWAYS_COMPUTE_COMPUTED_COLUMN_DEFAULT
                           , COM_ALWAYS_DEFAULT_COMPUTED_PARAM_DEFAULT // for future internal use only
                                                              = COM_ALWAYS_DEFAULT_COMPUTED_COLUMN_DEFAULT
+                          , COM_UUID_PARAM_DEAULT            = COM_UUID_DEFAULT
+                          , COM_CURRENT_UT_PARAM_DEFAULT     = COM_CURRENT_UT_DEFAULT
                           , COM_FUNCTION_DEFINED_PARAM_DEFAULT
                                                              = COM_FUNCTION_DEFINED_DEFAULT
                           };

http://git-wip-us.apache.org/repos/asf/trafodion/blob/fce62f89/core/sql/optimizer/BindRelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindRelExpr.cpp b/core/sql/optimizer/BindRelExpr.cpp
index eb5bbe0..89908b2 100644
--- a/core/sql/optimizer/BindRelExpr.cpp
+++ b/core/sql/optimizer/BindRelExpr.cpp
@@ -10425,7 +10425,8 @@ RelExpr *Insert::bindNode(BindWA *bindWA)
           // column. COM_CURRENT_DEFAULT is only used for Datetime
           // columns.
           //
-          if (nacol->getDefaultClass() == COM_CURRENT_DEFAULT) {
+          if (nacol->getDefaultClass() == COM_CURRENT_DEFAULT || nacol->getDefaultClass() == COM_CURRENT_UT_DEFAULT 
+             || nacol->getDefaultClass() == COM_UUID_DEFAULT) {
             castType = nacol->getType()->newCopy(bindWA->wHeap());
             omittedCurrentDefaultClassCols = TRUE;
             omittedDefaultCols = TRUE;

http://git-wip-us.apache.org/repos/asf/trafodion/blob/fce62f89/core/sql/optimizer/ItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemExpr.cpp b/core/sql/optimizer/ItemExpr.cpp
index 744a0a5..324a0bd 100644
--- a/core/sql/optimizer/ItemExpr.cpp
+++ b/core/sql/optimizer/ItemExpr.cpp
@@ -875,6 +875,7 @@ NABoolean ItemExpr::doesExprEvaluateToConstant(NABoolean strict,
 		case ITM_CURRENT_USER:
 		case ITM_SESSION_USER:
 		case ITM_CURRENT_TIMESTAMP:
+		case ITM_UNIX_TIMESTAMP:
 		case ITM_GET_TRIGGERS_STATUS:
 		case ITM_UNIQUE_EXECUTE_ID:
 		case ITM_CURR_TRANSID:
@@ -967,6 +968,7 @@ NABoolean ItemExpr::referencesAHostVar() const
       case ITM_CURRENT_USER:
       case ITM_SESSION_USER:
       case ITM_CURRENT_TIMESTAMP:
+      case ITM_UNIX_TIMESTAMP:
       case ITM_GET_TRIGGERS_STATUS:
       case ITM_UNIQUE_EXECUTE_ID:
       case ITM_CURR_TRANSID:

http://git-wip-us.apache.org/repos/asf/trafodion/blob/fce62f89/core/sql/regress/seabase/EXPECTED020
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED020 b/core/sql/regress/seabase/EXPECTED020
index 32c151d..3c1104b 100644
--- a/core/sql/regress/seabase/EXPECTED020
+++ b/core/sql/regress/seabase/EXPECTED020
@@ -3947,31 +3947,103 @@ AAAA                       ?            2
 >>
 >>obey TEST020(trafodion_2335);
 >>--create seqence test020_seq;
+>>cqd traf_upsert_mode 'merge';
+
+--- SQL operation complete.
+>>cqd traf_aligned_row_format 'off' ;
+
+--- SQL operation complete.
 >>create table test020t45(a  largeint not null default unix_timestamp(),
 +>                        b  char(36) not null default uuid(),
 +>                        c  varchar(10) default to_char(sysdate,'YYYYMMDD'),
 +>                        --support sequence as default in next check-in
 +>                        --d  int not null default testi020_seq.nextval,
-+>                        e  int );
++>                        e int not null,
++>                        f int, primary key(e));
 
 --- SQL operation complete.
->>insert into test020t45(e) values(1),(2),(3);
+>>-- check if the timestamp is inserted with the recent timestamp
+>>insert into test020t45(e,f) values(1,1),(2,2),(3,3);
 
 --- 3 row(s) inserted.
->>upsert into test020t45(e) values(4),(5);
+>>select sleep(1) from dual;
 
---- 2 row(s) inserted.
->>upsert using load into test020t45(e) values (6);
+(EXPR) 
+--------------------
+
+                   1
+
+--- 1 row(s) selected.
+>>upsert into test020t45(e,f) values(1,4);
 
 --- 1 row(s) inserted.
->>select count(*) from test020t45 where c = to_char(sysdate,'YYYYMMDD');
+>>select count(distinct(a)),count(distinct(b)),count(distinct(c)) from test020t45 ;
 
-(EXPR)              
+(EXPR)                (EXPR)                (EXPR)
+--------------------  --------------------  --------------------
+
+                   1                     3                     1
+
+--- 1 row(s) selected.
+>>
+>>cqd traf_upsert_mode 'replace';
+
+--- SQL operation complete.
+>>delete from test020t45;
+
+--- 3 row(s) deleted.
+>>insert into test020t45(e,f) values(1,1),(2,2),(3,3);
+
+--- 3 row(s) inserted.
+>>select sleep(1) from dual;
+
+(EXPR) 
 --------------------
 
-                   6
+                   1
 
 --- 1 row(s) selected.
+>>upsert into test020t45(e,f) values(1,4);
+
+--- 1 row(s) inserted.
+>>select count(distinct(a)),count(distinct(b)),count(distinct(c)) from test020t45 ;
+
+(EXPR)                (EXPR)                (EXPR)
+--------------------  --------------------  --------------------
+
+                   2                     3                     1
+
+--- 1 row(s) selected.
+>>
+>>cqd traf_upsert_mode 'optimal';
+
+--- SQL operation complete.
+>>delete from test020t45;
+
+--- 3 row(s) deleted.
+>>insert into test020t45(e,f) values(1,1),(2,2),(3,3);
+
+--- 3 row(s) inserted.
+>>select sleep(1) from dual;
+
+(EXPR) 
+--------------------
+
+                   1
+
+--- 1 row(s) selected.
+>>upsert into test020t45(e,f) values(1,4);
+
+--- 1 row(s) inserted.
+>>select count(distinct(a)),count(distinct(b)),count(distinct(c)) from test020t45 ;
+
+(EXPR)                (EXPR)                (EXPR)
+--------------------  --------------------  --------------------
+
+                   1                     3                     1
+
+--- 1 row(s) selected.
+>>
 >>--negative tests
 >>--the function is not variable-free, so should fail
 >>create table test020t45(a  largeint not null default unix_timestamp(),

http://git-wip-us.apache.org/repos/asf/trafodion/blob/fce62f89/core/sql/regress/seabase/TEST020
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST020 b/core/sql/regress/seabase/TEST020
index deb6583..47b6aec 100755
--- a/core/sql/regress/seabase/TEST020
+++ b/core/sql/regress/seabase/TEST020
@@ -933,16 +933,35 @@ select * from test020t44;
 
 ?section trafodion_2335
 --create seqence test020_seq;
+cqd traf_upsert_mode 'merge';
+cqd traf_aligned_row_format 'off' ;
 create table test020t45(a  largeint not null default unix_timestamp(),
                         b  char(36) not null default uuid(),
                         c  varchar(10) default to_char(sysdate,'YYYYMMDD'),
                         --support sequence as default in next check-in
                         --d  int not null default testi020_seq.nextval,
-                        e  int );
-insert into test020t45(e) values(1),(2),(3);
-upsert into test020t45(e) values(4),(5);
-upsert using load into test020t45(e) values (6); 
-select count(*) from test020t45 where c = to_char(sysdate,'YYYYMMDD');
+                        e  int not null,
+                        f  int, primary key(e));
+-- check if the timestamp is inserted with the recent timestamp
+insert into test020t45(e,f) values(1,1),(2,2),(3,3);
+select sleep(1) from dual;
+upsert into test020t45(e,f) values(1,4);
+select count(distinct(a)),count(distinct(b)),count(distinct(c)) from test020t45 ;
+
+cqd traf_upsert_mode 'replace';
+delete from test020t45;
+insert into test020t45(e,f) values(1,1),(2,2),(3,3);
+select sleep(1) from dual;
+upsert into test020t45(e,f) values(1,4);
+select count(distinct(a)),count(distinct(b)),count(distinct(c)) from test020t45 ;
+
+cqd traf_upsert_mode 'optimal';
+delete from test020t45;
+insert into test020t45(e,f) values(1,1),(2,2),(3,3);
+select sleep(1) from dual;
+upsert into test020t45(e,f) values(1,4);
+select count(distinct(a)),count(distinct(b)),count(distinct(c)) from test020t45 ;
+
 --negative tests
 --the function is not variable-free, so should fail
 create table test020t45(a  largeint not null default unix_timestamp(),


[2/6] trafodion git commit: update the regression test and various fixes

Posted by li...@apache.org.
update the regression test and various fixes


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

Branch: refs/heads/master
Commit: 5f58cd95aa72f4cbe944aa8d0aeb11eb0202f524
Parents: 6b800c3
Author: Liu Ming <ov...@sina.com>
Authored: Sun Mar 18 09:19:35 2018 +0000
Committer: Liu Ming <ov...@sina.com>
Committed: Sun Mar 18 09:19:35 2018 +0000

----------------------------------------------------------------------
 core/sql/optimizer/BindItemExpr.cpp      |  1 +
 core/sql/optimizer/ItemFunc.h            |  6 ++++++
 core/sql/parser/ElemDDLColDefault.h      |  4 ++--
 core/sql/parser/sqlparser.y              | 25 +++++++++++++++------
 core/sql/regress/seabase/EXPECTED020     | 31 +++++++++++++++++++++++++++
 core/sql/regress/seabase/TEST020         |  2 +-
 core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp | 12 +++++------
 7 files changed, 66 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/5f58cd95/core/sql/optimizer/BindItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindItemExpr.cpp b/core/sql/optimizer/BindItemExpr.cpp
index 3c81218..2541ab9 100644
--- a/core/sql/optimizer/BindItemExpr.cpp
+++ b/core/sql/optimizer/BindItemExpr.cpp
@@ -4166,6 +4166,7 @@ DateFormat::DateFormat(ItemExpr *val1Ptr, const NAString &formatStr,
        wasDateformat_(wasDateformat),
        formatType_(formatType),
        frmt_(-1),
+       origString_(""),
        dateFormat_(DATE_FORMAT_NONE)
 { 
   allowsSQLnullArg() = FALSE; 

http://git-wip-us.apache.org/repos/asf/trafodion/blob/5f58cd95/core/sql/optimizer/ItemFunc.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemFunc.h b/core/sql/optimizer/ItemFunc.h
index 6c0c779..ee5dcdc 100644
--- a/core/sql/optimizer/ItemFunc.h
+++ b/core/sql/optimizer/ItemFunc.h
@@ -1918,6 +1918,9 @@ public:
 
   ItemExpr * bindNode(BindWA * bindWA);
 
+  void setOriginalString(NAString &s) {origString_ = s; }
+  const NAString & getOriginalString() const { return origString_; }
+
   // a virtual function for type propagating the node
   virtual const NAType * synthesizeType();
 
@@ -1954,6 +1957,9 @@ private:
 
   // actual datetime format (defined in class ExpDatetime in exp_datetime.h)
   Lng32 frmt_;
+
+  //original string
+  NAString origString_;
 }; // class DateFormat
 
 class DayOfWeek : public CacheableBuiltinFunction

http://git-wip-us.apache.org/repos/asf/trafodion/blob/5f58cd95/core/sql/parser/ElemDDLColDefault.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLColDefault.h b/core/sql/parser/ElemDDLColDefault.h
index e435400..0415e6b 100644
--- a/core/sql/parser/ElemDDLColDefault.h
+++ b/core/sql/parser/ElemDDLColDefault.h
@@ -108,7 +108,7 @@ public:
   // mutator
   virtual void setChild(Lng32 index, ExprNode * pChildNode);
   inline  void setDefaultValueExpr(ItemExpr * pDefaultValueExpr);
-  inline  void setDefaultExprString(NAString &str);
+  inline  void setDefaultExprString(const NAString &str);
   inline void  setSGOptions(ElemDDLSGOptions * pSGOptions);
   inline void setSGLocation(NAString *pLocation);
   inline void setComputedDefaultExpr(const NAString &computedDefaultExpr);
@@ -165,7 +165,7 @@ ElemDDLColDefault::setDefaultValueExpr(ItemExpr * pDefaultValueExpr)
 }
 
 inline void
-ElemDDLColDefault::setDefaultExprString(NAString &str)
+ElemDDLColDefault::setDefaultExprString(const NAString &str)
 {
   defaultExprString_ = str;
 }

http://git-wip-us.apache.org/repos/asf/trafodion/blob/5f58cd95/core/sql/parser/sqlparser.y
----------------------------------------------------------------------
diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y
index dedd03f..c351181 100755
--- a/core/sql/parser/sqlparser.y
+++ b/core/sql/parser/sqlparser.y
@@ -8741,9 +8741,25 @@ datetime_value_function : TOK_CURDATE '(' ')'
 /* type item */
 datetime_misc_function_used_as_default:      TOK_TO_CHAR '(' value_expression ',' character_string_literal ')'
                                {
-
-                                $$ = new (PARSERHEAP()) 
+                                 NAString * ves= unicodeToChar
+                                   (ToTokvalPlusYYText(&$3)->yytext,
+                                   ToTokvalPlusYYText(&$3)->yyleng,
+                                   (CharInfo::CharSet) (
+                                          ComGetNameInterfaceCharSet() // CharInfo::UTF8
+                                          ),
+                                   PARSERHEAP()); 
+                                 //save the original text
+                                 NAString fullstr;
+                                 fullstr  += "TO_CHAR(";
+                                 //Column Reference will not be able to convert to NAString
+                                 //And it is not be allowed bo become default value, so no need to save original text 
+                                 if( ves != NULL) 
+                                 {
+                                   fullstr += *ves + ", '" +  *$5 + "')";
+                                 }
+                                 $$ = new (PARSERHEAP()) 
                                    DateFormat($3, *$5, DateFormat::FORMAT_TO_CHAR);
+                                 ((DateFormat *)$$)->setOriginalString(fullstr);
                                }
 
 /* type item */
@@ -25812,11 +25828,8 @@ col_def_default_clause_argument : literal_negatable
                                   $$ = new (PARSERHEAP())
 				    ElemDDLColDefault(
                                        ElemDDLColDefault::COL_FUNCTION_DEFAULT);
-                                  ItemExpr * firstItem = $1;
-                                  NAString unparsed(PARSERHEAP());
-                                  firstItem->unparse(unparsed); // expression as ascii string
 
-                                  ((ElemDDLColDefault *)$$)->setDefaultExprString(unparsed);
+                                  ((ElemDDLColDefault *)$$)->setDefaultExprString( (const NAString &)((DateFormat*)$1)->getOriginalString());
                                   ((ElemDDLColDefault *)$$)->setDefaultValueExpr($1);
                                 }
                       | builtin_function_user

http://git-wip-us.apache.org/repos/asf/trafodion/blob/5f58cd95/core/sql/regress/seabase/EXPECTED020
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED020 b/core/sql/regress/seabase/EXPECTED020
index 15771ce..3396b6d 100644
--- a/core/sql/regress/seabase/EXPECTED020
+++ b/core/sql/regress/seabase/EXPECTED020
@@ -3945,4 +3945,35 @@ AAAA                       ?            2
 
 --- 1 row(s) selected.
 >>
+>>obey TEST020(trafodion_2335);
+>>--create seqence test020_seq;
+>>create table test020t45(a  largeint not null default unix_timestamp(),
++>                        b  char(36) not null default uuid(),
++>                        c  varchar(10) default to_char(sysdate,'YYYYMMDD'),
++>                        --support sequence as default in next check-in
++>                        --d  int not null default testi020_seq.nextval,
++>                        e  int );
+
+--- SQL operation complete.
+>>insert into test020t45(e) values(1),(2),(3);
+
+--- 3 row(s) inserted.
+>>select count(*) from test020t45 where c = to_char(sysdate,'YYYYMMDD');
+
+(EXPR)              
+--------------------
+
+                   3
+
+--- 1 row(s) selected.
+>>--negative tests
+>>--the function is not variable-free, so should fail
+>>create table test020t45(a  largeint not null default unix_timestamp(),
++>                        b  varchar(10) default to_char(test020t45.c,'YYYYMMDD'),
++>                        e  int );
+
+*** ERROR[1084] An invalid default value was specified for column B.
+
+*** ERROR[8822] The statement was not prepared.
+
 >>log;

http://git-wip-us.apache.org/repos/asf/trafodion/blob/5f58cd95/core/sql/regress/seabase/TEST020
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST020 b/core/sql/regress/seabase/TEST020
index d435747..80681ae 100755
--- a/core/sql/regress/seabase/TEST020
+++ b/core/sql/regress/seabase/TEST020
@@ -940,7 +940,7 @@ create table test020t45(a  largeint not null default unix_timestamp(),
                         --d  int not null default testi020_seq.nextval,
                         e  int );
 insert into test020t45(e) values(1),(2),(3);
-select * from test020t45;
+select count(*) from test020t45 where c = to_char(sysdate,'YYYYMMDD');
 --negative tests
 --the function is not variable-free, so should fail
 create table test020t45(a  largeint not null default unix_timestamp(),

http://git-wip-us.apache.org/repos/asf/trafodion/blob/5f58cd95/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
index 3e602e8..dc9b108 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
@@ -3168,13 +3168,8 @@ short CmpSeabaseDDL::getColInfo(ElemDDLColDef * colNode,
             defaultClass = COM_IDENTITY_GENERATED_BY_DEFAULT;
         }
       else if (ie == NULL)
-        if (colNode->getComputedDefaultExpr().isNull() && colNode->getDefaultExprString().isNull())
+        if (colNode->getComputedDefaultExpr().isNull())
           defaultClass = COM_NO_DEFAULT;
-        else if(!colNode->getDefaultExprString().isNull())
-          {
-            defaultClass = COM_FUNCTION_DEFINED_DEFAULT;
-            defVal = colNode->getDefaultExprString();
-          }
         else
           {
             defaultClass = COM_ALWAYS_COMPUTE_COMPUTED_COLUMN_DEFAULT;
@@ -3186,6 +3181,11 @@ short CmpSeabaseDDL::getColInfo(ElemDDLColDef * colNode,
             else
               CMPASSERT(0);
           }
+      else if (!colNode->getDefaultExprString().isNull())
+        {
+            defaultClass = COM_FUNCTION_DEFINED_DEFAULT;
+            defVal = colNode->getDefaultExprString();
+        }
       else if (ie->getOperatorType() == ITM_CURRENT_TIMESTAMP)
         {
           defaultClass = COM_CURRENT_DEFAULT;


[4/6] trafodion git commit: Merge branch 'master' of git://git.apache.org/trafodion into TRAFODION-2335

Posted by li...@apache.org.
Merge branch 'master' of git://git.apache.org/trafodion into TRAFODION-2335


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

Branch: refs/heads/master
Commit: 007dcc68a41827d95ddf577af4810ff9e1206152
Parents: 2795240 5339170
Author: Liu Ming <ov...@sina.com>
Authored: Wed Mar 21 21:46:37 2018 +0000
Committer: Liu Ming <ov...@sina.com>
Committed: Wed Mar 21 21:46:37 2018 +0000

----------------------------------------------------------------------
 .rat-excludes                                   |   3 +-
 RAT_README                                      |   3 +-
 .../jdbc/t4/TrafT4PreparedStatement.java        |  21 +-
 .../export/include/common/evl_sqlog_eventnum.h  |  14 +
 core/sqf/monitor/linux/cluster.cxx              | 388 ++++++++--
 core/sqf/monitor/linux/cluster.h                |  26 +-
 core/sqf/monitor/linux/commaccept.cxx           | 108 +--
 core/sqf/monitor/linux/mlio.cxx                 |   7 +-
 core/sqf/monitor/linux/monitor.cxx              | 540 +++++++++++---
 core/sqf/monitor/linux/monitor.h                |   2 -
 core/sqf/monitor/linux/msgdef.h                 |  48 +-
 core/sqf/monitor/linux/pnode.cxx                |  67 +-
 core/sqf/monitor/linux/process.cxx              |  75 +-
 core/sqf/monitor/linux/reqprocinfo.cxx          |  83 ++-
 core/sqf/monitor/linux/reqqueue.cxx             |  10 +-
 core/sqf/monitor/linux/shell.cxx                | 273 ++++---
 core/sqf/monitor/linux/tmsync.cxx               |  10 +-
 core/sqf/monitor/linux/zclient.cxx              | 348 ++++++++-
 core/sqf/monitor/linux/zclient.h                |   5 +
 core/sqf/monitor/test/runtest                   |   3 +-
 core/sqf/sqenvcom.sh                            |  19 +
 core/sqf/sql/scripts/dcscheck                   |  24 +-
 core/sqf/sql/scripts/dcsstart                   |   8 +-
 core/sqf/sql/scripts/dcsstop                    |   9 +-
 core/sqf/sql/scripts/install_local_hadoop       |   5 +
 core/sqf/sql/scripts/install_traf_components    |   5 +-
 core/sqf/sql/scripts/sqcheck                    |   6 +-
 core/sqf/src/tm/tm_internal.h                   |   1 -
 core/sqf/src/tm/tmlibmsg.h                      |   4 +-
 core/sqf/src/tm/tools/dtmci.cpp                 |   2 -
 core/sqf/src/tm/tools/pwd.cpp                   |   2 -
 core/sqf/src/tm/tools/tmshutdown.cpp            |   1 -
 core/sqf/src/trafconf/clusterconf.cpp           |  10 +
 core/sqf/src/trafconf/clusterconf.h             |   4 +
 core/sql/arkcmp/CmpConnection.cpp               |   4 +-
 core/sql/arkcmp/CmpContext.cpp                  |  17 +-
 core/sql/arkcmp/CmpContext.h                    |   2 +-
 core/sql/bin/SqlciErrors.txt                    |   3 +-
 core/sql/cli/Cli.cpp                            | 294 ++------
 core/sql/cli/Context.cpp                        |  53 +-
 core/sql/cli/Context.h                          |  10 +
 core/sql/cli/ExSqlComp.cpp                      |  21 +-
 core/sql/cli/Globals.cpp                        |   1 +
 core/sql/cli/Globals.h                          |   1 +
 core/sql/cli/Statement.cpp                      |  11 +-
 core/sql/comexe/ComTdbBlockingHdfsScan.h        |   1 -
 core/sql/comexe/ComTdbHdfsScan.h                |  11 +-
 core/sql/common/ComRtUtils.cpp                  |   1 +
 core/sql/common/ComSmallDefs.h                  |   1 +
 core/sql/common/ComUser.cpp                     |   2 +-
 core/sql/common/NAString.cpp                    |   3 +-
 core/sql/common/Platform.h                      |   2 +
 core/sql/executor/ExCancel.cpp                  |   9 +-
 core/sql/executor/ExExeUtil.h                   |   1 -
 core/sql/executor/ExExeUtilCli.cpp              |   6 +-
 core/sql/executor/ExExeUtilCli.h                |   2 +-
 core/sql/executor/ExExeUtilGet.cpp              |   7 +-
 core/sql/executor/ExExeUtilGetStats.cpp         |   1 -
 core/sql/executor/ExExeUtilLoad.cpp             |  25 +-
 core/sql/executor/ExExplain.cpp                 |   6 +-
 core/sql/executor/ExFastTransport.cpp           |  48 +-
 core/sql/executor/ExHbaseAccess.cpp             |  11 +-
 core/sql/executor/ExHbaseIUD.cpp                |   2 +-
 core/sql/executor/ExHdfsScan.cpp                | 102 ++-
 core/sql/executor/ExHdfsScan.h                  |  24 +
 core/sql/executor/ExSMCommon.cpp                |   1 +
 core/sql/executor/ExSMCommon.h                  |   3 +-
 core/sql/executor/ExSMGlobals.cpp               |   1 +
 core/sql/executor/ExSMQueue.cpp                 |   2 +-
 core/sql/executor/ExSMReader.cpp                |   1 +
 core/sql/executor/ExSMShortMessage.cpp          |   2 +-
 core/sql/executor/ExSMTaskList.cpp              |   2 +-
 core/sql/executor/ExStats.cpp                   |   2 +-
 core/sql/executor/HBaseClient_JNI.cpp           |   1 -
 core/sql/executor/HdfsClient_JNI.cpp            | 426 +++++++++--
 core/sql/executor/HdfsClient_JNI.h              |  74 +-
 core/sql/executor/JavaObjectInterface.cpp       |   3 +-
 core/sql/executor/JavaObjectInterface.h         |  12 +-
 core/sql/executor/OrcFileReader.h               |   2 +-
 core/sql/executor/SequenceFileReader.h          |   4 +-
 core/sql/executor/ex_control.cpp                |   5 +-
 core/sql/executor/ex_ddl.cpp                    |  14 +-
 core/sql/executor/ex_root.cpp                   |  28 +-
 core/sql/exp/ExpLOBaccess.cpp                   | 144 +---
 core/sql/exp/ExpLOBaccess.h                     |   8 -
 core/sql/exp/exp_function.cpp                   |   2 +-
 core/sql/export/ComDiags.h                      |   8 +-
 core/sql/generator/GenFastTransport.cpp         |   4 +-
 core/sql/generator/GenPreCode.cpp               |   6 +-
 core/sql/generator/GenRelScan.cpp               |  19 +-
 core/sql/generator/GenRelUpdate.cpp             |   2 +
 .../java/org/trafodion/libmgmt/JDBCUDR.java     | 721 +++++++++++++++++++
 core/sql/nskgmake/tdm_sqlexp/Makefile           |   2 +-
 core/sql/optimizer/BindRelExpr.cpp              | 152 ++--
 core/sql/optimizer/HDFSHook.cpp                 |  35 +-
 core/sql/optimizer/HDFSHook.h                   |  16 +-
 core/sql/optimizer/Inlining.cpp                 |  19 +-
 core/sql/optimizer/NATable.cpp                  |   1 +
 core/sql/optimizer/OptimizerSimulator.cpp       |   3 +-
 core/sql/optimizer/RelExpr.cpp                  |  16 +-
 core/sql/optimizer/RelMisc.h                    |   3 +-
 core/sql/optimizer/RelScan.h                    |  18 +-
 core/sql/optimizer/ScanOptimizer.cpp            |   7 +-
 core/sql/optimizer/mdam.cpp                     |  30 +-
 core/sql/parser/SqlParserAux.cpp                |   4 +-
 core/sql/parser/sqlparser.y                     |  18 +-
 core/sql/regress/core/EXPECTED002.LINUX         | 147 +++-
 core/sql/regress/core/EXPECTED116               |   6 +-
 core/sql/regress/core/TEST002                   |  56 ++
 core/sql/regress/executor/EXPECTED001           |   3 +-
 core/sql/regress/executor/EXPECTED013.SB        |   3 +-
 core/sql/regress/hive/EXPECTED007               |   2 +-
 core/sql/regress/hive/EXPECTED018               |   2 +-
 core/sql/regress/hive/EXPECTED040               |   8 +-
 core/sql/regress/privs1/EXPECTED123             |  32 +
 core/sql/regress/privs1/EXPECTED125             |   8 +
 core/sql/regress/privs1/EXPECTED141             |   3 +-
 core/sql/regress/privs2/EXPECTED135             |  15 +-
 core/sql/regress/privs2/EXPECTED138             |   6 +-
 core/sql/regress/seabase/EXPECTED022            |   3 +-
 core/sql/regress/seabase/EXPECTED026            |   9 +-
 core/sql/regress/udr/EXPECTED002                |  97 ++-
 core/sql/regress/udr/EXPECTED102                |   2 +
 core/sql/regress/udr/TEST002                    |  58 +-
 core/sql/runtimestats/ssmpipc.cpp               |   4 +-
 core/sql/runtimestats/ssmpipc.h                 |   2 +-
 core/sql/sqlci/Param.cpp                        |   8 +-
 core/sql/sqlci/Param.h                          |   2 +-
 core/sql/sqlci/SqlCmd.cpp                       | 106 ++-
 core/sql/sqlci/SqlciCmd.cpp                     |   6 +-
 core/sql/sqlci/sqlcmd.h                         |   8 +-
 core/sql/sqlcomp/CmpDescribe.cpp                |   7 +-
 core/sql/sqlcomp/CmpSeabaseDDL.h                |   6 +
 core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp        |  21 +-
 core/sql/sqlcomp/CmpSeabaseDDLindex.cpp         |   8 +
 core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp       | 116 ++-
 core/sql/sqlcomp/CmpSeabaseDDLroutine.h         |  96 ++-
 core/sql/sqlcomp/CmpSeabaseDDLtable.cpp         |   1 -
 core/sql/sqlcomp/DefaultConstants.h             |   1 +
 .../main/java/org/trafodion/sql/HDFSClient.java | 307 ++++++--
 .../main/java/org/trafodion/sql/HdfsScan.java   |  95 ++-
 .../java/org/trafodion/sql/udr/LmT2Driver.java  |  12 +
 .../org/trafodion/sql/udr/predef/JDBCUDR.java   |  33 +-
 core/sql/ustat/hs_globals.cpp                   |  13 +-
 dcs/bin/dcs-config.sh                           |  14 +-
 dcs/bin/dcs-daemon.sh                           |  48 +-
 dcs/bin/getActiveMaster.sh                      |  80 ++
 dcs/bin/master-backup.sh                        |  36 +-
 dcs/bin/scripts/dcsbind.sh                      |  64 +-
 dcs/bin/scripts/dcsunbind.sh                    |  43 +-
 dcs/bin/scripts/parse_dcs_site.py               |  18 +-
 dcs/bin/start-dcs.sh                            |   9 +-
 dcs/bin/stop-dcs.sh                             |  16 +-
 dcs/conf/backup-masters                         |   0
 dcs/conf/master                                 |   0
 dcs/conf/masters                                |   0
 .../main/asciidoc/_chapters/configuration.adoc  | 220 +++---
 .../src/asciidoc/_chapters/odbc_windows.adoc    |  18 +-
 .../src/asciidoc/_chapters/preparation.adoc     |   2 +
 .../src/asciidoc/_chapters/binder_msgs.adoc     |  13 +
 .../sql_functions_and_expressions.adoc          | 205 ++++++
 .../src/asciidoc/_chapters/sql_statements.adoc  | 183 ++++-
 docs/src/site/markdown/documentation.md         |  21 +
 docs/src/site/markdown/download.md              |  88 ++-
 docs/src/site/markdown/release-notes-2-2-0.md   | 539 ++++++++++++++
 docs/src/site/markdown/release-notes.md         |   1 +
 .../TRAFODION/2.1/configuration/dcs-env.xml     |   7 +-
 .../2.1/package/scripts/trafodionnode.py        |  13 +-
 install/python-installer/scripts/dcs_setup.py   |   9 +-
 169 files changed, 5830 insertions(+), 1766 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/007dcc68/core/sql/common/ComSmallDefs.h
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafodion/blob/007dcc68/core/sql/optimizer/BindRelExpr.cpp
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafodion/blob/007dcc68/core/sql/parser/sqlparser.y
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafodion/blob/007dcc68/core/sql/sqlcomp/CmpDescribe.cpp
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafodion/blob/007dcc68/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafodion/blob/007dcc68/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
----------------------------------------------------------------------