http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/optimizer/BindItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindItemExpr.cpp 
b/core/sql/optimizer/BindItemExpr.cpp
index 3fd854e..72fa71f 100644
--- a/core/sql/optimizer/BindItemExpr.cpp
+++ b/core/sql/optimizer/BindItemExpr.cpp
@@ -77,6 +77,9 @@
 #include "ItemFuncUDF.h"
 #include "CmpSeabaseDDL.h"
 #include "QCache.h"
+
+#include "exp_datetime.h"
+
 #include <stack>
 
 
@@ -1236,6 +1239,7 @@ Int32 ItemExpr::shouldPushTranslateDown(CharInfo::CharSet 
chrset) const
      case ITM_CAST:                  // a) output is of a specific charset
      case ITM_CAST_CONVERT:          // a) internal node, too late to do ICAT
      case ITM_CAST_TYPE:
+     case ITM_DATEFORMAT:
        return -1;
 
      case ITM_LEFT:                  // b) counts characters
@@ -3708,19 +3712,10 @@ ItemExpr * ExtractOdbc::bindNode(BindWA * bindWA)
   return ie ;
 }
 
-ItemExpr * Format::bindNode(BindWA * bindWA)
+ItemExpr * DateFormat::quickDateFormatOpt(BindWA * bindWA)
 {
-  //  if (nodeIsBound()) 
-  //    return this;
-
-  bindSelf(bindWA);
-  if (bindWA->errStatus()) 
-    return this;
-
   const NAType *naType0 = &child(0)->getValueId().getType();
-  const NumericType * nType0 = NULL;
 
-  // a quick optimization for the date format.
   if ((CmpCommon::getDefault(MODE_SPECIAL_4) == DF_ON) &&
       (child(0)->getOperatorType() == ITM_CONSTANT) &&
       (formatStr_ == "DD-MON-YYYY") &&
@@ -3801,188 +3796,29 @@ ItemExpr * Format::bindNode(BindWA * bindWA)
       bindWA->resetErrStatus();
     }
 
+  return NULL;
+}
+
+ItemExpr * Format::bindNode(BindWA * bindWA)
+{
+  bindChildren(bindWA);
+  if (bindWA->errStatus()) 
+    return this;
+
+  const NAType *naType0 = &child(0)->getValueId().getType();
+  const NumericType * nType0 = NULL;
 
-  Int32 dateFormat = DateFormat::DEFAULT;
-  NABoolean formatAsDate = FALSE;
   NABoolean formatX = FALSE;
   NABoolean format9 = FALSE;
   NABoolean formatExtract = FALSE;
   Lng32 dotPos = 0;
   NABoolean formatNumericAsX = FALSE;
   NABoolean formatStringAsX  = FALSE;
-  if ((formatStr_ == "YYYY-MM-DD") ||
-      (formatStr_ == "MM/DD/YYYY") ||
-      (formatStr_ == "YY/MM/DD") ||
-      (formatStr_ == "YYYY/MM/DD") ||
-      (formatStr_ == "MM/DD/YY") ||
-      (formatStr_ == "YYYYMMDD") ||
-      (formatStr_ == "DD.MM.YYYY") ||
-      (formatStr_ == "DD-MM-YYYY") ||
-      (formatStr_ == "DD-MMM-YYYY") ||
-      (formatStr_ == "DD-MON-YYYY") ||
-      (formatStr_ == "DDMONYYYY") ||
-      (formatStr_ == "YYYYMMDDHH24MISS") ||
-      (formatStr_ == "YYYYMMDD:HH24:MI:SS") ||
-      (formatStr_ == "DD.MM.YYYY:HH24:MI:SS") ||
-      (formatStr_ == "YYYY-MM-DD HH24:MI:SS") ||
-      (formatStr_ == "MMDDYYYY HH24:MI:SS") ||
-      (formatStr_ == "MM/DD/YYYY HH24:MI:SS") ||
-      (formatStr_ == "DD-MON-YYYY HH:MI:SS") ||
-      (formatStr_ == "HH24:MI:SS") ||
-      (formatStr_ == "YYYYMM") ||
-      (formatStr_ == "YYYY-MM") ||
-      (formatStr_ == "SYYYYMM") ||
-      (formatStr_ == "MM-DD-YYYY"))
-    {
-      if (formatType_ == FORMAT_TO_CHAR)
-       {
-         if (naType0->getTypeQualifier() != NA_DATETIME_TYPE)
-           {
-             *CmpCommon::diags() << DgSqlCode(-4071) << DgString0("TO_CHAR");
-             bindWA->setErrStatus();
-             return this;
-           }
-
-         if ((formatStr_ == "HH24:MI:SS") &&
-             (naType0->getPrecision() != SQLDTCODE_TIMESTAMP) &&
-             (naType0->getPrecision() != SQLDTCODE_TIME))
-           {
-             *CmpCommon::diags() << DgSqlCode(-4072) << DgString0("TO_CHAR") 
<< DgString1("time");;
-             bindWA->setErrStatus();
-             return this;
-           }
-       }
-
-      if ((formatType_ == FORMAT_TO_DATE) &&
-         ((naType0->getTypeQualifier() != NA_CHARACTER_TYPE) &&
-          (naType0->getTypeQualifier() != NA_NUMERIC_TYPE)))
-       {
-         *CmpCommon::diags() << DgSqlCode(-4043) << DgString0("TO_DATE");
-         bindWA->setErrStatus();
-         return this;
-       }
-      
-      if ((naType0->getTypeQualifier() == NA_CHARACTER_TYPE) &&
-          (formatCharToDate_ == FALSE))
-       {
-         *CmpCommon::diags() << DgSqlCode(-4065) << DgString0(formatStr_)
-                             << DgString1(formatType_ == FORMAT_GENERIC ? 
"FORMAT" 
-                                          : (formatType_ == FORMAT_TO_CHAR ? 
"TO_CHAR" : "TO_DATE"));
-         
-         bindWA->setErrStatus();
-         return this;
-       }
-      
-      if (((formatStr_ == "YYYYMMDDHH24MISS") ||
-          (formatStr_ == "YYYYMMDD:HH24:MI:SS") ||
-          (formatStr_ == "DD.MM.YYYY:HH24:MI:SS") ||
-          (formatStr_ == "YYYY-MM-DD HH24:MI:SS") ||
-          (formatStr_ == "MMDDYYYY HH24:MI:SS") ||
-          (formatStr_ == "MM/DD/YYYY HH24:MI:SS") ||
-          (formatStr_ == "HH24:MI:SS") ||
-          (formatStr_ == "MM/DD/YY") ||
-          (formatStr_ == "YYYYMM") ||
-          (formatStr_ == "YYYY-MM") ||
-          (formatStr_ == "SYYYYMM") ||
-          (formatStr_ == "DDMONYYYY") ||
-          (formatStr_ == "MM-DD-YYYY")) &&
-         (CmpCommon::getDefault(MODE_SPECIAL_3) == DF_OFF))
-       {
-         *CmpCommon::diags() << DgSqlCode(-4065) << DgString0(formatStr_)
-                             << DgString1(formatType_ == FORMAT_GENERIC ? 
"FORMAT" 
-                                          : (formatType_ == FORMAT_TO_CHAR ? 
"TO_CHAR" : "TO_DATE"));
-         bindWA->setErrStatus();
-         return this;
-       }
-
-      if (formatStr_ == "SYYYYMM")
-       formatStr_ = "YYYYMM";
-
-      NAString newStr;
-      if (((formatStr_ == "YYYYMM") ||
-          (formatStr_ == "YYYY-MM")) &&
-         (CmpCommon::getDefault(MODE_SPECIAL_3) == DF_ON) &&
-         (formatCharToDate_) &&
-         (naType0->getTypeQualifier() == NA_NUMERIC_TYPE))
-       {
-         // currently only supports formatting of a numeric constant string 
literal
-         // of the form '200906'. Missing day is filled with value '01' and
-         // a new constant is added as child(0).
-         ConstValue * cv = (ConstValue *)child(0)->castToItemExpr();
-         if ((cv->getOperatorType() != ITM_CONSTANT) ||
-             (NOT cv->canGetExactNumericValue()))
-           {
-             *CmpCommon::diags() << DgSqlCode(-4065) << DgString0(formatStr_)
-                                 << DgString1(formatType_ == FORMAT_GENERIC ? 
"FORMAT" 
-                                              : (formatType_ == FORMAT_TO_CHAR 
? "TO_CHAR" : "TO_DATE"));
-             bindWA->setErrStatus();
-             return this;
-           }
-
-         Lng32 val = (Lng32)cv->getExactNumericValue();
-         char nBuf[40];
-         sprintf(nBuf, "%d", val);
-         newStr = nBuf;
-         
-         ConstValue *newChild = 
-           new (bindWA->wHeap()) ConstValue(newStr, bindWA->wHeap());
-         setChild(0, newChild->bindNode(bindWA));
-         
-         naType0 = &child(0)->getValueId().getType();
-       } // if YYYYMM
-
-      if (naType0->getTypeQualifier() == NA_NUMERIC_TYPE)
-       {
-         if (formatCharToDate_ == FALSE)
-           {
-             *CmpCommon::diags() << DgSqlCode(-4065) << DgString0(formatStr_)
-                                 << DgString1(formatType_ == FORMAT_GENERIC ? 
"FORMAT" 
-                                              : (formatType_ == FORMAT_TO_CHAR 
? "TO_CHAR" : "TO_DATE"));
-             bindWA->setErrStatus();
-             return this;
-           }
-         
-         // convert number to char before formatting.
-         // Length of target char is equal to formatStr_.
-         ItemExpr * newChild =
-           new (bindWA->wHeap())
-           Cast(child(0),
-                new (bindWA->wHeap())
-                SQLChar(formatStr_.length(),
-                        child(0)->castToItemExpr()->
-                        getValueId().getType().supportsSQLnull()));
-         setChild(0, newChild->bindNode(bindWA));
-         naType0 = &child(0)->getValueId().getType();
-       }
-      
-      if ((CmpCommon::getDefault(MODE_SPECIAL_2) == DF_OFF) &&
-         (formatCharToDate_ == FALSE) &&
-         (naType0->getTypeQualifier() != NA_DATETIME_TYPE)) 
-       {
-         // 4071 The operand of a DATEFORMAT function must be a datetime.
-         *CmpCommon::diags() << DgSqlCode(-4071) << DgString0(getTextUpper());
-         return NULL;
-       }
-
-      formatAsDate = TRUE;
-      if ((formatStr_ == "YYYYMMDDHH24MISS") ||
-         (formatStr_ == "YYYYMMDD:HH24:MI:SS") ||
-         (formatStr_ == "DD.MM.YYYY:HH24:MI:SS") ||
-         (formatStr_ == "YYYY-MM-DD HH24:MI:SS") ||
-         (formatStr_ == "MMDDYYYY HH24:MI:SS") ||
-         (formatStr_ == "MM/DD/YYYY HH24:MI:SS") ||
-          (formatStr_ == "DD-MON-YYYY HH:MI:SS"))
-       dateFormat = DateFormat::TIMESTAMP_FORMAT_STR;
-      else if (formatStr_ == "HH24:MI:SS")
-       dateFormat = DateFormat::TIME_FORMAT_STR;
-      else
-       dateFormat = DateFormat::DATE_FORMAT_STR;
-    }
 
-  else if ((formatStr_ == "HH24") ||
-           (formatStr_ == "D") ||
-           (formatStr_ == "MM") ||
-           (formatStr_ == "YYYY"))
+  if ((formatStr_ == "HH24") ||
+      (formatStr_ == "D") ||
+      (formatStr_ == "MM") ||
+      (formatStr_ == "YYYY"))
     {
       if (CmpCommon::getDefault(MODE_SPECIAL_4) == DF_OFF)
         {
@@ -4011,22 +3847,6 @@ ItemExpr * Format::bindNode(BindWA * bindWA)
       
       formatExtract = TRUE;
     }
-
-  else if ((formatStr_ == "99:99:99:99") ||
-          (formatStr_ == "-99:99:99:99"))
-    {
-      if (naType0->getTypeQualifier() == NA_NUMERIC_TYPE)
-       {
-         formatAsDate = TRUE;
-         dateFormat = DateFormat::TIME_FORMAT_STR;
-       }
-      else
-       {
-         *CmpCommon::diags() << DgSqlCode(-4045) << DgString0("FORMAT");
-         bindWA->setErrStatus();
-         return this;
-       }
-    }
   else
     {
       formatX = TRUE;
@@ -4073,88 +3893,7 @@ ItemExpr * Format::bindNode(BindWA * bindWA)
     }
 
   ItemExpr * newIE= NULL;
-  if (formatAsDate)
-    {
-      ConstValue * cv = new(bindWA->wHeap()) SystemLiteral(formatStr_);
-
-      if ((dateFormat == DateFormat::TIME_FORMAT_STR) &&
-         (formatStr_ != "HH24:MI:SS"))
-       {
-         if (naType0->getTypeName() != LiteralLargeInt)
-           {
-             // convert to largeint. We have already verified that
-             // child is exact with scale of 0.
-             ItemExpr * newChild =
-               new (bindWA->wHeap())
-               Cast(child(0),
-                    new (bindWA->wHeap())
-                    SQLLargeInt(TRUE,
-                                child(0)->castToItemExpr()->
-                                getValueId().getType().supportsSQLnull()));
-             setChild(0, newChild->bindNode(bindWA));
-           }
-       }
-
-      ItemExpr * newChild = NULL;
-         
-      if ((CmpCommon::getDefault(MODE_SPECIAL_3) == DF_ON) &&
-         (formatCharToDate_ == FALSE) &&
-         (naType0->getPrecision() == SQLDTCODE_TIMESTAMP))
-       {
-         if (formatStr_ == "HH24:MI:SS")
-           {
-             newChild =
-               new (bindWA->wHeap())
-               Cast(child(0),
-                    new (bindWA->wHeap())
-                    SQLTime(child(0)->castToItemExpr()->
-                            getValueId().getType().supportsSQLnull(),
-                            0));
-           }
-         else if ((formatStr_ == "YYYYMMDDHH24MISS") ||
-                  (formatStr_ == "YYYYMMDD:HH24:MI:SS") ||
-                  (formatStr_ == "DD.MM.YYYY:HH24:MI:SS") ||
-                  (formatStr_ == "YYYY-MM-DD HH24:MI:SS") ||
-                  (formatStr_ == "MMDDYYYY HH24:MI:SS") ||
-                  (formatStr_ == "MM/DD/YYYY HH24:MI:SS") ||
-                   (formatStr_ == "DD-MON-YYYY HH:MI:SS"))
-           {
-             // do nothing
-           }
-         else 
-           {
-             newChild =
-               new (bindWA->wHeap())
-               Cast(child(0),
-                    new (bindWA->wHeap())
-                    SQLDate(child(0)->castToItemExpr()->
-                            getValueId().getType().supportsSQLnull()));
-           }
-           
-         if (newChild)
-           setChild(0, newChild->bindNode(bindWA));
-       }
-
-      naType0 = &child(0)->getValueId().getType();
-      if (DFS2REC::isAnyVarChar(naType0->getFSDatatype()))
-       {
-         // convert to fixed char.
-         newChild =
-           new (bindWA->wHeap())
-           Cast(child(0),
-                new (bindWA->wHeap())
-                SQLChar(naType0->getNominalSize(),
-                        naType0->supportsSQLnull()));
-         setChild(0, newChild->bindNode(bindWA));
-       }
-
-      newIE=
-       new (bindWA->wHeap()) DateFormat(child(0), cv, dateFormat);
-      newIE = newIE->bindNode(bindWA);
-      if (bindWA->errStatus())
-       return NULL;
-    }
-  else if ((formatX) || (format9) || (formatExtract))
+  if ((formatX) || (format9) || (formatExtract))
     {
       Parser parser(bindWA->currentCmpContext());
       char buf[200];
@@ -4240,21 +3979,277 @@ ItemExpr * Format::bindNode(BindWA * bindWA)
   else
     {
       if (CmpCommon::getDefault(MODE_SPECIAL_1) == DF_OFF)
-      {
-        *CmpCommon::diags() << DgSqlCode(-4065) << DgString0(formatStr_)
-                         << DgString1(formatType_ == FORMAT_GENERIC ? "FORMAT" 
-                                      : (formatType_ == FORMAT_TO_CHAR ? 
"TO_CHAR" : "TO_DATE"));
-        bindWA->setErrStatus();
-        return this;
-      }
-
+        {
+          *CmpCommon::diags() << DgSqlCode(-4065) << DgString0(formatStr_)
+                              << DgString1(formatType_ == FORMAT_GENERIC ? 
"FORMAT" 
+                                           : (formatType_ == FORMAT_TO_CHAR ? 
"TO_CHAR" : "TO_DATE"));
+          bindWA->setErrStatus();
+          return this;
+        }
+      
       // In mode_special_1, ignore this format and return the child pointer.
       newIE = child(0);
     }
-
+  
   return newIE;
 }
 
+///////////////////////////////////////////////////////
+// various error checks, details below.
+//////////////////////////////////////////////////////
+NABoolean DateFormat::errorChecks(Lng32 frmt, BindWA *bindWA, 
+                                  const NAType* opType)
+{
+  Lng32 error = 0;
+
+  NABoolean tc  = (formatType_ == FORMAT_TO_CHAR);
+  NABoolean td  = (formatType_ == FORMAT_TO_DATE);
+  NABoolean df  = ExpDatetime::isDateFormat(frmt);
+  NABoolean tf  = ExpDatetime::isTimeFormat(frmt);
+  NABoolean tsf = ExpDatetime::isTimestampFormat(frmt);
+  NABoolean nf  = ExpDatetime::isNumericFormat(frmt);
+  NABoolean ms4 = (CmpCommon::getDefault(MODE_SPECIAL_4) == DF_ON);
+  
+  if (NOT (df || tf || tsf || nf))
+    {
+      // format must be date, time, timestamp or numeric
+      error = 1; // error 4065
+    }
+  else if ((NOT ms4) && nf)
+    {
+      // format can only be numeric in mode_special_4
+      error = 1; // error 4065
+    }
+
+  if (!error && tc)
+    {
+      // source must be datetime with to_char function
+      if (opType->getTypeQualifier() != NA_DATETIME_TYPE)
+        error = 2; // error 4071
+
+      // cannot convert date source to time format
+      else if (tf && (opType->getPrecision() == SQLDTCODE_DATE))
+        error = 3; // error 4072
+    }
+
+  if (!error && td)
+    {
+      // source must be char or numeric with to_date
+      if ((opType->getTypeQualifier() != NA_CHARACTER_TYPE) &&
+          (opType->getTypeQualifier() != NA_NUMERIC_TYPE))
+        error = 4; //error 4043
+
+      // source can only be numeric in mode_special_4
+      else if ((NOT ms4) && (opType->getTypeQualifier() != NA_CHARACTER_TYPE))
+        error = 4; // error 4043
+
+      // operand must be numeric with nf (numeric format)
+      else if (ms4 && nf && (opType->getTypeQualifier() != NA_NUMERIC_TYPE))
+        {
+          error = 7; // error 4045
+        }
+
+      // numeric must be exact with scale of 0
+      else if (ms4 && (opType->getTypeQualifier() == NA_NUMERIC_TYPE))
+        {
+          if (NOT ((NumericType*)opType)->isExact())
+            error = 5; // error 4046
+          else if (NOT ((NumericType*)opType)->getScale() == 0)
+            error = 6; // error 4047
+        }
+    }
+
+  if (error)
+    {
+      switch (error)
+        {
+        case 1: 
+          {
+            *CmpCommon::diags() << DgSqlCode(-4065) << DgString0(formatStr_)
+                                << DgString1((formatType_ == FORMAT_TO_CHAR
+                                              ? "TO_CHAR" : "TO_DATE"));
+            bindWA->setErrStatus();
+          }
+          break;
+
+        case 2:
+          {
+            *CmpCommon::diags() << DgSqlCode(-4071) << DgString0("TO_CHAR");
+            bindWA->setErrStatus();
+          }
+          break;
+
+        case 3:
+          {
+            *CmpCommon::diags() << DgSqlCode(-4072) << DgString0("TO_CHAR") << 
DgString1("time");;
+            bindWA->setErrStatus();
+          }
+          break;
+
+        case 4:
+          {
+            *CmpCommon::diags() << DgSqlCode(-4043) << DgString0("TO_DATE");
+            bindWA->setErrStatus();
+          }
+          break;
+          
+        case 5:
+          {
+            *CmpCommon::diags() << DgSqlCode(-4046) << DgString0("TO_DATE");
+            bindWA->setErrStatus();
+          }
+          break;
+          
+        case 6:
+          {
+            *CmpCommon::diags() << DgSqlCode(-4047) << DgString0("TO_DATE");
+            bindWA->setErrStatus();
+          }
+          break;
+
+        case 7:
+          {
+            *CmpCommon::diags() << DgSqlCode(-4045) << DgString0("TO_DATE");
+            bindWA->setErrStatus();
+          }
+          break;
+
+        } // switch
+
+      return TRUE;
+    }
+  
+  return FALSE;
+}
+
+// used for TO_DATE, TO_CHAR, TO_TIME, DATEFORMAT functions.
+DateFormat::DateFormat(ItemExpr *val1Ptr, const NAString &formatStr,
+                       Lng32 formatType, NABoolean wasDateformat)
+     : CacheableBuiltinFunction(ITM_DATEFORMAT,
+                                1, val1Ptr),
+       formatStr_(formatStr),
+       wasDateformat_(wasDateformat),
+       formatType_(formatType),
+       frmt_(-1),
+       dateFormat_(DATE_FORMAT_NONE)
+{ 
+  allowsSQLnullArg() = FALSE; 
+
+  if (formatStr_ == "SYYYYMM")
+    formatStr_ = "YYYYMM";
+  else if (formatStr_ == "HH:MI:SS")
+    formatStr_ = "HH24:MI:SS";
+
+  frmt_ = ExpDatetime::getDatetimeFormat(formatStr_.data());
+}
+
+ItemExpr * DateFormat::bindNode(BindWA * bindWA)
+{
+  if (checkForSQLnullChild(bindWA, this, allowsSQLnullArg(), FUNCTION_))
+    return this;
+
+  bindChildren(bindWA);
+  if (bindWA->errStatus()) 
+    return this;
+
+  const NAType *naType0 = &child(0)->getValueId().getType();
+  const NumericType * nType0 = NULL;
+
+  // a quick optimization for the date format.
+  ItemExpr *newNode = quickDateFormatOpt(bindWA);
+  if (newNode)
+    return newNode;
+
+  if (errorChecks(frmt_, bindWA, naType0))
+    {
+      return this;
+    }
+
+  dateFormat_ = DateFormat::DATE_FORMAT_NONE;
+
+  if (ExpDatetime::isDateTimeFormat(frmt_))
+    {
+      if (ExpDatetime::isTimestampFormat(frmt_))
+        dateFormat_ = DateFormat::TIMESTAMP_FORMAT_STR;
+      else if (ExpDatetime::isTimeFormat(frmt_))
+        dateFormat_ = DateFormat::TIME_FORMAT_STR;
+      else
+        dateFormat_ = DateFormat::DATE_FORMAT_STR;
+
+      if (naType0->getTypeQualifier() == NA_NUMERIC_TYPE)
+        {
+          // convert number to char before formatting.
+          // Length of target char is equal to formatStr_.
+          ItemExpr * newChild =
+            new (bindWA->wHeap())
+            Cast(child(0),
+                 new (bindWA->wHeap())
+                 SQLChar(formatStr_.length(),
+                         child(0)->castToItemExpr()->
+                         getValueId().getType().supportsSQLnull()));
+          setChild(0, newChild->bindNode(bindWA));
+          naType0 = &child(0)->getValueId().getType();
+        }
+    }
+  else if (ExpDatetime::isNumericFormat(frmt_))
+    {
+      dateFormat_ = DateFormat::TIME_FORMAT_STR;
+
+      if (naType0->getTypeName() != LiteralLargeInt)
+        {
+          // convert to largeint. We have already verified that
+          // child is exact with scale of 0.
+          ItemExpr * newChild =
+            new (bindWA->wHeap())
+            Cast(child(0),
+                 new (bindWA->wHeap())
+                 SQLLargeInt(TRUE,
+                             child(0)->castToItemExpr()->
+                             getValueId().getType().supportsSQLnull()));
+          setChild(0, newChild->bindNode(bindWA));
+        }
+    }
+  else
+    {
+      CMPASSERT(FALSE); // should not reach here
+    }
+
+  // if source is a timestamp and target is date or time, extract
+  // date or time part from source before formatting.
+  ItemExpr * newChild = NULL;
+  if (naType0->getPrecision() == SQLDTCODE_TIMESTAMP)
+    {
+      if (ExpDatetime::isTimeFormat(frmt_))
+        {
+          newChild =
+            new (bindWA->wHeap())
+            Cast(child(0),
+                 new (bindWA->wHeap())
+                 SQLTime(child(0)->castToItemExpr()->
+                         getValueId().getType().supportsSQLnull(),
+                         0));
+        }
+      else if (ExpDatetime::isDateFormat(frmt_))
+        {
+          newChild =
+            new (bindWA->wHeap())
+            Cast(child(0),
+                 new (bindWA->wHeap())
+                 SQLDate(child(0)->castToItemExpr()->
+                         getValueId().getType().supportsSQLnull()));
+        }
+      
+      if (newChild)
+        setChild(0, newChild->bindNode(bindWA));
+    }
+
+  BuiltinFunction::bindNode(bindWA);
+  if (bindWA->errStatus()) 
+    return this;
+
+  return getValueId().getItemExpr();  
+}
+
 ItemExpr *Trim::bindNode(BindWA *bindWA)
 {
   if (nodeIsBound())
@@ -11829,27 +11824,6 @@ ItemExpr *ZZZBinderFunction::bindNode(BindWA *bindWA)
       }
     
     break;
-    case ITM_DATEFMT:
-      {
-    Lng32 datefmt;
-       ItemExpr *secondOpExpr = child(1)->castToItemExpr(); 
-       secondOpExpr->bindNode(bindWA);
-       if (bindWA->errStatus()) 
-             return this;
-           
-       datefmt = (Lng32)((ConstValue*)secondOpExpr)->getExactNumericValue();
-
-       strcpy(buf, "TRANSLATE(DATEFMT_INTN");
-        if (datefmt == DateFormat::USA)
-         strcat(buf, "(@A1,USA)");
-
-        else if (datefmt == DateFormat::EUROPEAN)
-         strcat(buf, "(@A1,EUROPEAN)");
-        else
-         strcat(buf, "(@A1,DEFAULT)");
-       strcat(buf, " USING ISO88591ToUCS2);");
-      }
-    break;
     case ITM_CURRNT_USER:
       {
        strcpy(buf, "TRANSLATE(CURRNT_USR_INTN USING ISO88591ToUCS2);");

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/optimizer/BindRI.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindRI.cpp b/core/sql/optimizer/BindRI.cpp
index 4792460..1b3d138 100644
--- a/core/sql/optimizer/BindRI.cpp
+++ b/core/sql/optimizer/BindRI.cpp
@@ -408,6 +408,43 @@ void RefConstraint::getMatchOptionPredicateText(NAString 
&text,
   text += ")";
 }
 
+//helper function to check if the given column name is reserved hidden coloum
+//NOTE:
+//  this function hardcode the special name string for SALT, DIVSION columns
+//  if the naming convension of SALT/DIVISION column is changed,
+//  this function MUST be changed as well
+static NABoolean isHiddenColumn(const char *colname)
+{
+  int len = strlen(colname);
+  if(strcmp(colname , "_SALT_") ==0) 
+    return TRUE;
+  //check for DIVISION column
+  //pattern _DIVISION_%d_
+  //must longer than 12
+  if(len >= 12) {
+    //must end with _
+    if(colname[len-1] == '_')
+    {
+      //if begin with _DIVISION_?
+      if(strncmp(colname,"_DIVISION_",10) == 0) 
+      {
+        //middle part are number
+        int allDigit = 1;
+        for(int i = 0; i< len-11; i++)
+        {
+          if(isdigit(colname[i+10]) == 0)
+          {
+            allDigit = 0;
+            break; //not digit
+          }
+        } 
+        if(allDigit == 1)
+          return TRUE; 
+      }
+    }
+  }
+  return FALSE;
+}
 
 // Writes a row-value-constructor consisting of fully qualified column names
 // in Ansi (external) format
@@ -417,12 +454,18 @@ void RefConstraint::getPredicateText(NAString &text,
                                     NAString *corrName) const
 {
   NAString tblText = ( (corrName == NULL) ? 
tblName.getQualifiedNameAsAnsiString() : *corrName);
+  int pos= 0;
   text += "(";
   for (CollIndex i = 0; i < keyColumns.entries(); i++)
     {
-      if (i)
+      if(isHiddenColumn(keyColumns[i]->getColName()) )
+        continue;
+      if (pos > 0)
+      {
         text += ",";
+      }
       text += tblText + "." + ToAnsiIdentifier(keyColumns[i]->getColName());
+      pos++; //move the pos
     }
   text += ")";
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/optimizer/BindRelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindRelExpr.cpp 
b/core/sql/optimizer/BindRelExpr.cpp
index ab347a7..cbb460e 100644
--- a/core/sql/optimizer/BindRelExpr.cpp
+++ b/core/sql/optimizer/BindRelExpr.cpp
@@ -9888,7 +9888,7 @@ RelExpr *Insert::bindNode(BindWA *bindWA)
                    (nacol->getDefaultClass() == 
COM_IDENTITY_GENERATED_BY_DEFAULT)) {
             setSystemGeneratesIdentityValue(TRUE);
           }
-          else 
+          else if (nacol->getDefaultClass() != COM_NO_DEFAULT)
             omittedDefaultCols = TRUE;
 
           // Bind the default value, make an Assign, etc, as above
@@ -10112,15 +10112,8 @@ RelExpr *Insert::bindNode(BindWA *bindWA)
          *CmpCommon::diags() << DgSqlCode(-4490);
     }
   }
-  if (isUpsert() && (!getIsTrafLoadPrep()) && 
-        (((!isAlignedRowFormat) && omittedCurrentDefaultClassCols) || 
-             (isAlignedRowFormat && omittedDefaultCols)) 
-              && 
(CmpCommon::getDefault(TRAF_UPSERT_WITH_INSERT_DEFAULT_SEMANTICS) == DF_OFF)) {
-    boundExpr = xformUpsertToMerge(bindWA);
-    return boundExpr;
-  }
-  else 
-  if (isUpsertThatNeedsMerge()) {
+
+  if (isUpsertThatNeedsMerge(isAlignedRowFormat, omittedDefaultCols, 
omittedCurrentDefaultClassCols)) {
     boundExpr = xformUpsertToMerge(bindWA);
     return boundExpr;
   }
@@ -10171,17 +10164,26 @@ matched clause of merge). If the upsert caused a row 
to be updated in the
 base table then the old version of the row will have to be deleted from 
 indexes, and a new version inserted. Upsert is being transformed to merge
 so that we can delete the old version of an updated row from the index.
+
+Upsert is also converted into merge when there are omitted cols with default 
values and 
+TRAF_UPSERT_WITH_INSERT_DEFAULT_SEMANTICS is set to  OFF in case of aligned 
format table or 
+omitted current timestamp cols in case of non-aligned row format
 */
-NABoolean Insert::isUpsertThatNeedsMerge() const
+NABoolean Insert::isUpsertThatNeedsMerge(NABoolean isAlignedRowFormat, 
NABoolean omittedDefaultCols,
+                                   NABoolean omittedCurrentDefaultClassCols) 
const
 {
-  if (!isUpsert() || getIsTrafLoadPrep() || 
-      (getTableDesc()->isIdentityColumnGeneratedAlways() && 
-       getTableDesc()->hasIdentityColumnInClusteringKey()) ||
-      getTableDesc()->getClusteringIndex()->getNAFileSet()->hasSyskey() || 
-      !(getTableDesc()->hasSecondaryIndexes()))
-    return FALSE;
-
-  return TRUE;
+  if (isUpsert() && 
+      (NOT getIsTrafLoadPrep()) && 
+      (NOT (getTableDesc()->isIdentityColumnGeneratedAlways() && 
getTableDesc()->hasIdentityColumnInClusteringKey())) && 
+      (NOT 
(getTableDesc()->getClusteringIndex()->getNAFileSet()->hasSyskey())) && 
+       ((getTableDesc()->hasSecondaryIndexes()) ||
+         (( NOT isAlignedRowFormat) && omittedCurrentDefaultClassCols) ||
+             ((isAlignedRowFormat && omittedDefaultCols
+              && 
(CmpCommon::getDefault(TRAF_UPSERT_WITH_INSERT_DEFAULT_SEMANTICS) == DF_OFF)))
+       ))
+     return TRUE;
+  else
+     return FALSE;
 }
 
 RelExpr* Insert::xformUpsertToMerge(BindWA *bindWA) 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/optimizer/ItemCache.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemCache.cpp b/core/sql/optimizer/ItemCache.cpp
index 9bdd830..703f9f8 100644
--- a/core/sql/optimizer/ItemCache.cpp
+++ b/core/sql/optimizer/ItemCache.cpp
@@ -714,7 +714,10 @@ void DateFormat::generateCacheKey(CacheWA& cwa) const
 {
   BuiltinFunction::generateCacheKey(cwa); 
   cwa += " fmt:";
-  char dFmt[20]; str_itoa(dateFormat_, dFmt); 
+  char dFmt[20]; 
+  str_itoa(dateFormat_, dFmt); 
+  cwa += dFmt;
+  str_itoa(frmt_, dFmt);
   cwa += dFmt;
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/optimizer/ItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemExpr.cpp b/core/sql/optimizer/ItemExpr.cpp
index d68768e..a76ddb4 100644
--- a/core/sql/optimizer/ItemExpr.cpp
+++ b/core/sql/optimizer/ItemExpr.cpp
@@ -49,7 +49,7 @@
 #include "exp_function.h" // for calling ExHDPHash::hash(data, len)
 #include "ItemFuncUDF.h"
 #include "CmpStatement.h"
-//#include "ItmFlowControlFunction.h"
+#include "exp_datetime.h"
 
 #include "OptRange.h"
 
@@ -8241,12 +8241,16 @@ DateFormat::~DateFormat() {}
 ItemExpr * DateFormat::copyTopNode(ItemExpr *derivedNode,
                                   CollHeap* outHeap)
 {
-  ItemExpr *result;
+  DateFormat *result;
 
   if (derivedNode == NULL)
-    result = new (outHeap) DateFormat(child(0), child(1), getDateFormat());
+    result = new (outHeap) DateFormat(child(0), 
+                                      formatStr_, formatType_, 
+                                      wasDateformat_);
   else
-    result = derivedNode;
+    result = (DateFormat*)derivedNode;
+
+  frmt_ = result->frmt_;
 
   return BuiltinFunction::copyTopNode(result,outHeap);
 
@@ -8265,6 +8269,46 @@ NABoolean DateFormat::hasEquivalentProperties(ItemExpr * 
other)
   return 
       (this->dateFormat_ == df->dateFormat_);
 }
+
+void DateFormat::unparse(NAString &result,
+                     PhaseEnum phase,
+                      UnparseFormatEnum form,
+                     TableDesc * tabId) const
+{
+  if (wasDateformat_)
+    result += "DATEFORMAT(";
+  else if (formatType_ == FORMAT_TO_DATE)
+    result += "TO_DATE(";
+  else if (formatType_ == FORMAT_TO_CHAR)
+    result += "TO_CHAR(";
+  else
+    result += "unknown(";
+
+  child(0)->unparse(result, phase, form, tabId);
+
+  result += ", ";
+
+  if (wasDateformat_)
+    {
+      if (frmt_ == ExpDatetime::DATETIME_FORMAT_DEFAULT)
+        result += "DEFAULT";
+      else if (frmt_ == ExpDatetime::DATETIME_FORMAT_USA)
+        result += "USA";
+      else if (frmt_ == ExpDatetime::DATETIME_FORMAT_EUROPEAN)
+        result += "EUROPEAN";
+      else
+        result += "unknown";
+    }
+  else
+    {
+      result += "'";
+      result += formatStr_;
+      result += "'";
+    }
+
+  result += ")";  
+}
+
 // -----------------------------------------------------------------------
 // member functions for class DayOfWeek
 // -----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/optimizer/ItemFunc.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemFunc.h b/core/sql/optimizer/ItemFunc.h
index d794a3d..0728521 100644
--- a/core/sql/optimizer/ItemFunc.h
+++ b/core/sql/optimizer/ItemFunc.h
@@ -1703,22 +1703,23 @@ public:
 class DateFormat : public CacheableBuiltinFunction
 {
 public:
+  enum FormatType
+  {
+    FORMAT_GENERIC = 0,
+    FORMAT_TO_DATE,
+    FORMAT_TO_CHAR
+  };
+
   enum 
   { 
-    DEFAULT,  // YYYY-MM-DD
-    USA,      // MM/DD/YYYY AM|PM
-    EUROPEAN, // DD.MM.YYYY
-    DATE_FORMAT_STR, // formatStr_ contains date format    
-    TIME_FORMAT_STR, // formatStr_ contains time format
-    TIMESTAMP_FORMAT_STR  // formatStr_ contains time format
+    DATE_FORMAT_NONE = 0,
+    DATE_FORMAT_STR,       // formatStr_ contains date format    
+    TIME_FORMAT_STR,       // formatStr_ contains time format
+    TIMESTAMP_FORMAT_STR   // formatStr_ contains timestamp format
   };
 
-  DateFormat(ItemExpr *val1Ptr, ItemExpr *formatStrPtr,
-            Int32 dateFormat)
-       : CacheableBuiltinFunction(ITM_DATEFORMAT,
-                         2, val1Ptr, formatStrPtr),
-         dateFormat_(dateFormat)
-       { allowsSQLnullArg() = FALSE; }
+  DateFormat(ItemExpr *val1Ptr, const NAString &formatStr,
+             Lng32 formatType, NABoolean wasDateformat = FALSE);
 
   // virtual destructor
   virtual ~DateFormat();
@@ -1726,6 +1727,8 @@ public:
   // accessor functions
   Int32 getDateFormat() const { return dateFormat_; }
 
+  Int32 getExpDatetimeFormat() const { return frmt_; }
+
   // do not change format literals of DateFormat into constant parameters
   virtual ItemExpr* normalizeForCache(CacheWA& cwa, BindWA& bindWA)
     { return this; } 
@@ -1733,6 +1736,12 @@ public:
   // append an ascii-version of ItemExpr into cachewa.qryText_
   virtual void generateCacheKey(CacheWA& cwa) const;
 
+  NABoolean errorChecks(Lng32 frmt, BindWA *bindWA, const NAType* opType);
+
+  ItemExpr * quickDateFormatOpt(BindWA * bindWA);
+
+  ItemExpr * bindNode(BindWA * bindWA);
+
   // a virtual function for type propagating the node
   virtual const NAType * synthesizeType();
 
@@ -1742,7 +1751,11 @@ public:
   virtual ItemExpr * copyTopNode(ItemExpr *derivedNode = NULL,
                                 CollHeap* outHeap = 0);
   
-  
+  void unparse(NAString &result,
+               PhaseEnum phase,
+               UnparseFormatEnum form,
+               TableDesc * tabId) const;
+    
   virtual NABoolean hasEquivalentProperties(ItemExpr * other);
 
   virtual QR::ExprElement getQRExprElem() const
@@ -1751,8 +1764,20 @@ public:
   }
 
 private:
+  // string contains user specified format string
+  NAString formatStr_;
+
+  // TO_DATE or TO_CHAR
+  Lng32 formatType_;
 
+  // DATE, TIME or TIMESTAMP
   Int32 dateFormat_;
+
+  // original function was DATEFORMAT
+  NABoolean wasDateformat_; 
+
+  // actual datetime format (defined in class ExpDatetime in exp_datetime.h)
+  Lng32 frmt_;
 }; // class DateFormat
 
 class DayOfWeek : public CacheableBuiltinFunction
@@ -2664,6 +2689,8 @@ public:
   virtual ItemExpr * copyTopNode(ItemExpr *derivedNode = NULL,
                                 CollHeap* outHeap = 0);
 
+  ItemExpr * quickDateFormatOpt(BindWA * bindWA);
+
   const NAString& getFormatStr() const
   {
     return formatStr_;
@@ -2709,8 +2736,12 @@ public:
    lobNum_(-1),
    lobStorageType_(Lob_Invalid_Storage),
    lobMaxSize_(CmpCommon::getDefaultNumeric(LOB_MAX_SIZE)),
-   lobMaxChunkMemSize_(CmpCommon::getDefaultNumeric(LOB_MAX_CHUNK_MEM_SIZE))
-   {}
+     lobMaxChunkMemSize_(CmpCommon::getDefaultNumeric(LOB_MAX_CHUNK_MEM_SIZE)),
+     lobGCLimit_(CmpCommon::getDefaultNumeric(LOB_GC_LIMIT_SIZE)),
+     hdfsPort_((Lng32)CmpCommon::getDefaultNumeric(LOB_HDFS_PORT)),
+     hdfsServer_( CmpCommon::getDefaultString(LOB_HDFS_SERVER))
+   {
+   }
 
  // copyTopNode method
   virtual ItemExpr * copyTopNode(ItemExpr *derivedNode = NULL,
@@ -2737,8 +2768,10 @@ public:
   LobsStorage &lobStorageType() { return lobStorageType_; }
   NAString &lobStorageLocation() { return lobStorageLocation_; }
   Int64 getLobMaxSize() {return lobMaxSize_*1024*1024; }
-  Int64 getLobMaxChunkMemSize() { return lobMaxChunkMemSize_;}
-  
+  Int64 getLobMaxChunkMemSize() { return lobMaxChunkMemSize_*1024*1024;}
+  Int64 getLobGCLimit() { return lobGCLimit_*1025*1024;}
+  Int32 getLobHdfsPort() { return hdfsPort_;}
+  NAString &getLobHdfsServer(){return hdfsServer_;}
  protected:
   ObjectType obj_;
 
@@ -2747,6 +2780,9 @@ public:
   NAString lobStorageLocation_;
   Int32 lobMaxSize_; // In MB units
   Int32 lobMaxChunkMemSize_; //In MB Units
+  Int32 lobGCLimit_ ;//In MB Units
+  Int32 hdfsPort_;
+  NAString hdfsServer_;
   
 }; // LOBoper
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/optimizer/NAFileSet.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NAFileSet.cpp b/core/sql/optimizer/NAFileSet.cpp
index 83d34a8..ea6b840 100644
--- a/core/sql/optimizer/NAFileSet.cpp
+++ b/core/sql/optimizer/NAFileSet.cpp
@@ -75,6 +75,7 @@ NAFileSet::NAFileSet(const QualifiedName & fileSetName,
                      Lng32 fileCode,
                     NABoolean isVolatile,
                     NABoolean inMemObjectDefn,
+                     Int64 indexUID,
                      desc_struct *keysDesc,
                      HHDFSTableStats *hHDFSTableStats,
                      Lng32 numSaltPartns,
@@ -113,6 +114,7 @@ NAFileSet::NAFileSet(const QualifiedName & fileSetName,
            thisRemoteIndexGone_(FALSE),
            isDecoupledRangePartitioned_(isDecoupledRangePartitioned),
            fileCode_(fileCode),
+           indexUID_(indexUID),
            keysDesc_(keysDesc),
            hHDFSTableStats_(hHDFSTableStats),
            numSaltPartns_(numSaltPartns),

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/optimizer/NAFileSet.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NAFileSet.h b/core/sql/optimizer/NAFileSet.h
index 04b4c0e..f8ca7ed 100644
--- a/core/sql/optimizer/NAFileSet.h
+++ b/core/sql/optimizer/NAFileSet.h
@@ -115,6 +115,7 @@ public:
             Lng32 fileCode,
            NABoolean isVolatile,
            NABoolean inMemObjectDefn,
+            Int64 indexUID,
             desc_struct *keysDesc,
             HHDFSTableStats *hHDFSTableStats,
             Lng32 numSaltPartns,
@@ -170,6 +171,9 @@ public:
 
   Lng32 getFileCode() const { return fileCode_; }
 
+  const Int64 &getIndexUID() const { return indexUID_; }
+  Int64 &getIndexUID() { return indexUID_; }
+
   const HHDFSTableStats *getHHDFSTableStats() const { return hHDFSTableStats_; 
}
   HHDFSTableStats *getHHDFSTableStats()             { return hHDFSTableStats_; 
}
 
@@ -382,6 +386,9 @@ private:
   // ---------------------------------------------------------------------
   NAColumnArray indexKeyColumns_;
 
+  // uid for index
+  Int64 indexUID_;
+
   desc_struct *keysDesc_;  // needed for parallel label operations.
 
   // ---------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/optimizer/NATable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NATable.cpp b/core/sql/optimizer/NATable.cpp
index ef095ce..c01998c 100644
--- a/core/sql/optimizer/NATable.cpp
+++ b/core/sql/optimizer/NATable.cpp
@@ -4300,6 +4300,7 @@ NABoolean createNAFileSets(desc_struct * table_desc       
/*IN*/,
                   files_desc ? files_desc->body.files_desc.fileCode : 0,
                  (indexes_desc->body.indexes_desc.isVolatile != 0),
                  (indexes_desc->body.indexes_desc.isInMemoryObjectDefn != 0),
+                  indexes_desc->body.indexes_desc.indexUID,
                   indexes_desc->body.indexes_desc.keys_desc,
                   NULL, // no Hive stats
                   indexes_desc->body.indexes_desc.numSaltPartns,
@@ -4635,6 +4636,7 @@ NABoolean createNAFileSets(hive_tbl_desc* hvt_desc        
/*IN*/,
                   0, // file code
                  0, // not a volatile
                  0, // inMemObjectDefn
+                  0,
                   NULL, // indexes_desc->body.indexes_desc.keys_desc,
                   hiveHDFSTableStats,
                   0, // saltPartns
@@ -5516,7 +5518,8 @@ NATable::NATable(BindWA *bindWA,
 
   if(postCreateNATableWarnings != preCreateNATableWarnings)
     tableConstructionHadWarnings_=TRUE;
-
+  const char *lobHdfsServer = CmpCommon::getDefaultString(LOB_HDFS_SERVER);
+  Int32 lobHdfsPort = (Lng32)CmpCommon::getDefaultNumeric(LOB_HDFS_PORT);
   if (hasLobColumn())
     {
       // read lob related information from lob metadata
@@ -5556,7 +5559,7 @@ NATable::NATable(BindWA *bindWA,
         LOB_CLI_SELECT_CURSOR,
         lobNumList,
         lobTypList,
-        lobLocList,0);
+        lobLocList,(char *)lobHdfsServer,lobHdfsPort,0);
       
       if (cliRC == 0)
        {
@@ -7537,12 +7540,30 @@ ExtendedQualName::SpecialTableType 
NATable::getTableType()
   return qualifiedName_.getSpecialType();
 }
 
-NABoolean NATable::hasSaltedColumn()
+NABoolean NATable::hasSaltedColumn(Lng32 * saltColPos)
 {
   for (CollIndex i=0; i<colArray_.entries(); i++ )
   {
     if ( colArray_[i]->isSaltColumn() ) 
-      return TRUE;
+      {
+        if (saltColPos)
+          *saltColPos = i;
+        return TRUE;
+      }
+  }
+  return FALSE;
+}
+
+NABoolean NATable::hasDivisioningColumn(Lng32 * divColPos)
+{
+  for (CollIndex i=0; i<colArray_.entries(); i++ )
+  {
+    if ( colArray_[i]->isDivisioningColumn() ) 
+      {
+        if (divColPos)
+          *divColPos = i;
+        return TRUE;
+      }
   }
   return FALSE;
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/optimizer/NATable.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NATable.h b/core/sql/optimizer/NATable.h
index 3f58406..e496242 100644
--- a/core/sql/optimizer/NATable.h
+++ b/core/sql/optimizer/NATable.h
@@ -561,7 +561,8 @@ public:
 
   const char *getViewCheck() const              { return viewCheck_; }
 
-  NABoolean hasSaltedColumn();
+  NABoolean hasSaltedColumn(Lng32 * saltColPos = NULL);
+  NABoolean hasDivisioningColumn(Lng32 * divColPos = NULL);
 
   void setUpdatable( NABoolean value )
   {  value ? flags_ |= IS_UPDATABLE : flags_ &= ~IS_UPDATABLE; }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/optimizer/QRDescGenerator.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/QRDescGenerator.cpp 
b/core/sql/optimizer/QRDescGenerator.cpp
index 2a412a3..f8bb9f6 100644
--- a/core/sql/optimizer/QRDescGenerator.cpp
+++ b/core/sql/optimizer/QRDescGenerator.cpp
@@ -543,22 +543,11 @@ static void addFunctionParameters(ItemExpr* ie,
 
       case ITM_DATEFORMAT:
         {
-          // Only include the parameter if it is one of the predefined values
-          // DEFAULT, USA, or EUROPEAN. The other possible values indicate that
-          // a format string is used to determine the format, and this takes
-          // the form of an explicit operand in the ItemExpr tree.
           DateFormat* dateFormatFn = static_cast<DateFormat*>(ie);
-          Int32 dateFormat = dateFormatFn->getDateFormat();
-          if (dateFormat == DateFormat::DEFAULT ||
-              dateFormat == DateFormat::USA     ||
-              dateFormat == DateFormat::EUROPEAN)
-            {
-              param->setName("dateFormat");
-              param->setValue(dateFormat);
-              function->addHiddenParam(param);
-            }
-          else
-            deletePtr(param);
+          Int32 dateFormat = dateFormatFn->getExpDatetimeFormat();
+          param->setName("dateFormat");
+          param->setValue(dateFormat);
+          function->addHiddenParam(param);
         }
         break;
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/optimizer/RelExeUtil.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelExeUtil.cpp 
b/core/sql/optimizer/RelExeUtil.cpp
index e3401b5..e1b28ca 100644
--- a/core/sql/optimizer/RelExeUtil.cpp
+++ b/core/sql/optimizer/RelExeUtil.cpp
@@ -3794,6 +3794,7 @@ RelExpr * DDLExpr::bindNode(BindWA *bindWA)
   NABoolean alterRenameTable = FALSE;
   NABoolean alterIdentityCol = FALSE;
   NABoolean alterColDatatype = FALSE;
+  NABoolean alterColRename = FALSE;
   NABoolean externalTable = FALSE;
   
   returnStatus_ = FALSE;
@@ -3819,6 +3820,11 @@ RelExpr * DDLExpr::bindNode(BindWA *bindWA)
     isHbase_ = TRUE;
     hbaseDDLNoUserXn_ = TRUE;
   }
+  else if (createLibmgr() || dropLibmgr() || upgradeLibmgr())
+    {
+      isHbase_ = TRUE;
+      hbaseDDLNoUserXn_ = TRUE;
+    }
   else if (createRepos() || dropRepos() || upgradeRepos())
     {
       isHbase_ = TRUE;
@@ -4012,7 +4018,9 @@ RelExpr * DDLExpr::bindNode(BindWA *bindWA)
          alterIdentityCol = TRUE;
       else if 
(getExprNode()->castToStmtDDLNode()->castToStmtDDLAlterTableAlterColumnDatatype())
          alterColDatatype = TRUE;
-      else if 
(getExprNode()->castToStmtDDLNode()->castToStmtDDLAlterTableHBaseOptions())
+       else if 
(getExprNode()->castToStmtDDLNode()->castToStmtDDLAlterTableAlterColumnRename())
+         alterColRename = TRUE;
+       else if 
(getExprNode()->castToStmtDDLNode()->castToStmtDDLAlterTableHBaseOptions())
          alterHBaseOptions = TRUE;
        else
         otherAlters = TRUE;
@@ -4210,7 +4218,7 @@ RelExpr * DDLExpr::bindNode(BindWA *bindWA)
          (isCreate_ || isDrop_ || purgedataHbase_ ||
           (isAlter_ && (alterAddCol || alterDropCol || alterDisableIndex || 
alterEnableIndex || 
                        alterAddConstr || alterDropConstr || alterRenameTable ||
-                        alterIdentityCol || alterColDatatype ||
+                        alterIdentityCol || alterColDatatype || alterColRename 
||
                         alterHBaseOptions || otherAlters)))))
       {
        if (NOT isNative_)

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/optimizer/RelExeUtil.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelExeUtil.h b/core/sql/optimizer/RelExeUtil.h
index 21a771e..a2ab73d 100644
--- a/core/sql/optimizer/RelExeUtil.h
+++ b/core/sql/optimizer/RelExeUtil.h
@@ -405,6 +405,18 @@ public:
   {(v ? flags_ |= GET_MD_VERSION : flags_ &= ~GET_MD_VERSION); }
   NABoolean getMDVersion() { return (flags_ & GET_MD_VERSION) != 0;}
 
+  void setCreateLibmgr(NABoolean v)
+  {(v ? flags_ |= CREATE_LIBMGR : flags_ &= ~CREATE_LIBMGR); }
+  NABoolean createLibmgr() { return (flags_ & CREATE_LIBMGR) != 0;}
+
+  void setDropLibmgr(NABoolean v)
+  {(v ? flags_ |= DROP_LIBMGR : flags_ &= ~DROP_LIBMGR); }
+  NABoolean dropLibmgr() { return (flags_ & DROP_LIBMGR) != 0;}
+
+  void setUpgradeLibmgr(NABoolean v)
+  {(v ? flags_ |= UPGRADE_LIBMGR : flags_ &= ~UPGRADE_LIBMGR); }
+  NABoolean upgradeLibmgr() { return (flags_ & UPGRADE_LIBMGR) != 0;}
+
   void setCreateRepos(NABoolean v)
   {(v ? flags_ |= CREATE_REPOS : flags_ &= ~CREATE_REPOS); }
   NABoolean createRepos() { return (flags_ & CREATE_REPOS) != 0;}
@@ -432,7 +444,10 @@ public:
     CREATE_REPOS            = 0x0008,
     DROP_REPOS              = 0x0010,
     UPGRADE_REPOS           = 0x0020,
-    CLEANUP_AUTH            = 0X0040  
+    CLEANUP_AUTH            = 0X0040,
+    CREATE_LIBMGR           = 0x0080,
+    DROP_LIBMGR             = 0x0100,
+    UPGRADE_LIBMGR          = 0x0200
   };
 
   // see method processSpecialDDL in sqlcomp/parser.cpp

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/optimizer/RelFastTransport.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelFastTransport.cpp 
b/core/sql/optimizer/RelFastTransport.cpp
index 182ff65..5049d76 100644
--- a/core/sql/optimizer/RelFastTransport.cpp
+++ b/core/sql/optimizer/RelFastTransport.cpp
@@ -203,7 +203,7 @@ short FastExtract::setOptions(NAList<UnloadOption*> *
 
   for (CollIndex i = 0; i < fastExtractOptionList->entries(); i++)
   {
-    UnloadOption::UnloadOption * feo = (*fastExtractOptionList)[i];
+    UnloadOption * feo = (*fastExtractOptionList)[i];
     switch (feo->option_)
     {
       case UnloadOption::DELIMITER_:

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/optimizer/RelUpdate.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelUpdate.h b/core/sql/optimizer/RelUpdate.h
index dbd8a06..d949781 100644
--- a/core/sql/optimizer/RelUpdate.h
+++ b/core/sql/optimizer/RelUpdate.h
@@ -1149,7 +1149,8 @@ public:
     baseColRefs_ = val;
   }
 
-  NABoolean isUpsertThatNeedsMerge() const;
+  NABoolean isUpsertThatNeedsMerge(NABoolean isAlignedRowFormat, NABoolean 
omittedDefaultCols,
+                                   NABoolean omittedCurrentDefaultCols) const;
   RelExpr* xformUpsertToMerge(BindWA *bindWA) ;
 
 protected:

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/optimizer/Stats.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/Stats.h b/core/sql/optimizer/Stats.h
index e2ae0c0..faa8bc7 100644
--- a/core/sql/optimizer/Stats.h
+++ b/core/sql/optimizer/Stats.h
@@ -965,7 +965,7 @@ public:
   // NB: no need for a dtor
   //
   Interval () :
-      loIndex_(NULL_COLL_INDEX), hist_(NULL)
+      loIndex_(NULL_COLL_INDEX), hist_(0)
   {}
 
   Interval (CollIndex startIndex, const HistogramSharedPtr& hist) :
@@ -1137,10 +1137,10 @@ public:
   inline NABoolean isNull() const { return (hiBound().isNullValue()) ; }
 
   // make sure we don't use Intervals that have been compromised
-  inline void setInvalid() { hist_ = NULL ; }
+  inline void setInvalid() { hist_ = 0; }
   inline NABoolean isValid() const
   {
-    return ( (hist_ != NULL) &&
+    return ( (hist_ != 0) &&
              ((loIndex_+2) <= hist_->entries()) ) ;
   }
   // was loIndex_ <= hist_->entries()-2, but we hate underflow!
@@ -1446,7 +1446,7 @@ public:
   ColStats (ComUID & histid, CostScalar uec = 0, CostScalar rowcount = 0,
             CostScalar baseRowCount = -1,
            NABoolean unique = FALSE, NABoolean shapeChanged = FALSE,
-           const HistogramSharedPtr& desc = NULL, NABoolean modified = FALSE,
+           const HistogramSharedPtr& desc = 0, NABoolean modified = FALSE,
            CostScalar rowRedFactor = 1.0, CostScalar uecRedFactor = 1.0,
                  Int32 avgVarcharSize = 0,  
            NAMemory* heap=0, NABoolean allowMinusOne=FALSE);

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/optimizer/SynthType.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/SynthType.cpp b/core/sql/optimizer/SynthType.cpp
index fc0f12d..16880e1 100644
--- a/core/sql/optimizer/SynthType.cpp
+++ b/core/sql/optimizer/SynthType.cpp
@@ -43,6 +43,7 @@
 #include "CmpErrors.h"
 #include "ComSqlId.h"
 #include "OptimizerSimulator.h"
+#include "exp_datetime.h"
 
 // For TRIGGERS_STATUS_VECTOR_SIZE and SIZEOF_UNIQUE_EXECUTE_ID
 #include "Triggers.h"
@@ -2782,8 +2783,6 @@ const NAType *CurrentTimestampRunning::synthesizeType()
 // -----------------------------------------------------------------------
 // member functions for class DateFormat
 // -----------------------------------------------------------------------
-
-#pragma nowarn(1506)   // warning elimination
 const NAType *DateFormat::synthesizeType()
 {
   //
@@ -2797,17 +2796,6 @@ const NAType *DateFormat::synthesizeType()
   //
   if (!vid.getType().isSupportedType()) {
     // 4071 The operand of a DATEFORMAT function must be a datetime.
-// LCOV_EXCL_START - mp
-    *CmpCommon::diags() << DgSqlCode(-4071) << DgString0(getTextUpper());
-    return NULL;
-// LCOV_EXCL_STOP
-  }
-
-  if (((getDateFormat() == DEFAULT) ||
-       (getDateFormat() == USA) ||
-       (getDateFormat() == EUROPEAN)) &&
-      (vid.getType().getTypeQualifier() != NA_DATETIME_TYPE)) {
-    // 4071 The operand of a DATEFORMAT function must be a datetime.
     *CmpCommon::diags() << DgSqlCode(-4071) << DgString0(getTextUpper());
     return NULL;
   }
@@ -2837,154 +2825,43 @@ const NAType *DateFormat::synthesizeType()
   NABoolean formatAsDate = FALSE;
   NABoolean formatAsTimestamp = FALSE;
   NABoolean formatAsTime = FALSE;
+
   if (vid.getType().getTypeQualifier() == NA_DATETIME_TYPE)
     {
-      // This code is now identical for all DatetimeTypes
       const DatetimeType& operand = (DatetimeType &)vid.getType();
-      //
-      // Return the result.
-      //
-      if (getDateFormat() == DATE_FORMAT_STR)
-       {
-         if (child(1)->castToItemExpr()->getOperatorType() == ITM_CONSTANT)
-           {
-             ConstValue * cv = (ConstValue*)(child(1)->castToItemExpr());
-             length = cv->getStorageSize();
-           }
-         else
-           {
-             // must be a const for now.
-             CMPASSERT(child(1)->castToItemExpr()->getOperatorType() == 
ITM_CONSTANT);
-           }
-       }
-      else if (getDateFormat() == TIMESTAMP_FORMAT_STR)
-       {
-         if (child(1)->castToItemExpr()->getOperatorType() == ITM_CONSTANT)
-           {
-             ConstValue * cv = (ConstValue*)(child(1)->castToItemExpr());
-             length = cv->getStorageSize();
-
-             if ((NAString((char*)(cv->getConstValue()), cv->getStorageSize())
-                  == "YYYYMMDDHH24MISS") ||
-                 (NAString((char*)(cv->getConstValue()), cv->getStorageSize())
-                  == "YYYYMMDD:HH24:MI:SS") ||
-                 (NAString((char*)(cv->getConstValue()), cv->getStorageSize())
-                  == "DD.MM.YYYY:HH24:MI:SS") ||
-                 (NAString((char*)(cv->getConstValue()), cv->getStorageSize())
-                  == "YYYY-MM-DD HH24:MI:SS"))
-               {
-                 // length includes 2 extra bytes for "24" that was specified
-                 // in the format.
-                 length -= 2;
-               }
-           }
-         else if (getDateFormat() == TIME_FORMAT_STR)
-           {
-             if (child(1)->castToItemExpr()->getOperatorType() == ITM_CONSTANT)
-               {
-                 ConstValue * cv = (ConstValue*)(child(1)->castToItemExpr());
-                 length = cv->getStorageSize();
-                 
-                 if (NAString((char*)(cv->getConstValue()), 
cv->getStorageSize())
-                     == "HH24:MI:SS")
-                   {
-                     // length includes 2 extra bytes for "24" that was 
specified
-                     // in the format.
-                     length -= 2;
-                   }
-               }
-           }  
-         else
-           {
-             // must be a const for now.
-             CMPASSERT(child(1)->castToItemExpr()->getOperatorType() == 
ITM_CONSTANT);
-           }
-       }
-      else
-       {
+      Lng32 frmt = ExpDatetime::getDatetimeFormat(formatStr_.data());
+
+      if (wasDateformat_)
+        {
          length = operand.getDisplayLength();
-         if(operand.containsField(REC_DATE_HOUR) && (getDateFormat() == USA))
+         if(operand.containsField(REC_DATE_HOUR) && 
+             (frmt == ExpDatetime::DATETIME_FORMAT_USA))
            length += 3; // add 3 for a blank and "am" or "pm"
-       }
+        }
+      else
+        {
+          length = ExpDatetime::getDatetimeFormatMaxLen(frmt);
+        }
     }
   else if (vid.getType().getTypeQualifier() == NA_CHARACTER_TYPE)
     {
-      //
-      // Return the result.
-      //
+      length = formatStr_.length();
       if (getDateFormat() == DATE_FORMAT_STR)
        {
          formatAsDate = TRUE;
-         if (child(1)->castToItemExpr()->getOperatorType() == ITM_CONSTANT)
-           {
-             ConstValue * cv = (ConstValue*)(child(1)->castToItemExpr());
-             length = cv->getStorageSize();
-           }
-         else
-           {
-             // must be a const for now.
-             CMPASSERT(child(1)->castToItemExpr()->getOperatorType() == 
ITM_CONSTANT);
-           }
        }
       else if (getDateFormat() == TIMESTAMP_FORMAT_STR)
        {
          formatAsTimestamp = TRUE;
-         if (child(1)->castToItemExpr()->getOperatorType() == ITM_CONSTANT)
-           {
-             ConstValue * cv = (ConstValue*)(child(1)->castToItemExpr());
-             length = cv->getStorageSize();
-           }
-         else
-           {
-             // must be a const for now.
-             CMPASSERT(child(1)->castToItemExpr()->getOperatorType() == 
ITM_CONSTANT);
-           }
        }
       else if (getDateFormat() == TIME_FORMAT_STR)
        {
          formatAsTime = TRUE;
-         if (child(1)->castToItemExpr()->getOperatorType() == ITM_CONSTANT)
-           {
-             ConstValue * cv = (ConstValue*)(child(1)->castToItemExpr());
-             length = cv->getStorageSize();
-           }
-         else
-           {
-             // must be a const for now.
-             CMPASSERT(child(1)->castToItemExpr()->getOperatorType() == 
ITM_CONSTANT);
-           }
        }
     }
   else if (vid.getType().getTypeQualifier() == NA_NUMERIC_TYPE)
     {
-      const NumericType &numeric  = (NumericType&)vid.getType();
-      if ((numeric.isExact()) &&
-         (NOT numeric.isBigNum()) &&
-         (numeric.getScale() == 0))
-       {
-         if (child(1)->castToItemExpr()->getOperatorType() == ITM_CONSTANT)
-           {
-             ConstValue * cv = (ConstValue*)(child(1)->castToItemExpr());
-             length = cv->getStorageSize();
-           }
-         else
-           {
-             // must be a const for now.
-             CMPASSERT(child(1)->castToItemExpr()->getOperatorType() == 
ITM_CONSTANT);
-           }
-       }
-      else
-       {
-         // 4047 Arguments of USER function must have a scale of 0.
-         *CmpCommon::diags() << DgSqlCode(-4047) << DgString0(getTextUpper());
-         return NULL;
-       }
-    }
-  else
-    {
-      // 4071 The operand of a DATEFORMAT function must be a datetime.
-      *CmpCommon::diags() << DgSqlCode(-4071) << DgString0(getTextUpper());
-      return NULL;
+      length = formatStr_.length();
     }
 
   if (formatAsDate)
@@ -2996,7 +2873,6 @@ const NAType *DateFormat::synthesizeType()
   else
     return new HEAP SQLChar(length, vid.getType().supportsSQLnullLogical());
 }
-#pragma warn(1506)  // warning elimination
 
 // -----------------------------------------------------------------------
 // member functions for class DayOfWeek

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/optimizer/ValueDesc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ValueDesc.cpp b/core/sql/optimizer/ValueDesc.cpp
index 891ba15..95246aa 100644
--- a/core/sql/optimizer/ValueDesc.cpp
+++ b/core/sql/optimizer/ValueDesc.cpp
@@ -514,7 +514,7 @@ ValueId::getNAColumn(NABoolean okIfNotColumn) const
 }
 
 
-NABoolean ValueId::isAddedColumnWithNonNullDefault() const{
+NABoolean ValueId::isColumnWithNonNullNonCurrentDefault() const{
   NAColumn * nac = NULL;
   ItemExpr *ck = getItemExpr();
   if ( ck == NULL )
@@ -529,14 +529,13 @@ NABoolean ValueId::isAddedColumnWithNonNullDefault() 
const{
   default:
       break;
   }
-  if (nac && nac->isAddedColumn() && nac->getDefaultValue())
+  if (nac &&  nac->getDefaultValue() && 
nac->getDefaultClass()!=COM_NULL_DEFAULT && 
nac->getDefaultClass()!=COM_CURRENT_DEFAULT)
       return TRUE;
   else
       return FALSE;
 }
 
 
-
 // Since we *can* have an INSTANTIATE_NULL inside a VEG_REFERENCE, a loop
 // was required for the function below.
 //

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/optimizer/ValueDesc.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ValueDesc.h b/core/sql/optimizer/ValueDesc.h
index 559588b..b0e7300 100644
--- a/core/sql/optimizer/ValueDesc.h
+++ b/core/sql/optimizer/ValueDesc.h
@@ -194,9 +194,9 @@ public:
   NABoolean isSaltColumn() const;
 
   // return TRUE if I am a ValueId associated with an Index Column, or
-  // a base column , and I am an added column with a default value that is not
-  // null.
-  NABoolean isAddedColumnWithNonNullDefault() const;
+  // a base column , and I am a column with a default value that is not
+  // null or not Current.
+  NABoolean isColumnWithNonNullNonCurrentDefault() const;
 
   // ---------------------------------------------------------------------
   // change the ValueId's type to the given type

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/parser/ElemDDLNode.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLNode.cpp b/core/sql/parser/ElemDDLNode.cpp
index 3e9b21b..ebb56e0 100644
--- a/core/sql/parser/ElemDDLNode.cpp
+++ b/core/sql/parser/ElemDDLNode.cpp
@@ -1403,6 +1403,12 @@ ElemDDLNode::castToStmtDDLAlterTableAlterColumnDatatype()
   return NULL;
 }
 
+StmtDDLAlterTableAlterColumnRename *
+ElemDDLNode::castToStmtDDLAlterTableAlterColumnRename()
+{
+  return NULL;
+}
+
 StmtDDLAlterTableAlterColumnSetSGOption *
 ElemDDLNode::castToStmtDDLAlterTableAlterColumnSetSGOption()
 {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/parser/ElemDDLNode.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLNode.h b/core/sql/parser/ElemDDLNode.h
index e1d540a..e873a11 100644
--- a/core/sql/parser/ElemDDLNode.h
+++ b/core/sql/parser/ElemDDLNode.h
@@ -275,6 +275,7 @@ class StmtDDLAlterTablePartition;
 class StmtDDLAlterTableRename;
 class StmtDDLAlterTableNamespace;
 class StmtDDLAlterTableAlterColumnDatatype;
+class StmtDDLAlterTableAlterColumnRename;
 class StmtDDLAlterTableAlterColumnDefaultValue;
 class StmtDDLAlterTableAlterColumnSetSGOption;
 class StmtDDLAlterTableSetConstraint;
@@ -606,6 +607,8 @@ public:
                 castToStmtDDLAlterTableAlterColumnDefaultValue();
   virtual StmtDDLAlterTableAlterColumnDatatype* 
                 castToStmtDDLAlterTableAlterColumnDatatype();
+  virtual StmtDDLAlterTableAlterColumnRename* 
+                castToStmtDDLAlterTableAlterColumnRename();
   virtual StmtDDLAlterTableSetConstraint*
                 castToStmtDDLAlterTableSetConstraint();
   virtual StmtDDLAlterTableToggleConstraint*

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/parser/ParKeyWords.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/ParKeyWords.cpp b/core/sql/parser/ParKeyWords.cpp
index b46660e..9e52923 100644
--- a/core/sql/parser/ParKeyWords.cpp
+++ b/core/sql/parser/ParKeyWords.cpp
@@ -302,7 +302,6 @@ ParKeyWord ParKeyWords::keyWords_[] = {
   ParKeyWord("DATE_TRUNC",         TOK_DATE_TRUNC,  NONRESTOKEN_),
   ParKeyWord("DATEDIFF",           TOK_DATEDIFF,    NONRESTOKEN_),
   ParKeyWord("DATE_SUB",           TOK_DATE_SUB,    NONRESTOKEN_),
-  ParKeyWord("DATEFMT_INTN",       TOK_DATEFMT_INTN, NONRESTOKEN_),
   ParKeyWord("DATEFORMAT",         TOK_DATEFORMAT,  NONRESTOKEN_),
   ParKeyWord("DATETIME",           TOK_DATETIME,    COMPAQ_|RESWORD_|MPWORD_),
   ParKeyWord("DATETIME_CODE",      TOK_DATETIME_CODE, NONRESTOKEN_),
@@ -620,6 +619,7 @@ ParKeyWord ParKeyWords::keyWords_[] = {
   ParKeyWord("LZO",                TOK_LZO,         NONRESTOKEN_),
   ParKeyWord("M",                  TOK_M,           NONRESTOKEN_),
   ParKeyWord("MAINTAIN",           TOK_MAINTAIN,    SECOND_|COMPAQ_|RESWORD_),
+  ParKeyWord("MANAGEMENT",         TOK_MANAGEMENT,  NONRESTOKEN_),
   ParKeyWord("MANUAL",             TOK_MANUAL,      FLAGSNONE_),
   ParKeyWord("MAP",                TOK_MAP,         COMPAQ_|RESWORD_),
   ParKeyWord("MASTER",             TOK_MASTER,      NONRESTOKEN_),
@@ -1089,9 +1089,10 @@ ParKeyWord ParKeyWords::keyWords_[] = {
   ParKeyWord("TO_CHAR",            TOK_TO_CHAR,     NONRESTOKEN_),
   ParKeyWord("TO_DATE",            TOK_TO_DATE,     NONRESTOKEN_),
   ParKeyWord("TO_NUMBER",          TOK_TO_NUMBER,   NONRESTOKEN_),
-  ParKeyWord("TO_TIMESTAMP",          TOK_TO_TIMESTAMP,   NONRESTOKEN_),
+  ParKeyWord("TO_TIME",            TOK_TO_TIME,   NONRESTOKEN_),
+  ParKeyWord("TO_TIMESTAMP",       TOK_TO_TIMESTAMP,   NONRESTOKEN_),
   ParKeyWord("TOKENSTR",           TOK_TOKENSTR,    NONRESTOKEN_),
-  ParKeyWord("TRAFODION",             TOK_TRAFODION,    NONRESTOKEN_),
+  ParKeyWord("TRAFODION",          TOK_TRAFODION,    NONRESTOKEN_),
   ParKeyWord("TRAILING",           TOK_TRAILING,    ANS_|RESWORD_|MPWORD_),
   ParKeyWord("TRANSACTION",        TOK_TRANSACTION, ANS_|RESWORD_),
   ParKeyWord("TRANSFORM",          TOK_TRANSFORM,   NONRESTOKEN_),

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/parser/StmtDDLAlterTableAlterColumn.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLAlterTableAlterColumn.cpp 
b/core/sql/parser/StmtDDLAlterTableAlterColumn.cpp
index b2c1f9c..cb68092 100644
--- a/core/sql/parser/StmtDDLAlterTableAlterColumn.cpp
+++ b/core/sql/parser/StmtDDLAlterTableAlterColumn.cpp
@@ -51,7 +51,6 @@ StmtDDLAlterTableAlterColumn::getText() const
 }
        
 
-
 //----------------------------------------------------------------------------
 // CLASS StmtDDLAlterTableAlterColumnDatatype
 //----------------------------------------------------------------------------
@@ -96,6 +95,44 @@ StmtDDLAlterTableAlterColumnDatatype::getText() const
   return "StmtDDLAlterTableAlterColumnDatatype" ;
 }
        
+//----------------------------------------------------------------------------
+// CLASS StmtDDLAlterTableAlterColumnRename
+//----------------------------------------------------------------------------
+StmtDDLAlterTableAlterColumnRename::StmtDDLAlterTableAlterColumnRename( 
+     const NAString &columnName,
+     const NAString &renamedColumnName,
+     CollHeap *heap)
+    : StmtDDLAlterTableAlterColumn(DDL_ALTER_TABLE_ALTER_COLUMN_RENAME, 
+                                   columnName,
+                                   NULL,
+                                   heap),
+      renamedColumnName_(renamedColumnName)
+{
+}
+
+//
+// Virtual destructor
+//
+
+StmtDDLAlterTableAlterColumnRename::~StmtDDLAlterTableAlterColumnRename()
+{}
+
+//
+// Cast function: to provide the safe castdown to the current object
+//
+
+StmtDDLAlterTableAlterColumnRename *
+StmtDDLAlterTableAlterColumnRename::castToStmtDDLAlterTableAlterColumnRename()
+{
+  return this;
+}
+
+const NAString
+StmtDDLAlterTableAlterColumnRename::getText() const
+{
+  return "StmtDDLAlterTableAlterColumnRename" ;
+}
+       
 
 //----------------------------------------------------------------------------
 // CLASS StmtDDLAlterTableAlterColumnDefaultValue

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/parser/StmtDDLAlterTableAlterColumn.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLAlterTableAlterColumn.h 
b/core/sql/parser/StmtDDLAlterTableAlterColumn.h
index 7ad20de..ecb2178 100644
--- a/core/sql/parser/StmtDDLAlterTableAlterColumn.h
+++ b/core/sql/parser/StmtDDLAlterTableAlterColumn.h
@@ -135,7 +135,6 @@ private:
 
 }; // class StmtDDLAlterTableAlterColumnDefaultValue
 
-
 // -----------------------------------------------------------------------
 // definition of class StmtDDLAlterTableAlterColumnDatatype
 // -----------------------------------------------------------------------
@@ -178,4 +177,43 @@ private:
 
 }; // class StmtDDLAlterTableAlterColumnDatatype
 
+// -----------------------------------------------------------------------
+// definition of class StmtDDLAlterTableAlterColumnRename
+// -----------------------------------------------------------------------
+class StmtDDLAlterTableAlterColumnRename : public StmtDDLAlterTableAlterColumn
+{
+public:
+  
+  // constructor
+  StmtDDLAlterTableAlterColumnRename( const NAString &columnName,
+                                      const NAString &renamedColumnName,
+                                      CollHeap    * heap = PARSERHEAP());
+  
+  // virtual destructor
+  virtual ~StmtDDLAlterTableAlterColumnRename();
+  
+  // cast
+  virtual StmtDDLAlterTableAlterColumnRename * 
castToStmtDDLAlterTableAlterColumnRename();
+  
+  // accessors
+  NAString getRenamedColumnName() { return renamedColumnName_; }
+  const NAString getRenamedColumnName() const { return renamedColumnName_; }
+  
+  // method for tracing
+  virtual const NAString getText() const;
+  
+private: 
+  // column name
+  NAString renamedColumnName_;
+  
+  //
+  // please do not use the following methods
+  //
+  
+  StmtDDLAlterTableAlterColumnRename();   // DO NOT USE
+  StmtDDLAlterTableAlterColumnRename(const StmtDDLAlterTableAlterColumnRename 
&);   // DO NOT USE
+  StmtDDLAlterTableAlterColumnRename & operator=(const 
StmtDDLAlterTableAlterColumnRename &);  // DO NOT USE
+  
+}; // class StmtDDLAlterTableAlterColumnRename
+
 #endif //STMTDDLALTERTABLEALTERCOLUMN_H

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/parser/sqlparser.y
----------------------------------------------------------------------
diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y
index e565f14..dc1a323a 100755
--- a/core/sql/parser/sqlparser.y
+++ b/core/sql/parser/sqlparser.y
@@ -182,6 +182,7 @@ using namespace std;
 
 #include "exp_expr.h"
 #include "exp_clause_derived.h"
+#include "exp_datetime.h"
 #include "Analyzer.h"
 
 
@@ -589,7 +590,6 @@ static void enableMakeQuotedStringISO88591Mechanism()
 %token <tokval> TOK_DATE_TRUNC
 %token <tokval> TOK_DATEDIFF
 %token <tokval> TOK_DATEFORMAT          /* Tandem extension */
-%token <tokval> TOK_DATEFMT_INTN        /* Tandem extension */
 %token <tokval> TOK_DATETIME            /* Tandem extension non-reserved word 
*/
 %token <tokval> TOK_DAY
 %token <tokval> TOK_DAYNAME
@@ -818,6 +818,7 @@ static void enableMakeQuotedStringISO88591Mechanism()
 %token <tokval> TOK_LSDECIMAL
 %token <tokval> TOK_LTRIM               /*  ODBC extension  */
 %token <tokval> TOK_MAINTAIN
+%token <tokval> TOK_MANAGEMENT
 %token <tokval> TOK_MANUAL                             // MV
 %token <tokval> TOK_MASTER
 %token <tokval> TOK_MATCH
@@ -1113,6 +1114,7 @@ static void enableMakeQuotedStringISO88591Mechanism()
 %token <tokval> TOK_TO_CHAR
 %token <tokval> TOK_TO_DATE
 %token <tokval> TOK_TO_NUMBER
+%token <tokval> TOK_TO_TIME
 %token <tokval> TOK_TO_TIMESTAMP
 %token <tokval> TOK_TOKENSTR
 %token <tokval> TOK_TRAILING
@@ -2007,7 +2009,7 @@ static void enableMakeQuotedStringISO88591Mechanism()
 %type <item>                    insert_obj_to_lob_function
 %type <item>                    update_obj_to_lob_function
 %type <item>                    select_lob_to_obj_function
-%type <tokval>                 date_format
+%type <stringval>              date_format
 %type <tokval>                 trim_spec
 %type <na_type>                proc_arg_data_type
 %type <na_type>                data_type
@@ -2492,6 +2494,7 @@ static void enableMakeQuotedStringISO88591Mechanism()
 %type <pStmtDDL>               alter_table_alter_column_default_value 
 %type <pStmtDDL>               alter_table_alter_column_datatype
 %type <pStmtDDL>               alter_table_alter_column_set_sg_option 
+%type <pStmtDDL>               alter_table_alter_column_rename
 %type <boolean>                alter_column_type //++ MV
 %type <pStmtDDL>               alter_table_set_constraint_clause
 %type <pStmtDDL>                alter_table_disable_constraint_clause
@@ -3217,7 +3220,7 @@ literal :       numeric_literal
                       $$ = new (PARSERHEAP()) ConstValue
                         (*$1, getStringCharSet(&$1));
                       SqlParser_CurrentParser->collectItem4HQC($$);    
-                     $$ = new (PARSERHEAP()) Format($$, *$6, TRUE);
+                      $$ = new (PARSERHEAP()) DateFormat($$, *$6, 
DateFormat::FORMAT_TO_DATE);
                    }
                  else
                    {
@@ -3225,7 +3228,7 @@ literal :       numeric_literal
                      if (! $$) YYERROR;
                       SqlParser_CurrentParser->collectItem4HQC($$);
                      restoreInferCharsetState();
-                     $$ = new (PARSERHEAP()) Format($$, *$6, FALSE);
+                      $$ = new (PARSERHEAP()) DateFormat($$, *$6, 
DateFormat::FORMAT_TO_CHAR);
                    }
 
                 }
@@ -7912,7 +7915,7 @@ primary :     '(' value_expression ')'
              | dml_column_reference TOK_LPAREN_BEFORE_DATE_COMMA_AND_FORMAT 
TOK_DATE ',' TOK_FORMAT character_string_literal ')'
                 {
                   // DEFAULT_CHARSET has no effect on character_string_literal 
in this context
-                 $$ = new (PARSERHEAP()) Format($1, *$6, FALSE);
+                  $$ = new (PARSERHEAP()) DateFormat($1, *$6, 
DateFormat::FORMAT_TO_CHAR);
                }
 
               | hostvar_expression
@@ -8460,23 +8463,11 @@ datetime_misc_function : TOK_CONVERTTIMESTAMP '(' 
value_expression ')'
                                }
      | TOK_DATEFORMAT '(' value_expression ',' date_format  ')'
                                 {
-                                  if ( (SqlParser_DEFAULT_CHARSET == 
CharInfo::ISO88591) ||
-                                       
(CmpCommon::getDefault(ALLOW_IMPLICIT_CHAR_CASTING) == DF_ON) )
-                                  {
-                                    $$ = new (PARSERHEAP())
-                                      DateFormat($3, NULL, $5);
-                                  }
-                                  else
-                                  {
-                                      $$ = new (PARSERHEAP()) 
ZZZBinderFunction( ITM_DATEFMT,
-                                           $3, new (PARSERHEAP()) 
ConstValue($5) );
-                                  }
+                                  $$ = new (PARSERHEAP()) 
+                                    DateFormat($3, *$5, 
+                                               DateFormat::FORMAT_TO_CHAR,
+                                               TRUE);
                                 }
-     | TOK_DATEFMT_INTN '(' value_expression ',' date_format  ')'
-                               {
-                                 $$ = new (PARSERHEAP())
-                                   DateFormat($3, NULL, $5);
-                               }
                                    
      | TOK_DAYOFWEEK '(' value_expression ')'
                                {
@@ -8583,29 +8574,24 @@ datetime_misc_function : TOK_CONVERTTIMESTAMP '(' 
value_expression ')'
                                 }
     | TOK_TO_CHAR '(' value_expression ',' character_string_literal ')'
                                {
-                                CheckModeSpecial3;
-
                                 $$ = new (PARSERHEAP()) 
-                                  Format($3, *$5, FALSE, 
Format::FORMAT_TO_CHAR);
+                                   DateFormat($3, *$5, 
DateFormat::FORMAT_TO_CHAR);
                               }
     | TOK_TO_CHAR '(' value_expression ')'
                                {
-                                CheckModeSpecial4;
-                                 $$ = $3;
+                                 $$ = new (PARSERHEAP()) DateFormat
+                                   ($3, "YYYY-MM-DD", 
DateFormat::FORMAT_TO_CHAR);
+
                               }
     | TOK_TO_DATE '(' value_expression ',' character_string_literal ')'
                                {
-                                CheckModeSpecial3;
-
-                                $$ = new (PARSERHEAP()) 
-                                  Format($3, *$5, TRUE, 
Format::FORMAT_TO_DATE);
+                                 $$ = new (PARSERHEAP()) 
+                                   DateFormat($3, *$5, 
DateFormat::FORMAT_TO_DATE);
                               }
    | TOK_TO_DATE '(' value_expression  ')'
                                {
-                                CheckModeSpecial4;
-
                                 $$ = new (PARSERHEAP()) 
-                                  Format($3, "YYYY-MM-DD", TRUE, 
Format::FORMAT_TO_DATE);
+                                  DateFormat($3, "YYYY-MM-DD", 
DateFormat::FORMAT_TO_DATE);
                               }
     | TOK_TO_NUMBER '(' value_expression ')'
                                {
@@ -8614,6 +8600,11 @@ datetime_misc_function : TOK_CONVERTTIMESTAMP '(' 
value_expression ')'
                                 $$ = new (PARSERHEAP()) 
                                   ZZZBinderFunction(ITM_TO_NUMBER, $3);
                               }
+    | TOK_TO_TIME '(' value_expression ',' character_string_literal ')'
+                               {
+                                 $$ = new (PARSERHEAP()) 
+                                   DateFormat($3, *$5, 
DateFormat::FORMAT_TO_DATE);
+                              }
     | TOK_TO_TIMESTAMP '(' value_expression ')'
                                {
                                 CheckModeSpecial4;
@@ -10321,10 +10312,19 @@ trim_spec : TOK_LEADING     {  $$ = (Int32) 
Trim::LEADING;  }
 
 
 
-/* type uint */
-date_format : TOK_DEFAULT   {  $$ = (Int32) DateFormat::DEFAULT;  }
-       | TOK_EUROPEAN      {  $$ = (Int32) DateFormat::EUROPEAN; }
-       | TOK_USA           {  $$ = (Int32) DateFormat::USA;      }
+/* type stringval */
+date_format : TOK_DEFAULT   
+    {  
+      $$ = new (PARSERHEAP()) 
NAString(ExpDatetime::getDatetimeFormatStr(ExpDatetime::DATETIME_FORMAT_DEFAULT));
+    }
+       | TOK_EUROPEAN      
+    {  
+      $$ = new (PARSERHEAP()) 
NAString(ExpDatetime::getDatetimeFormatStr(ExpDatetime::DATETIME_FORMAT_EUROPEAN));
+    }
+       | TOK_USA           
+    {  
+      $$ = new (PARSERHEAP()) 
NAString(ExpDatetime::getDatetimeFormatStr(ExpDatetime::DATETIME_FORMAT_USA));
+    }
 
 
 /* type item */
@@ -16127,6 +16127,57 @@ exe_util_init_hbase : TOK_INITIALIZE TOK_TRAFODION
 
                }
 
+             | TOK_INITIALIZE TOK_TRAFODION ',' TOK_CREATE TOK_LIBRARY 
TOK_MANAGEMENT
+               {
+                CharInfo::CharSet stmtCharSet = CharInfo::UnknownCharSet;
+                NAString * stmt = getSqlStmtStr ( stmtCharSet  // out - 
CharInfo::CharSet &
+                                                , PARSERHEAP() 
+                                                );
+
+                DDLExpr * de = new(PARSERHEAP()) DDLExpr(NULL,
+                                                          (char*)stmt->data(),
+                                                           stmtCharSet);
+
+                 de->setCreateLibmgr(TRUE);
+
+                 $$ = de;
+
+               }
+
+             | TOK_INITIALIZE TOK_TRAFODION ',' TOK_DROP TOK_LIBRARY 
TOK_MANAGEMENT
+               {
+                 CharInfo::CharSet stmtCharSet = CharInfo::UnknownCharSet;
+                 NAString * stmt = getSqlStmtStr ( stmtCharSet  // out - 
CharInfo::CharSet &
+                                                 , PARSERHEAP()
+                                                 );
+
+                 DDLExpr * de = new(PARSERHEAP()) DDLExpr(NULL,
+                                                          (char*)stmt->data(),
+                                                          stmtCharSet);
+
+                 de->setDropLibmgr(TRUE);
+
+                 $$ = de;
+
+               }
+
+             | TOK_INITIALIZE TOK_TRAFODION ',' TOK_UPGRADE TOK_LIBRARY 
TOK_MANAGEMENT
+               {
+                 CharInfo::CharSet stmtCharSet = CharInfo::UnknownCharSet;
+                 NAString * stmt = getSqlStmtStr ( stmtCharSet  // out - 
CharInfo::CharSet &
+                                                 , PARSERHEAP()
+                                                 );
+
+                 DDLExpr * de = new(PARSERHEAP()) DDLExpr(NULL,
+                                                          (char*)stmt->data(),
+                                                          stmtCharSet);
+
+                 de->setUpgradeLibmgr(TRUE);
+
+                 $$ = de;
+
+               }
+
             | TOK_INITIALIZE TOK_TRAFODION ',' TOK_CREATE TOK_REPOSITORY
                {
                 CharInfo::CharSet stmtCharSet = CharInfo::UnknownCharSet;
@@ -28693,6 +28744,8 @@ before_trigger_prefix: create_trigger_keywords 
ddl_qualified_name
              TOK_BEFORE iud_event optional_update_column_list TOK_ON
              ddl_qualified_name referencing_clause before_action_orientation
              {
+               *SqlParser_Diags << DgSqlCode(-3131);
+               YYERROR;
 
                InsideTriggerDefinition = TRUE;
 
@@ -28767,6 +28820,9 @@ after_trigger_prefix: create_trigger_keywords 
ddl_qualified_name
              TOK_AFTER iud_event optional_update_column_list TOK_ON
              ddl_qualified_name referencing_clause after_action_orientation
              {
+               *SqlParser_Diags << DgSqlCode(-3131);
+               YYERROR;
+
                InsideTriggerDefinition = TRUE;
 
             //  if (NonISO88591LiteralEncountered) {
@@ -29047,6 +29103,9 @@ mv_definition: create_mv_keywords ddl_qualified_name
                 optional_in_memory_clause
                 as_token query_expression
     {
+      *SqlParser_Diags << DgSqlCode(-3131);
+      YYERROR;
+
       RelRoot *top = finalize($11);
       ForUpdateSpec spec(FALSE);
       spec.finalizeUpdatability(top);
@@ -29176,6 +29235,9 @@ create_mv_keywords: TOK_CREATE optional_ghost mv_token
 // type pStmtDDL 
 create_mvrgroup_statement : TOK_CREATE TOK_MVGROUP ddl_qualified_name
 {
+  *SqlParser_Diags << DgSqlCode(-3131);
+  YYERROR;
+
   $$ = new (PARSERHEAP())StmtDDLCreateMvRGroup(*$3);
   delete $3;
 }
@@ -30590,10 +30652,13 @@ alter_view_statement : TOK_ALTER TOK_VIEW 
ddl_qualified_name
 // type pStmtDDL
 alter_mv_statement : TOK_ALTER optional_ghost mv_token alter_mv_body
                                         {
-                                                
$4->castToStmtDDLAlterMV()->synthesize();
-                                                $$ = $4 /*alter_mv_body*/;
-                                                 if ($2) /*optional_ghost*/
-                                                   $$->setIsGhostObject(TRUE);
+                                           *SqlParser_Diags << 
DgSqlCode(-3131);
+                                           YYERROR;
+                                           
+                                           
$4->castToStmtDDLAlterMV()->synthesize();
+                                           $$ = $4 /*alter_mv_body*/;
+                                           if ($2) /*optional_ghost*/
+                                             $$->setIsGhostObject(TRUE);
                                         }
 
 
@@ -31167,9 +31232,11 @@ alter_table_action : add_table_constraint_definition
                      | alter_table_alter_column_datatype
                        {
                                $$ = $1;
-
                        }
-                       
+                     | alter_table_alter_column_rename
+                       {
+                               $$ = $1;
+                       }
                      | alter_table_alter_column_default_value 
                        {
                                $$ = $1;
@@ -31248,6 +31315,18 @@ alter_table_alter_column_default_value : TOK_ALTER 
TOK_COLUMN column_name TOK_DE
                                       delete $3;
                                       restoreInferCharsetState();
                                }
+
+// type pStmtDDL
+alter_table_alter_column_rename : TOK_ALTER TOK_COLUMN column_name TOK_RENAME 
TOK_TO column_name
+                               {
+                                 $$ = new (PARSERHEAP())
+                                    StmtDDLAlterTableAlterColumnRename(
+                                         *$3,  // column name
+                                         *$6); // renamed column name
+                                  delete $3;
+                                  delete $6;
+                                  restoreInferCharsetState();
+                               }
                                
 // type pStmtDDL
 alter_table_alter_column_set_sg_option : TOK_ALTER TOK_COLUMN column_name 
TOK_SET sequence_generator_options
@@ -31795,6 +31874,9 @@ drop_table_start_tokens : TOK_DROP TOK_TABLE
 // MV - RG
 drop_mvrgroup_statement : TOK_DROP TOK_MVGROUP ddl_qualified_name
 {
+  *SqlParser_Diags << DgSqlCode(-3131);
+  YYERROR;
+
   $$ = new (PARSERHEAP())StmtDDLDropMvRGroup(*$3);
   delete $3;
 }
@@ -31803,6 +31885,9 @@ drop_mvrgroup_statement : TOK_DROP TOK_MVGROUP 
ddl_qualified_name
 drop_trigger_statement : TOK_DROP TOK_TRIGGER ddl_qualified_name 
                          optional_cleanup optional_validate optional_logfile
                 {
+                  *SqlParser_Diags << DgSqlCode(-3131);
+                  YYERROR;
+
                   /* If VALIDATE, or LOG option specified, */
                   /* ALLOW_SPECIALTABLETYPE must also be specified  */
                   if (($5 || $6) &&
@@ -31831,6 +31916,9 @@ drop_trigger_statement : TOK_DROP TOK_TRIGGER 
ddl_qualified_name
 drop_mv_statement : TOK_DROP optional_ghost mv_token ddl_qualified_name 
optional_cleanup
                     optional_drop_behavior optional_validate optional_logfile
                 {
+                  *SqlParser_Diags << DgSqlCode(-3131);
+                  YYERROR;
+
                   /* If VALIDATE, or LOG option specified, */
                   /* ALLOW_SPECIALTABLETYPE must also be specified  */
                   if (($7 || $8) &&
@@ -33147,6 +33235,7 @@ nonreserved_word :      TOK_ABORT
                       | TOK_SEQUENCES
                       | TOK_SINCE
 //                   | TOK_MAINTAIN
+                      | TOK_MANAGEMENT
                      | TOK_MANUAL
                      | TOK_MIXED
                      | TOK_MVS  // MV
@@ -33209,7 +33298,6 @@ nonreserved_func_word:  TOK_ABS
                       | TOK_D_RANK 
                       | TOK_DATABASE
                       | TOK_DATEFORMAT
-                      | TOK_DATEFMT_INTN
                       | TOK_DAYNAME
                       | TOK_DAYOFMONTH
                       | TOK_DAYOFWEEK
@@ -33305,6 +33393,7 @@ nonreserved_func_word:  TOK_ABS
                       | TOK_TO_CHAR
                       | TOK_TO_DATE
                       | TOK_TO_NUMBER
+                      | TOK_TO_TIME
                       | TOK_TO_TIMESTAMP
                       | TOK_TRUNC
                       | TOK_TRUNCATE

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/regress/charsets/DIFF012.KNOWN.SB
----------------------------------------------------------------------
diff --git a/core/sql/regress/charsets/DIFF012.KNOWN.SB 
b/core/sql/regress/charsets/DIFF012.KNOWN.SB
index 72130ac..7dadfad 100644
--- a/core/sql/regress/charsets/DIFF012.KNOWN.SB
+++ b/core/sql/regress/charsets/DIFF012.KNOWN.SB
@@ -1,2 +1,2 @@
-125d124
+126d125
 < good day_suffix

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/regress/charsets/EXPECTED002
----------------------------------------------------------------------
diff --git a/core/sql/regress/charsets/EXPECTED002 
b/core/sql/regress/charsets/EXPECTED002
index 3d40878..18f1eed 100755
--- a/core/sql/regress/charsets/EXPECTED002
+++ b/core/sql/regress/charsets/EXPECTED002
@@ -92,7 +92,7 @@
 >>--no UCS2 strings in a view text
 >>create view nt006v1 as select * from t013 where c > _UCS2'aaaa';
 
-*** ERROR[4082] Object CAT.SCH.T013 does not exist or is inaccessible.
+*** ERROR[4082] Object TRAFODION.SCH.T013 does not exist or is inaccessible.
 
 --- SQL operation failed with errors.
 >>
@@ -108,7 +108,7 @@
 >>create trigger t013t1 after insert on nt008
 +>     update nt008 set i = 7 where i = 9;
 
-*** ERROR[4222] The DDL feature is not supported in this software version.
+*** ERROR[3131] The statement just entered is currently not supported.
 
 *** ERROR[8822] The statement was not prepared.
 
@@ -116,7 +116,7 @@
 >>create trigger t013t2 after insert on nt008
 +>     update nt007 set d = _UCS2'qwer' where d = _UCS2'aaaa';
 
-*** ERROR[4222] The DDL feature is not supported in this software version.
+*** ERROR[3131] The statement just entered is currently not supported.
 
 *** ERROR[8822] The statement was not prepared.
 
@@ -143,11 +143,12 @@
 --- SQL operation complete.
 >>invoke t013;
 
--- Definition of table CAT.SCH.T013
--- Definition current  Fri Jul 23 16:05:50 2010
+-- Definition of Trafodion table TRAFODION.SCH.T013
+-- Definition current  Sun Mar 20 15:28:28 2016
 
   (
-    A                                CHAR(10) CHARACTER SET UCS2 COLLATE
+    SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
+  , A                                CHAR(10) CHARACTER SET UCS2 COLLATE
       DEFAULT DEFAULT _UCS2'aa'
   )
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/regress/charsets/EXPECTED003
----------------------------------------------------------------------
diff --git a/core/sql/regress/charsets/EXPECTED003 
b/core/sql/regress/charsets/EXPECTED003
index af07866..4aad76f 100755
--- a/core/sql/regress/charsets/EXPECTED003
+++ b/core/sql/regress/charsets/EXPECTED003
@@ -11,18 +11,19 @@
 >>--INVOKE and SHOWDDL work for tables with columns associated with UCS2.
 >>invoke t002;
 
--- Definition of table CAT.SCH.T002
--- Definition current  Fri Apr 23 14:40:12 2010
+-- Definition of Trafodion table TRAFODION.SCH.T002
+-- Definition current  Thu Feb 25 10:23:15 2016
 
   (
-    C                                CHAR(10) CHARACTER SET UCS2 COLLATE
+    SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
+  , C                                CHAR(10) CHARACTER SET UCS2 COLLATE
       DEFAULT DEFAULT NULL
   )
 
 --- SQL operation complete.
 >>showddl t002;
 
-CREATE TABLE CAT.SCH.T002
+CREATE TABLE TRAFODION.SCH.T002
   (
     C                                CHAR(10) CHARACTER SET UCS2 COLLATE
       DEFAULT DEFAULT NULL
@@ -71,7 +72,7 @@ ucs2      iso88591  xxxx
 
 *** ERROR[15001] A syntax error occurred at or before: 
 insert into t002 values(_UNICODE'asdf');
-                        ^ (25 characters from start of SQL statement)
+                              ^ (31 characters from start of SQL statement)
 
 *** ERROR[8822] The statement was not prepared.
 

Reply via email to