trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ansha...@apache.org
Subject [01/11] incubator-trafodion git commit: commit #1
Date Tue, 12 Apr 2016 01:17:29 GMT
Repository: incubator-trafodion
Updated Branches:
  refs/heads/master 709b9318e -> 19b4f1fe7


commit #1


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

Branch: refs/heads/master
Commit: 236e26d374605974e39bb9c3063cb6494418be87
Parents: 4dda119
Author: Cloud User <centos@ansharma-3.novalocal>
Authored: Fri Apr 1 04:18:53 2016 +0000
Committer: Cloud User <centos@ansharma-3.novalocal>
Committed: Fri Apr 1 04:18:53 2016 +0000

----------------------------------------------------------------------
 core/sql/arkcmp/CmpContext.h              |   1 +
 core/sql/bin/SqlciErrors.txt              |   2 +-
 core/sql/cli/Statement.cpp                |   3 +-
 core/sql/exp/exp_datetime.cpp             |   3 +-
 core/sql/generator/GenExpGenerator.cpp    |  43 +++++++++--
 core/sql/generator/GenPreCode.cpp         |  96 ++++++++++++++++++++++-
 core/sql/generator/GenRelUpdate.cpp       |  24 ------
 core/sql/optimizer/BindItemExpr.cpp       |  26 ++++++-
 core/sql/optimizer/NARoutine.cpp          |  47 ++++++++++--
 core/sql/optimizer/NARoutineDB.h          |   4 +-
 core/sql/optimizer/NATable.cpp            |   1 +
 core/sql/optimizer/RelExeUtil.cpp         |   8 +-
 core/sql/optimizer/RelExeUtil.h           |   2 +
 core/sql/optimizer/SynthType.cpp          |   5 +-
 core/sql/regress/core/EXPECTED116         | 102 +++++++++++++++++++++----
 core/sql/regress/core/TEST116             |  18 +++++
 core/sql/regress/seabase/EXPECTED027      |  98 +++++++++++-------------
 core/sql/regress/seabase/EXPECTED030      |  34 ++++++---
 core/sql/regress/seabase/EXPECTED031      |  24 ++++++
 core/sql/regress/seabase/TEST030          |   2 +
 core/sql/regress/seabase/TEST031          |   8 ++
 core/sql/regress/udr/TEST100              |   1 +
 core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp |   3 +-
 core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp  |  87 +++------------------
 core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp |   8 +-
 core/sql/sqlcomp/CmpSeabaseDDLtable.cpp   |  24 +++++-
 26 files changed, 466 insertions(+), 208 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/arkcmp/CmpContext.h
----------------------------------------------------------------------
diff --git a/core/sql/arkcmp/CmpContext.h b/core/sql/arkcmp/CmpContext.h
index 2ef7133..f53648f 100644
--- a/core/sql/arkcmp/CmpContext.h
+++ b/core/sql/arkcmp/CmpContext.h
@@ -473,6 +473,7 @@ public :
   struct DDLObjInfo
   {
     NAString ddlObjName;
+    Int64 objUID;
     ComQiScope qiScope;
     ComObjectType ot;
   };

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/bin/SqlciErrors.txt
----------------------------------------------------------------------
diff --git a/core/sql/bin/SqlciErrors.txt b/core/sql/bin/SqlciErrors.txt
index 045b1f1..bcb4fb3 100644
--- a/core/sql/bin/SqlciErrors.txt
+++ b/core/sql/bin/SqlciErrors.txt
@@ -2983,7 +2983,7 @@ $3~String1.
 20122 ZZZZZ 99999 BEGINNER MINOR LOGONLY Table has indexes. Cannot purge data from partition.
 20123 ZZZZZ 99999 BEGINNER MINOR LOGONLY A user-defined transaction has been started. $0~string0 cannot be performed.
 20124 ZZZZZ 99999 BEGINNER MINOR LOGONLY $0~string0 operation cannot be performed if AUTOCOMMIT is OFF.
-20125 ZZZZZ 99999 BEGINNER MINOR LOGONLY $0~string0 is a metadata table. PURGEDATA cannot be performed on metadata tables.
+20125 ZZZZZ 99999 BEGINNER MINOR LOGONLY $0~string0 operation cannot be performed if a user-defined transaction has been started or AUTOCOMMIT is OFF.
 20126 ZZZZZ 99999 ADVANCED INFRM LOGONLY Vertical partitions exist for the source table. Cannot perform DUP.
 20127 ZZZZZ 99999 BEGINNER MINOR LOGONLY Target option was specified as NEW but $0~string0 exists. DUP operation failed.
 20128 ZZZZZ 99999 BEGINNER MINOR LOGONLY $0~string0 is a metadata table. DUP cannot be performed on metadata tables.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/cli/Statement.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/Statement.cpp b/core/sql/cli/Statement.cpp
index 66d175c..0fad61b 100644
--- a/core/sql/cli/Statement.cpp
+++ b/core/sql/cli/Statement.cpp
@@ -6278,7 +6278,8 @@ short Statement::beginTransaction(ComDiagsArea &diagsArea)
   // implicit xns for ddl stmts will be started and committed/aborted
   // in arkcmp
   if ((root_tdb->transactionReqd()) &&
-      (NOT root_tdb->ddlQuery()))
+      ((NOT root_tdb->ddlQuery()) ||
+       (NOT context_->getTransaction()->autoCommit())))
     {
       // the trans mode at compile time of this query must be the
       // same as the transaction mode at execution time.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/exp/exp_datetime.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_datetime.cpp b/core/sql/exp/exp_datetime.cpp
index 456f539..deb8300 100644
--- a/core/sql/exp/exp_datetime.cpp
+++ b/core/sql/exp/exp_datetime.cpp
@@ -3445,7 +3445,8 @@ ExpDatetime::convDatetimeToASCII(char *srcData,
 
   // If the format is USA and there is an HOUR field, add AM or PM.
   //
-  if (format == DATETIME_FORMAT_USA &&
+  if (((format == DATETIME_FORMAT_USA) ||
+       (format == DATETIME_FORMAT_TS7)) &&
       startField <= REC_DATE_HOUR &&
       endField >= REC_DATE_HOUR) {
     if (militaryHour < 12) {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/generator/GenExpGenerator.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenExpGenerator.cpp b/core/sql/generator/GenExpGenerator.cpp
index c03e369..9cef6cd 100644
--- a/core/sql/generator/GenExpGenerator.cpp
+++ b/core/sql/generator/GenExpGenerator.cpp
@@ -740,7 +740,6 @@ void ExpGenerator::copyDefaultValues(
 				     ExpTupleDesc * srcTupleDesc)
 {
   Lng32 numAttrs = MINOF(srcTupleDesc->numAttrs(), tgtTupleDesc->numAttrs());
-  //  for (CollIndex i = 0; i < srcTupleDesc->numAttrs(); i++)
   for (CollIndex i = 0; i < numAttrs; i++)
     {
       Attributes * srcAttr = srcTupleDesc->getAttr(i);
@@ -753,12 +752,42 @@ void ExpGenerator::copyDefaultValues(
 
       if (srcAttr->getDefaultValue())
 	{
-	  char * tgtDefVal =
-	    new(generator->getSpace()) char[srcAttr->getDefaultValueStorageLength()];
-	  
-	  str_cpy_all(tgtDefVal, 
-		      srcAttr->getDefaultValue(), 
-		      srcAttr->getDefaultValueStorageLength());
+          Lng32 tgtDefLen = tgtAttr->getDefaultValueStorageLength();
+          Lng32 srcDefLen = srcAttr->getDefaultValueStorageLength();
+          char* srcDefVal = srcAttr->getDefaultValue();
+	  char * tgtDefVal = new(generator->getSpace()) char[tgtDefLen];
+          // if source and target def storage lengths dont match, then
+          // need to move each part (null, vclen, data) separately.
+          if (tgtDefLen != srcDefLen) 
+            {
+              char * tgtDefValCurr = tgtDefVal;
+
+              short nullVal = 0;
+              if (srcAttr->getNullFlag())
+                {
+                  str_cpy_all((char*)&nullVal, srcDefVal, 
+                              ExpTupleDesc::NULL_INDICATOR_LENGTH);
+                  srcDefVal += ExpTupleDesc::NULL_INDICATOR_LENGTH;
+                }
+              
+              if (tgtAttr->getNullFlag())
+                {
+                  str_cpy_all(tgtDefVal, (char*)&nullVal, 
+                              ExpTupleDesc::NULL_INDICATOR_LENGTH);
+                  tgtDefValCurr += ExpTupleDesc::NULL_INDICATOR_LENGTH;
+                }
+              
+              Lng32 srcDefLen    = srcAttr->getLength(srcDefVal);
+              tgtAttr->setVarLength(srcDefLen, tgtDefValCurr);
+              tgtDefValCurr += tgtAttr->getVCIndicatorLength();
+              srcDefVal += srcAttr->getVCIndicatorLength();
+
+              str_cpy_all(tgtDefValCurr, srcDefVal, srcDefLen);
+            }
+          else
+            {
+              str_cpy_all(tgtDefVal, srcDefVal, srcDefLen);
+            }
 	  
 	  tgtAttr->setDefaultValue(srcAttr->getDefaultClass(), tgtDefVal);
 	}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/generator/GenPreCode.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenPreCode.cpp b/core/sql/generator/GenPreCode.cpp
index 2752e61..66ae65f 100644
--- a/core/sql/generator/GenPreCode.cpp
+++ b/core/sql/generator/GenPreCode.cpp
@@ -58,7 +58,7 @@
 #include "CostMethod.h"
 #include "ItmFlowControlFunction.h"
 #include "UdfDllInteraction.h"
-
+#include "StmtDDLNode.h"
 
 #include "NATable.h"
 #include "NumericType.h"
@@ -2781,6 +2781,90 @@ RelExpr * ExeUtilExpr::preCodeGen(Generator * generator,
   return this;
 }
 
+// returns true if the whole ddl operation can run in one transaction
+// and transaction can be started by caller(master executor or arkcmp)
+// before executing this ddl.
+short DDLExpr::ddlXnsInfo(NABoolean &isDDLxn, NABoolean &xnCanBeStarted)
+{
+  ExprNode * ddlNode = getDDLNode();
+
+  xnCanBeStarted = TRUE;
+  // no DDL transactions.
+  if ((NOT ddlXns()) &&
+      ((dropHbase()) ||
+       (purgedataHbase()) ||
+       (initHbase()) ||
+       (createMDViews()) ||
+       (dropMDViews()) ||
+       (initAuthorization()) ||
+       (dropAuthorization()) ||
+       (addSeqTable()) ||
+       (createRepos()) ||
+       (dropRepos()) ||
+       (upgradeRepos()) ||
+       (addSchemaObjects()) ||
+       (updateVersion())))
+    {
+      // transaction will be started and commited in called methods.
+      xnCanBeStarted = FALSE;
+    }
+  
+  // no DDL transactions
+  if (((ddlNode) && (ddlNode->castToStmtDDLNode()) &&
+       (NOT ddlNode->castToStmtDDLNode()->ddlXns())) &&
+      ((ddlNode->getOperatorType() == DDL_DROP_SCHEMA) ||
+       (ddlNode->getOperatorType() == DDL_CLEANUP_OBJECTS) ||
+       (ddlNode->getOperatorType() == DDL_ALTER_TABLE_ADD_CONSTRAINT_PRIMARY_KEY) ||
+       (ddlNode->getOperatorType() == DDL_ALTER_TABLE_ALTER_COLUMN_SET_SG_OPTION) ||
+       (ddlNode->getOperatorType() == DDL_CREATE_INDEX) ||
+       (ddlNode->getOperatorType() == DDL_POPULATE_INDEX) ||
+       (ddlNode->getOperatorType() == DDL_CREATE_TABLE) ||
+       (ddlNode->getOperatorType() == DDL_ALTER_TABLE_DROP_COLUMN) ||
+       (ddlNode->getOperatorType() == DDL_ALTER_TABLE_ALTER_COLUMN_DATATYPE) ||
+       (ddlNode->getOperatorType() == DDL_DROP_TABLE)))
+    {
+      // transaction will be started and commited in called methods.
+      xnCanBeStarted = FALSE;
+    }
+
+  isDDLxn = FALSE;
+  if ((ddlXns()) || 
+      ((ddlNode && ddlNode->castToStmtDDLNode() &&
+        ddlNode->castToStmtDDLNode()->ddlXns())))
+    isDDLxn = TRUE;
+
+  // ddl transactions are on.
+  // Following commands currently require transactions be started and
+  // committed in the called methods.
+  if ((ddlXns()) &&
+      (
+           (purgedataHbase()) ||
+           (initAuthorization()) ||
+           (dropAuthorization()) ||
+           (upgradeRepos())
+       )
+      )
+    {
+      // transaction will be started and commited in called methods.
+      xnCanBeStarted = FALSE;
+    }
+
+  // ddl transactions are on.
+  // Cleanup and alter commands requires transactions to be started and commited
+  // in the called method.
+  if ((ddlNode && ddlNode->castToStmtDDLNode() &&
+       ddlNode->castToStmtDDLNode()->ddlXns()) &&
+      ((ddlNode->getOperatorType() == DDL_CLEANUP_OBJECTS) ||
+       (ddlNode->getOperatorType() == DDL_ALTER_TABLE_DROP_COLUMN) ||
+       (ddlNode->getOperatorType() == DDL_ALTER_TABLE_ALTER_COLUMN_DATATYPE)))
+    {
+      // transaction will be started and commited in called methods.
+      xnCanBeStarted = FALSE;
+    }
+
+  return 0;
+}
+
 RelExpr * DDLExpr::preCodeGen(Generator * generator,
 			      const ValueIdSet & externalInputs,
 			      ValueIdSet &pulledNewInputs)
@@ -2796,6 +2880,16 @@ RelExpr * DDLExpr::preCodeGen(Generator * generator,
       generator->setAqrEnabled(FALSE);
     }
   
+  NABoolean startXn = FALSE;
+  NABoolean ddlXns = FALSE;
+  if (ddlXnsInfo(ddlXns, startXn))
+    return NULL;
+
+  if (ddlXns && startXn)
+    xnNeeded() = TRUE;
+  else
+    xnNeeded() = FALSE;
+
   markAsPreCodeGenned();
   
   // Done.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/generator/GenRelUpdate.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenRelUpdate.cpp b/core/sql/generator/GenRelUpdate.cpp
index ec5c3b4..e7bae97 100644
--- a/core/sql/generator/GenRelUpdate.cpp
+++ b/core/sql/generator/GenRelUpdate.cpp
@@ -1080,30 +1080,6 @@ short HbaseDelete::codeGen(Generator * generator)
                                ex_expr::exp_ARITH_EXPR, &lobDelExpr);
     }
 
-#ifdef __ignore
-  ex_expr * lobDelExpr = NULL;
-  if (getTableDesc()->getNATable()->hasLobColumn())
-    {
-      // generate code to delete rows from LOB desc table
-
-      ValueIdList lobDelVIDlist;
-      for (Lng32 i = 0; i < getIndexDesc()->getIndexColumns().entries(); i++)
-        {
-	  const ValueId vid = getIndexDesc()->getIndexColumns()[i];
-          if (vid.getType().isLob())
-            {
-              ItemExpr * ld = new(generator->wHeap())
-                LOBdelete(vid.getItemExpr());
-              ld->bindNode(generator->getBindWA());
-              lobDelVIDlist.insert(ld->getValueId());
-            }
-        }
-
-      expGen->generateListExpr(lobDelVIDlist, 
-                               ex_expr::exp_ARITH_EXPR, &lobDelExpr);
-    }
-#endif
-
   ULng32 rowIdAsciiRowLen = 0; 
   ExpTupleDesc * rowIdAsciiTupleDesc = 0;
   ex_expr * rowIdExpr = NULL;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/optimizer/BindItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindItemExpr.cpp b/core/sql/optimizer/BindItemExpr.cpp
index 72fa71f..75c126f 100644
--- a/core/sql/optimizer/BindItemExpr.cpp
+++ b/core/sql/optimizer/BindItemExpr.cpp
@@ -4169,14 +4169,36 @@ ItemExpr * DateFormat::bindNode(BindWA * bindWA)
 
   if (ExpDatetime::isDateTimeFormat(frmt_))
     {
-      if (ExpDatetime::isTimestampFormat(frmt_))
+      // if DATEFORMAT function was specified, then time portion of the
+      // format depends on the operand. Date portion remains the same as
+      // what was specified (DEFAULT, USA, EUROPEAN).
+      if ((wasDateformat_) &&
+          (naType0->getTypeQualifier() == NA_DATETIME_TYPE))
+        {
+          const DatetimeType* operand = (DatetimeType *)naType0;
+          if (operand->getPrecision() == SQLDTCODE_TIMESTAMP)
+            {
+              if (frmt_ == ExpDatetime::DATETIME_FORMAT_DEFAULT)
+                frmt_ = ExpDatetime::DATETIME_FORMAT_TS3;// YYYY-MM-DD HH24:MI:SS
+              else if (frmt_ == ExpDatetime::DATETIME_FORMAT_USA)
+                frmt_ = ExpDatetime::DATETIME_FORMAT_TS7;// MM/DD/YYYY HH24:MI:SS
+              else
+                frmt_ = ExpDatetime::DATETIME_FORMAT_TS2;// DD.MM.YYYY:HH24:MI:SS
+            }
+#ifdef __ignore
+          else  if (operand->getPrecision() == SQLDTCODE_TIME)
+            frmt_ = ExpDatetime::DATETIME_FORMAT_TS4;// HH24:MI:SS
+#endif
+        }
+
+       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)
+     if (naType0->getTypeQualifier() == NA_NUMERIC_TYPE)
         {
           // convert number to char before formatting.
           // Length of target char is equal to formatStr_.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/optimizer/NARoutine.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NARoutine.cpp b/core/sql/optimizer/NARoutine.cpp
index c1cb6db..bc8c504 100644
--- a/core/sql/optimizer/NARoutine.cpp
+++ b/core/sql/optimizer/NARoutine.cpp
@@ -792,9 +792,6 @@ void NARoutineDB::resetAfterStatement()
   // to save compile-time performance.
   if (routinesToDeleteAfterStatement_.entries())
   {
-    for(CollIndex i=0; i < routinesToDeleteAfterStatement_.entries(); i++)
-      delete routinesToDeleteAfterStatement_[i];
-
     // Clear the list of tables to delete after statement
     routinesToDeleteAfterStatement_.clear();
   }
@@ -856,9 +853,9 @@ void NARoutineDB::free_entries_with_QI_key(Int32 numKeys, SQL_QIKEY* qiKeyArray)
 // propagate to all the other processes that could have the routine stored 
 // in cache.
 // ----------------------------------------------------------------------------
-void NARoutineDB::removeNARoutine(QualifiedName &routineName, 
-                                  ComQiScope qiScope, 
-                                  Int64 objUID)
+void NARoutineDB::removeNARoutine2(QualifiedName &routineName, 
+                                   ComQiScope qiScope, 
+                                   Int64 objUID)
 {
 
   NAHashDictionaryIterator<NARoutineDBKey,NARoutine> iter (*this); 
@@ -908,6 +905,44 @@ void NARoutineDB::removeNARoutine(QualifiedName &routineName,
   }
 }
 
+// This method follows the same semantics as NATableDB::removeNATable
+void NARoutineDB::removeNARoutine(QualifiedName &routineName, 
+                                  ComQiScope qiScope, 
+                                  Int64 objUID,
+                                  NABoolean ddlXns, NABoolean atCommit)
+
+{
+  if ((ddlXns) &&
+      (NOT atCommit))
+    {
+      CmpContext::DDLObjInfo ddlObj;
+      ddlObj.ddlObjName = routineName.getQualifiedNameAsString();
+      ddlObj.qiScope = qiScope;
+      ddlObj.ot = COM_USER_DEFINED_ROUTINE_OBJECT;
+      ddlObj.objUID = objUID;
+
+      NABoolean found = FALSE;
+      for (Lng32 i = 0;
+           ((NOT found) && (i <  CmpCommon::context()->ddlObjsList().entries()));
+           i++)
+        {
+          CmpContext::DDLObjInfo &ddlObjInList = 
+            CmpCommon::context()->ddlObjsList()[i];
+          if (ddlObj.ddlObjName == ddlObjInList.ddlObjName)
+            found = TRUE;
+        }
+
+      removeNARoutine2(routineName, qiScope, objUID);
+
+      if (NOT found)
+        CmpCommon::context()->ddlObjsList().insert(ddlObj);
+ 
+      return;
+    }
+
+  removeNARoutine2(routineName, qiScope, objUID);
+}
+
 // Find the NARoutine entry in the cache for 'key' or create it if not found.
 // 1. Check for entry in cache.  
 // 2. If it doesn't exist, return.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/optimizer/NARoutineDB.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NARoutineDB.h b/core/sql/optimizer/NARoutineDB.h
index 9e91e8e..68229d5 100644
--- a/core/sql/optimizer/NARoutineDB.h
+++ b/core/sql/optimizer/NARoutineDB.h
@@ -57,7 +57,9 @@ public:
   NABoolean  cachingMetaData();
   void       moveRoutineToDeleteList(NARoutine *cachedNARoutine, const NARoutineDBKey *key);
   void       free_entries_with_QI_key(Int32 numSiKeys, SQL_QIKEY* qiKeyArray);
-  void       removeNARoutine(QualifiedName &routineName, ComQiScope qiScope, Int64 objUID);
+  void       removeNARoutine2(QualifiedName &routineName, ComQiScope qiScope, Int64 objUID);
+  void       removeNARoutine(QualifiedName &routineName, ComQiScope qiScope, Int64 objUID,
+                             NABoolean ddlXns, NABoolean atCommit);
 
 
   // Defined member functions.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/optimizer/NATable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NATable.cpp b/core/sql/optimizer/NATable.cpp
index 01981db..b2128f1 100644
--- a/core/sql/optimizer/NATable.cpp
+++ b/core/sql/optimizer/NATable.cpp
@@ -8409,6 +8409,7 @@ void NATableDB::removeNATable(CorrName &corrName, ComQiScope qiScope,
       ddlObj.ddlObjName = corrName.getQualifiedNameAsString();
       ddlObj.qiScope = qiScope;
       ddlObj.ot = ot;
+      ddlObj.objUID = -1;
 
       NABoolean found = FALSE;
       for (Lng32 i = 0;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/optimizer/RelExeUtil.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelExeUtil.cpp b/core/sql/optimizer/RelExeUtil.cpp
index e1b28ca..eac65b6 100644
--- a/core/sql/optimizer/RelExeUtil.cpp
+++ b/core/sql/optimizer/RelExeUtil.cpp
@@ -4206,13 +4206,17 @@ RelExpr * DDLExpr::bindNode(BindWA *bindWA)
     else if (getExprNode()->castToStmtDDLNode()->castToStmtDDLCleanupObjects())
     {
       isCleanup_ = TRUE;
-      if (NOT Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL))
-        hbaseDDLNoUserXn_ = TRUE;
 
       returnStatus_ = 
         getExprNode()->castToStmtDDLNode()->castToStmtDDLCleanupObjects()->getStatus();
     }
 
+    if (isCleanup_) // || isRoutine_ || isLibrary_)
+      {
+        if (NOT Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL))
+          hbaseDDLNoUserXn_ = TRUE;
+      }
+
     if ((isCreateSchema || isDropSchema) ||
         ((isTable_ || isIndex_ || isView_ || isRoutine_ || isLibrary_ || isSeq) &&
          (isCreate_ || isDrop_ || purgedataHbase_ ||

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/optimizer/RelExeUtil.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelExeUtil.h b/core/sql/optimizer/RelExeUtil.h
index a2ab73d..a5ff871 100644
--- a/core/sql/optimizer/RelExeUtil.h
+++ b/core/sql/optimizer/RelExeUtil.h
@@ -391,6 +391,8 @@ public:
   NABoolean addSeqTable() { return addSeqTable_; }
   NABoolean addSchemaObjects() { return addSchemaObjects_; }
 
+  short ddlXnsInfo(NABoolean &ddlXns, NABoolean &xnCanBeStarted);
+
   NAString getQualObjName() { return qualObjName_.getQualifiedNameAsString(); }
 
   void setCreateMDViews(NABoolean v)

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/optimizer/SynthType.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/SynthType.cpp b/core/sql/optimizer/SynthType.cpp
index 16880e1..67940f7 100644
--- a/core/sql/optimizer/SynthType.cpp
+++ b/core/sql/optimizer/SynthType.cpp
@@ -2834,8 +2834,9 @@ const NAType *DateFormat::synthesizeType()
       if (wasDateformat_)
         {
 	  length = operand.getDisplayLength();
-	  if(operand.containsField(REC_DATE_HOUR) && 
-             (frmt == ExpDatetime::DATETIME_FORMAT_USA))
+          if(operand.containsField(REC_DATE_HOUR) && 
+             ((frmt == ExpDatetime::DATETIME_FORMAT_USA) ||
+              (frmt == ExpDatetime::DATETIME_FORMAT_TS7)))
 	    length += 3; // add 3 for a blank and "am" or "pm"
         }
       else

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/regress/core/EXPECTED116
----------------------------------------------------------------------
diff --git a/core/sql/regress/core/EXPECTED116 b/core/sql/regress/core/EXPECTED116
index 1128c8e..8e6f410 100644
--- a/core/sql/regress/core/EXPECTED116
+++ b/core/sql/regress/core/EXPECTED116
@@ -341,7 +341,7 @@ A1           C1           B1
 >>invoke t116t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T116T1
--- Definition current  Sun Mar 13 00:13:59 2016
+-- Definition current  Tue Mar 22 18:13:32 2016
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -359,7 +359,7 @@ A1           C1           B1
 >>invoke t116t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T116T1
--- Definition current  Sun Mar 13 00:13:59 2016
+-- Definition current  Tue Mar 22 18:13:32 2016
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -374,7 +374,7 @@ A1           C1           B1
 >>invoke t116v1;
 
 -- Definition of Trafodion view TRAFODION.SCH.T116V1
--- Definition current  Sun Mar 13 00:14:00 2016
+-- Definition current  Tue Mar 22 18:13:33 2016
 
   (
     A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -391,7 +391,7 @@ A1           C1           B1
 >>invoke t116t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T116T1
--- Definition current  Sun Mar 13 00:14:10 2016
+-- Definition current  Tue Mar 22 18:13:40 2016
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -406,7 +406,7 @@ A1           C1           B1
 >>invoke t116v1;
 
 -- Definition of Trafodion view TRAFODION.SCH.T116V1
--- Definition current  Sun Mar 13 00:14:10 2016
+-- Definition current  Tue Mar 22 18:13:41 2016
 
   (
     A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -423,7 +423,7 @@ A1           C1           B1
 >>invoke t116t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T116T1
--- Definition current  Sun Mar 13 00:14:14 2016
+-- Definition current  Tue Mar 22 18:13:44 2016
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -438,7 +438,7 @@ A1           C1           B1
 >>invoke t116v1;
 
 -- Definition of Trafodion view TRAFODION.SCH.T116V1
--- Definition current  Sun Mar 13 00:14:15 2016
+-- Definition current  Tue Mar 22 18:13:45 2016
 
   (
     A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -456,7 +456,7 @@ A1           C1           B1
 >>invoke t116t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T116T1
--- Definition current  Sun Mar 13 00:14:15 2016
+-- Definition current  Tue Mar 22 18:13:45 2016
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -471,7 +471,7 @@ A1           C1           B1
 >>invoke t116v1;
 
 -- Definition of Trafodion view TRAFODION.SCH.T116V1
--- Definition current  Sun Mar 13 00:14:15 2016
+-- Definition current  Tue Mar 22 18:13:45 2016
 
   (
     A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -488,7 +488,7 @@ A1           C1           B1
 >>invoke t116t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T116T1
--- Definition current  Sun Mar 13 00:14:25 2016
+-- Definition current  Tue Mar 22 18:13:52 2016
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -503,7 +503,7 @@ A1           C1           B1
 >>invoke t116v1;
 
 -- Definition of Trafodion view TRAFODION.SCH.T116V1
--- Definition current  Sun Mar 13 00:14:25 2016
+-- Definition current  Tue Mar 22 18:13:52 2016
 
   (
     A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -521,7 +521,7 @@ A1           C1           B1
 >>invoke t116t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T116T1
--- Definition current  Sun Mar 13 00:14:30 2016
+-- Definition current  Tue Mar 22 18:13:57 2016
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -536,7 +536,7 @@ A1           C1           B1
 >>invoke t116v1;
 
 -- Definition of Trafodion view TRAFODION.SCH.T116V1
--- Definition current  Sun Mar 13 00:14:30 2016
+-- Definition current  Tue Mar 22 18:13:58 2016
 
   (
     A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -594,7 +594,7 @@ End of MXCI Session
 >>invoke t116t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T116T1
--- Definition current  Sun Mar 13 00:14:46 2016
+-- Definition current  Tue Mar 22 18:14:15 2016
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -688,4 +688,78 @@ T116T1
 
 --- SQL operation complete.
 >>
+>>-- ddl with autocommit off
+>>set transaction autocommit off;
+
+--- SQL operation complete.
+>>drop table if exists t116t2;
+
+--- SQL operation complete.
+>>commit work;
+
+--- SQL operation complete.
+>>invoke t116t2;
+
+*** ERROR[4082] Object TRAFODION.T116SCH1.T116T2 does not exist or is inaccessible.
+
+--- SQL operation failed with errors.
+>>create table t116t2 (a int);
+
+--- SQL operation complete.
+>>invoke t116t2;
+
+-- Definition of Trafodion table TRAFODION.T116SCH1.T116T2
+-- Definition current  Tue Mar 22 18:15:37 2016
+
+  (
+    SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
+  , A                                INT DEFAULT NULL
+  )
+
+--- SQL operation complete.
+>>rollback work;
+
+--- SQL operation complete.
+>>invoke t116t2;
+
+*** ERROR[4082] Object TRAFODION.T116SCH1.T116T2 does not exist or is inaccessible.
+
+--- SQL operation failed with errors.
+>>create table t116t2 (a int);
+
+--- SQL operation complete.
+>>commit work;
+
+--- SQL operation complete.
+>>invoke t116t2;
+
+-- Definition of Trafodion table TRAFODION.T116SCH1.T116T2
+-- Definition current  Tue Mar 22 18:15:41 2016
+
+  (
+    SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
+  , A                                INT DEFAULT NULL
+  )
+
+--- SQL operation complete.
+>>-- ddl not allowed with autocommit off
+>>purgedata t116t2;
+
+*** ERROR[20124] This DDL operation cannot be performed if AUTOCOMMIT is OFF.
+
+--- SQL operation failed with errors.
+>>alter table t116t2 alter column a largeint;
+
+*** ERROR[20125] This ALTER operation cannot be performed if a user-defined transaction has been started or AUTOCOMMIT is OFF.
+
+--- SQL operation failed with errors.
+>>cleanup table t116t2;
+
+*** ERROR[20123] A user-defined transaction has been started. This DDL operation cannot be performed.
+
+--- SQL operation failed with errors.
+>>rollback work;
+
+--- SQL operation complete.
+>>
 >>log;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/regress/core/TEST116
----------------------------------------------------------------------
diff --git a/core/sql/regress/core/TEST116 b/core/sql/regress/core/TEST116
index 663a593..0755b7d 100755
--- a/core/sql/regress/core/TEST116
+++ b/core/sql/regress/core/TEST116
@@ -197,6 +197,24 @@ select count(*) from "_MD_".objects where schema_name = 'T116SCH1'
 rollback work;
 get tables in schema t116sch1;
 
+-- ddl with autocommit off
+set transaction autocommit off;
+drop table if exists t116t2;
+commit work;
+invoke t116t2;
+create table t116t2 (a int);
+invoke t116t2;
+rollback work;
+invoke t116t2;
+create table t116t2 (a int);
+commit work;
+invoke t116t2;
+-- ddl not allowed with autocommit off
+purgedata t116t2;
+alter table t116t2 alter column a largeint;
+cleanup table t116t2;
+rollback work;
+
 log;
 exit;
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/regress/seabase/EXPECTED027
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED027 b/core/sql/regress/seabase/EXPECTED027
index c4a7920..32d7038 100644
--- a/core/sql/regress/seabase/EXPECTED027
+++ b/core/sql/regress/seabase/EXPECTED027
@@ -12,7 +12,7 @@
 >>invoke t027t01;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T01
--- Definition current  Mon Mar 21 01:06:26 2016
+-- Definition current  Wed Mar 23 18:34:13 2016
 
   (
     A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -40,7 +40,7 @@ CREATE TABLE TRAFODION.SCH027.T027T01
 >>invoke t027t01;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T01
--- Definition current  Mon Mar 21 01:06:35 2016
+-- Definition current  Wed Mar 23 18:34:22 2016
 
   (
     "cf".A                           INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -69,7 +69,7 @@ CREATE TABLE TRAFODION.SCH027.T027T01
 >>invoke t027t01;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T01
--- Definition current  Mon Mar 21 01:06:41 2016
+-- Definition current  Wed Mar 23 18:34:27 2016
 
   (
     "cf".A                           INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -101,7 +101,7 @@ CREATE TABLE TRAFODION.SCH027.T027T01
 >>invoke t027t01;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T01
--- Definition current  Mon Mar 21 01:06:46 2016
+-- Definition current  Wed Mar 23 18:34:36 2016
 
   (
     "cf".A                           INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -131,7 +131,7 @@ CREATE TABLE TRAFODION.SCH027.T027T01
 >>invoke t027t01;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T01
--- Definition current  Mon Mar 21 01:06:54 2016
+-- Definition current  Wed Mar 23 18:34:38 2016
 
   (
     "cf".A                           INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -196,7 +196,7 @@ A            B            C
 >>invoke t027t01;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T01
--- Definition current  Mon Mar 21 01:06:59 2016
+-- Definition current  Wed Mar 23 18:34:44 2016
 
   (
     "cf".A                           INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -234,7 +234,7 @@ CREATE INDEX T027T01I1 ON TRAFODION.SCH027.T027T01
 >>invoke t027t01;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T01
--- Definition current  Mon Mar 21 01:07:06 2016
+-- Definition current  Wed Mar 23 18:34:47 2016
 
   (
     "cf".A                           INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -274,7 +274,7 @@ CREATE INDEX T027T01I1 ON TRAFODION.SCH027.T027T01
 >>invoke t027t01;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T01
--- Definition current  Mon Mar 21 01:07:11 2016
+-- Definition current  Wed Mar 23 18:34:52 2016
 
   (
     "cf".A                           INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -312,7 +312,7 @@ CREATE INDEX T027T01I1 ON TRAFODION.SCH027.T027T01
 >>invoke t027t01;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T01
--- Definition current  Mon Mar 21 01:07:12 2016
+-- Definition current  Wed Mar 23 18:34:53 2016
 
   (
     "cf".A                           INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -352,7 +352,7 @@ CREATE INDEX T027T01I1 ON TRAFODION.SCH027.T027T01
 >>invoke t027t011;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T011
--- Definition current  Mon Mar 21 01:07:15 2016
+-- Definition current  Wed Mar 23 18:34:56 2016
 
   (
     "cf".A                           INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -397,7 +397,7 @@ A            B            C            E            D
 >>invoke t027t011;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T011
--- Definition current  Mon Mar 21 01:07:19 2016
+-- Definition current  Wed Mar 23 18:35:00 2016
 
   (
     "cf".A                           INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -437,7 +437,7 @@ CREATE TABLE TRAFODION.SCH027.T027T011
 >>invoke t027t011;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T011
--- Definition current  Mon Mar 21 01:07:28 2016
+-- Definition current  Wed Mar 23 18:35:09 2016
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -472,7 +472,7 @@ CREATE TABLE TRAFODION.SCH027.T027T011
 >>invoke t027t011;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T011
--- Definition current  Mon Mar 21 01:07:32 2016
+-- Definition current  Wed Mar 23 18:35:14 2016
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -504,7 +504,7 @@ CREATE TABLE TRAFODION.SCH027.T027T011
 >>invoke t027t03;
 
 -- Definition of Trafodion volatile table T027T03
--- Definition current  Mon Mar 21 01:07:38 2016
+-- Definition current  Wed Mar 23 18:35:20 2016
 
   (
     "cf1".A                          INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -536,7 +536,7 @@ CREATE VOLATILE TABLE T027T03
 >>invoke t027t03;
 
 -- Definition of Trafodion volatile table T027T03
--- Definition current  Mon Mar 21 01:07:58 2016
+-- Definition current  Wed Mar 23 18:35:41 2016
 
   (
     "cf1".A                          INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -585,7 +585,7 @@ CREATE VOLATILE TABLE T027T03
 >>invoke t027t02;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T02
--- Definition current  Mon Mar 21 01:08:18 2016
+-- Definition current  Wed Mar 23 18:36:01 2016
 
   (
     "cf".SYSKEY                      LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -637,7 +637,7 @@ CREATE VOLATILE TABLE T027T03
 >>invoke t027t03;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T03
--- Definition current  Mon Mar 21 01:08:40 2016
+-- Definition current  Wed Mar 23 18:36:22 2016
 
   (
     "cf1".A                          INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -674,7 +674,7 @@ A            B            C            D
 >>invoke t027t02;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T02
--- Definition current  Mon Mar 21 01:08:53 2016
+-- Definition current  Wed Mar 23 18:36:34 2016
 
   (
     OBJECT_UID                       LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -787,7 +787,7 @@ create index t027t01i2 on t027t01("cf2".b);
 >>invoke t027t7;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T7
--- Definition current  Mon Mar 21 01:09:19 2016
+-- Definition current  Wed Mar 23 18:36:59 2016
 
   (
     A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -819,7 +819,7 @@ A            B   C                 Z
 >>invoke t027t7;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T7
--- Definition current  Mon Mar 21 01:09:28 2016
+-- Definition current  Wed Mar 23 18:37:07 2016
 
   (
     A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -840,7 +840,7 @@ A            B   C                 Z
 >>invoke t027t7;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T7
--- Definition current  Mon Mar 21 01:09:51 2016
+-- Definition current  Wed Mar 23 18:37:28 2016
 
   (
     A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -861,7 +861,7 @@ A            B   C                 Z
 >>invoke t027t7;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T7
--- Definition current  Mon Mar 21 01:10:14 2016
+-- Definition current  Wed Mar 23 18:37:50 2016
 
   (
     A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -883,7 +883,7 @@ A            B   C                 Z
 >>invoke t027t7;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T7
--- Definition current  Mon Mar 21 01:10:35 2016
+-- Definition current  Wed Mar 23 18:38:10 2016
 
   (
     A                                LARGEINT DEFAULT NULL /*altered_col*/
@@ -904,7 +904,7 @@ A            B   C                 Z
 >>invoke t027t7;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T7
--- Definition current  Mon Mar 21 01:10:55 2016
+-- Definition current  Wed Mar 23 18:38:39 2016
 
   (
     A                                LARGEINT DEFAULT NULL /*altered_col*/
@@ -925,7 +925,7 @@ A            B   C                 Z
 >>invoke t027t7;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T7
--- Definition current  Mon Mar 21 01:11:16 2016
+-- Definition current  Wed Mar 23 18:39:01 2016
 
   (
     A                                LARGEINT DEFAULT NULL /*altered_col*/
@@ -946,7 +946,7 @@ A            B   C                 Z
 >>invoke t027t7;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T7
--- Definition current  Mon Mar 21 01:11:35 2016
+-- Definition current  Wed Mar 23 18:39:27 2016
 
   (
     A                                LARGEINT DEFAULT NULL /*altered_col*/
@@ -967,7 +967,7 @@ A            B   C                 Z
 >>invoke t027t7;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T7
--- Definition current  Mon Mar 21 01:12:03 2016
+-- Definition current  Wed Mar 23 18:39:49 2016
 
   (
     A                                INT DEFAULT NULL /*altered_col*/
@@ -988,7 +988,7 @@ A            B   C                 Z
 >>invoke t027t7;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T7
--- Definition current  Mon Mar 21 01:12:26 2016
+-- Definition current  Wed Mar 23 18:40:08 2016
 
   (
     A                                SMALLINT DEFAULT 0 NOT NULL NOT DROPPABLE
@@ -1025,7 +1025,7 @@ A       B   C       Z
 >>invoke t027t7;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T7
--- Definition current  Mon Mar 21 01:12:50 2016
+-- Definition current  Wed Mar 23 18:40:31 2016
 
   (
     A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -1057,7 +1057,7 @@ A            B   C                 Z
 >>invoke t027t7;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T7
--- Definition current  Mon Mar 21 01:13:16 2016
+-- Definition current  Wed Mar 23 18:40:57 2016
 
   (
     A                                LARGEINT DEFAULT NULL /*altered_col*/
@@ -1086,7 +1086,7 @@ A                     B   C                 Z
 >>invoke t027t7;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T7
--- Definition current  Mon Mar 21 01:13:44 2016
+-- Definition current  Wed Mar 23 18:41:27 2016
 
   (
     A                                LARGEINT DEFAULT NULL /*altered_col*/
@@ -1113,7 +1113,7 @@ A                     C                 Z
 >>invoke t027t7;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T7
--- Definition current  Mon Mar 21 01:13:51 2016
+-- Definition current  Wed Mar 23 18:41:30 2016
 
   (
     A                                LARGEINT DEFAULT NULL /*altered_col*/
@@ -1142,7 +1142,7 @@ A                     C                 Z            B
 >>invoke t027t7;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T7
--- Definition current  Mon Mar 21 01:14:16 2016
+-- Definition current  Wed Mar 23 18:42:00 2016
 
   (
     A                                LARGEINT DEFAULT NULL /*altered_col*/
@@ -1177,7 +1177,7 @@ SCH027.T027V1
 >>invoke t027v1;
 
 -- Definition of Trafodion view TRAFODION.SCH027.T027V1
--- Definition current  Mon Mar 21 01:14:24 2016
+-- Definition current  Wed Mar 23 18:42:07 2016
 
   (
     A                                LARGEINT DEFAULT NULL
@@ -1193,7 +1193,7 @@ SCH027.T027V1
 >>invoke t027v1;
 
 -- Definition of Trafodion view TRAFODION.SCH027.T027V1
--- Definition current  Mon Mar 21 01:14:58 2016
+-- Definition current  Wed Mar 23 18:42:42 2016
 
   (
     A                                SMALLINT DEFAULT NULL
@@ -1266,7 +1266,7 @@ SCH027.T027V1
 >>invoke t027t7;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T7
--- Definition current  Mon Mar 21 01:17:02 2016
+-- Definition current  Wed Mar 23 18:44:39 2016
 
   (
     A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -1295,7 +1295,7 @@ A            B   C                 Z
 >>invoke t027t7;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T7
--- Definition current  Mon Mar 21 01:17:13 2016
+-- Definition current  Wed Mar 23 18:44:53 2016
 
   (
     A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -1324,7 +1324,7 @@ A            BB  C                 Z
 >>invoke t027t7;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T7
--- Definition current  Mon Mar 21 01:17:28 2016
+-- Definition current  Wed Mar 23 18:45:04 2016
 
   (
     A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -1455,31 +1455,23 @@ SCH027.T027V122
 --- SQL operation complete.
 >>alter table t027t7 drop column b;
 
-*** ERROR[20123] A user-defined transaction has been started. ALTER cannot be performed.
-
-*** ERROR[8839] Transaction was aborted.
+*** ERROR[20125] This ALTER operation cannot be performed if a user-defined transaction has been started or AUTOCOMMIT is OFF.
 
 --- SQL operation failed with errors.
 >>rollback work;
 
-*** ERROR[8609] Waited rollback performed without starting a transaction.
-
---- SQL operation failed with errors.
+--- SQL operation complete.
 >>begin work;
 
 --- SQL operation complete.
 >>alter table t027t7 alter column b largeint;
 
-*** ERROR[20123] A user-defined transaction has been started. ALTER cannot be performed.
-
-*** ERROR[8839] Transaction was aborted.
+*** ERROR[20125] This ALTER operation cannot be performed if a user-defined transaction has been started or AUTOCOMMIT is OFF.
 
 --- SQL operation failed with errors.
 >>rollback work;
 
-*** ERROR[8609] Waited rollback performed without starting a transaction.
-
---- SQL operation failed with errors.
+--- SQL operation complete.
 >>
 >>-- reserved words cannot be used as colnames in create/add/alter stmts
 >>drop table if exists t027t7 cascade;
@@ -1534,7 +1526,7 @@ SCH027.T027V122
 >>invoke t027t7;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T7
--- Definition current  Mon Mar 21 01:21:43 2016
+-- Definition current  Wed Mar 23 18:49:16 2016
 
   (
     SYSKEY                           INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -1558,7 +1550,7 @@ SCH027.T027V122
 >>invoke t027t1;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T1
--- Definition current  Mon Mar 21 01:21:53 2016
+-- Definition current  Wed Mar 23 18:49:29 2016
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -1589,7 +1581,7 @@ A            B            C            D            E            F            G
 >>invoke t027t1;
 
 -- Definition of Trafodion table TRAFODION.SCH027.T027T1
--- Definition current  Mon Mar 21 01:22:00 2016
+-- Definition current  Wed Mar 23 18:49:36 2016
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/regress/seabase/EXPECTED030
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED030 b/core/sql/regress/seabase/EXPECTED030
index 3d85727..94b6790 100644
--- a/core/sql/regress/seabase/EXPECTED030
+++ b/core/sql/regress/seabase/EXPECTED030
@@ -434,28 +434,44 @@ March 01, 2016, 10:11:12
 10.11.12
 
 --- 1 row(s) selected.
+>>select dateformat(time '10:11:12.12', usa) from (values(1)) x(a);
+
+(EXPR)        
+--------------
+
+10:11:12.12 AM
+
+--- 1 row(s) selected.
 >>select dateformat(timestamp '2016-03-01 10:11:12.1', default) from (values(1)) x(a);
 
-(EXPR)    
-----------
+(EXPR)               
+---------------------
 
-2016-03-01
+2016-03-01 10:11:12.1
 
 --- 1 row(s) selected.
 >>select dateformat(timestamp '2016-03-01 10:11:12', usa) from (values(1)) x(a);
 
-(EXPR)    
-----------
+(EXPR)             
+-------------------
 
-03/01/2016
+03/01/2016 10:11:12
 
 --- 1 row(s) selected.
 >>select dateformat(timestamp '2016-03-01 10:11:12.123', european) from (values(1)) x(a);
 
-(EXPR)    
-----------
+(EXPR)                 
+-----------------------
 
-01.03.2016
+01.03.2016:10:11:12.123
+
+--- 1 row(s) selected.
+>>select dateformat(timestamp '2016-03-01 10:11:12.12', usa) from (values(1)) x(a);
+
+(EXPR)                   
+-------------------------
+
+03/01/2016 10:11:12.12 AM
 
 --- 1 row(s) selected.
 >>

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/regress/seabase/EXPECTED031
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED031 b/core/sql/regress/seabase/EXPECTED031
index 5d0ea78..6b0951f 100644
--- a/core/sql/regress/seabase/EXPECTED031
+++ b/core/sql/regress/seabase/EXPECTED031
@@ -211,4 +211,28 @@ ID           TIME1     TIME2     TYPE1     TYPE2  DIFF
 
 --- 1 row(s) selected.
 >>
+>>-- varchar default values were not being handled correctly
+>>drop table if exists t031t1;
+
+--- SQL operation complete.
+>>create  table t031t1 (a varchar(6) not null default 'ABC',
++>                      b varchar(6) default 'ABC');
+
+--- SQL operation complete.
+>>insert into t031t1 default values;
+
+--- 1 row(s) inserted.
+>>upsert into t031t1 default values;
+
+--- 1 row(s) inserted.
+>>select * from t031t1;
+
+A       B     
+------  ------
+
+ABC     ABC   
+ABC     ABC   
+
+--- 2 row(s) selected.
+>>
 >>log;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/regress/seabase/TEST030
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST030 b/core/sql/regress/seabase/TEST030
index 62d5a0b..aff9c7c 100644
--- a/core/sql/regress/seabase/TEST030
+++ b/core/sql/regress/seabase/TEST030
@@ -81,9 +81,11 @@ select to_char(TIMESTAMP '2016-03-01 10:11:12', 'HH:MI:SS') from (values(1)) x(a
 select dateformat(time '10:11:12.1', default) from (values(1)) x(a);
 select dateformat(time '10:11:12.123', usa) from (values(1)) x(a);
 select dateformat(time '10:11:12', european) from (values(1)) x(a);
+select dateformat(time '10:11:12.12', usa) from (values(1)) x(a);
 select dateformat(timestamp '2016-03-01 10:11:12.1', default) from (values(1)) x(a);
 select dateformat(timestamp '2016-03-01 10:11:12', usa) from (values(1)) x(a);
 select dateformat(timestamp '2016-03-01 10:11:12.123', european) from (values(1)) x(a);
+select dateformat(timestamp '2016-03-01 10:11:12.12', usa) from (values(1)) x(a);
 
 drop table if exists t030t1;
 create table t030t1 (a date, b char(30), c varchar(30));

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/regress/seabase/TEST031
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST031 b/core/sql/regress/seabase/TEST031
index 5265339..c52a3fe 100644
--- a/core/sql/regress/seabase/TEST031
+++ b/core/sql/regress/seabase/TEST031
@@ -105,4 +105,12 @@ from t031t1
 where id = 1;
 select * from t031t1;
 
+-- varchar default values were not being handled correctly
+drop table if exists t031t1;
+create  table t031t1 (a varchar(6) not null default 'ABC',
+                      b varchar(6) default 'ABC');
+insert into t031t1 default values;
+upsert into t031t1 default values;
+select * from t031t1;
+
 log;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/regress/udr/TEST100
----------------------------------------------------------------------
diff --git a/core/sql/regress/udr/TEST100 b/core/sql/regress/udr/TEST100
index cedb778..f3f5c32 100755
--- a/core/sql/regress/udr/TEST100
+++ b/core/sql/regress/udr/TEST100
@@ -75,6 +75,7 @@ obey TEST100(java_compile);
 obey TEST100(set_up);
 obey TEST100(tests);
 log;
+exit;
 obey TEST100(clean_up_procs);
 obey TEST100(clean_up_tables);
 obey TEST100(clean_up_files);

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp
index 6ca1586..59c3d94 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp
@@ -1748,7 +1748,8 @@ void CmpSeabaseMDcleanup::cleanupObjects(StmtDDLCleanupObjects * stmtCleanupNode
   if ((xnInProgress(&cliInterface)) &&
       (!Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)))
      {
-      *CmpCommon::diags() << DgSqlCode(-20123);
+       *CmpCommon::diags() << DgSqlCode(-20125)
+                           << DgString0("This CLEANUP");
       return;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
index c17b5ed..b5479a9 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
@@ -2084,7 +2084,7 @@ short CmpSeabaseDDL::ddlInvalidateNATables()
       NAString &ddlObjName = ddlObj.ddlObjName;
       ComQiScope &qiScope = ddlObj.qiScope;
       ComObjectType &ot = ddlObj.ot;
-
+      Int64 objUID = ddlObj.objUID;
       ComObjectName tableName(ddlObjName);
       
       const NAString catalogNamePart = 
@@ -2095,8 +2095,13 @@ short CmpSeabaseDDL::ddlInvalidateNATables()
         tableName.getObjectNamePartAsAnsiString(TRUE);
       
       CorrName cn(objectNamePart, STMTHEAP, schemaNamePart, catalogNamePart);
-      
-      ActiveSchemaDB()->getNATableDB()->removeNATable(cn, qiScope, ot, TRUE, TRUE);
+
+      if (ot == COM_USER_DEFINED_ROUTINE_OBJECT)
+        ActiveSchemaDB()->getNARoutineDB()->removeNARoutine(
+             cn.getQualifiedNameObj(), 
+             qiScope, objUID, TRUE, TRUE);
+      else
+        ActiveSchemaDB()->getNATableDB()->removeNATable(cn, qiScope, ot, TRUE, TRUE);
     }
 
   return 0;
@@ -8424,80 +8429,10 @@ short CmpSeabaseDDL::executeSeabaseDDL(DDLExpr * ddlExpr, ExprNode * ddlNode,
          }
     }
 
-  NABoolean startXn = TRUE;
-  // no DDL transactions.
-  if ((NOT ddlExpr->ddlXns()) &&
-      ((ddlExpr->dropHbase()) ||
-       (ddlExpr->purgedataHbase()) ||
-       (ddlExpr->initHbase()) ||
-       (ddlExpr->createMDViews()) ||
-       (ddlExpr->dropMDViews()) ||
-       (ddlExpr->initAuthorization()) ||
-       (ddlExpr->dropAuthorization()) ||
-       (ddlExpr->addSeqTable()) ||
-       (ddlExpr->createRepos()) ||
-       (ddlExpr->dropRepos()) ||
-       (ddlExpr->upgradeRepos()) ||
-       (ddlExpr->addSchemaObjects()) ||
-       (ddlExpr->updateVersion())))
-    {
-      // transaction will be started and commited in called methods.
-      startXn = FALSE;
-    }
-  
-  // no DDL transactions
-  if (((ddlNode) && (ddlNode->castToStmtDDLNode()) &&
-       (NOT ddlNode->castToStmtDDLNode()->ddlXns())) &&
-      ((ddlNode->getOperatorType() == DDL_DROP_SCHEMA) ||
-       (ddlNode->getOperatorType() == DDL_CLEANUP_OBJECTS) ||
-       (ddlNode->getOperatorType() == DDL_ALTER_TABLE_ADD_CONSTRAINT_PRIMARY_KEY) ||
-       (ddlNode->getOperatorType() == DDL_ALTER_TABLE_ALTER_COLUMN_SET_SG_OPTION) ||
-       (ddlNode->getOperatorType() == DDL_CREATE_INDEX) ||
-       (ddlNode->getOperatorType() == DDL_POPULATE_INDEX) ||
-       (ddlNode->getOperatorType() == DDL_CREATE_TABLE) ||
-       (ddlNode->getOperatorType() == DDL_ALTER_TABLE_DROP_COLUMN) ||
-       (ddlNode->getOperatorType() == DDL_ALTER_TABLE_ALTER_COLUMN_DATATYPE) ||
-       //       (ddlNode->getOperatorType() == DDL_ALTER_TABLE_ALTER_COLUMN_RENAME) ||
-       (ddlNode->getOperatorType() == DDL_DROP_TABLE)))
-    {
-      // transaction will be started and commited in called methods.
-      startXn = FALSE;
-    }
-
+  NABoolean startXn = FALSE;
   NABoolean ddlXns = FALSE;
-  if ((ddlExpr->ddlXns()) || 
-      ((ddlNode && ddlNode->castToStmtDDLNode() &&
-        ddlNode->castToStmtDDLNode()->ddlXns())))
-    ddlXns = TRUE;
-
-  // ddl transactions are on.
-  // Following commands currently require transactions be started and
-  // committed in the called methods.
-  if ((ddlExpr->ddlXns()) &&
-      (
-           (ddlExpr->purgedataHbase()) ||
-           (ddlExpr->initAuthorization()) ||
-           (ddlExpr->dropAuthorization()) ||
-           (ddlExpr->upgradeRepos())
-       )
-      )
-    {
-      // transaction will be started and commited in called methods.
-      startXn = FALSE;
-    }
-
-  // ddl transactions are on.
-  // Cleanup and alter commands requires transactions to be started and commited
-  // in the called method.
-  if ((ddlNode && ddlNode->castToStmtDDLNode() &&
-       ddlNode->castToStmtDDLNode()->ddlXns()) &&
-      ((ddlNode->getOperatorType() == DDL_CLEANUP_OBJECTS) ||
-       (ddlNode->getOperatorType() == DDL_ALTER_TABLE_DROP_COLUMN) ||
-       (ddlNode->getOperatorType() == DDL_ALTER_TABLE_ALTER_COLUMN_DATATYPE)))
-    {
-      // transaction will be started and commited in called methods.
-      startXn = FALSE;
-    }
+  if (ddlExpr->ddlXnsInfo(ddlXns, startXn))
+    return -1;
   
   if (startXn)
     {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp b/core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp
index 5f29264..28609e9 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp
@@ -543,8 +543,9 @@ void CmpSeabaseDDL::dropSeabaseLibrary(StmtDDLDropLibrary * dropLibraryNode,
        Int64 routineUID = *(Int64*)rou->get(2);
        pRoutineDBCache->removeNARoutine(qualRoutineName,
                                         ComQiScope::REMOVE_FROM_ALL_USERS,
-                                        routineUID);
-    }
+                                        routineUID,
+                                        dropLibraryNode->ddlXns(), FALSE);
+     }
 
    }
  
@@ -1326,7 +1327,8 @@ void CmpSeabaseDDL::dropSeabaseRoutine(StmtDDLDropRoutine * dropRoutineNode,
   // Remove cached entries in other processes
   pRoutineDBCache->removeNARoutine(qualRoutineName, 
                                    ComQiScope::REMOVE_FROM_ALL_USERS,
-                                   objUID);
+                                   objUID,
+                                   dropRoutineNode->ddlXns(), FALSE);
 
   deallocEHI(ehi);      
   processReturn();

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/236e26d3/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
index 5b9174d..20971a5 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
@@ -4746,6 +4746,22 @@ void CmpSeabaseDDL::alterSeabaseTableAddColumn(
      ComQiScope::REMOVE_FROM_ALL_USERS, COM_BASE_TABLE_OBJECT,
      alterAddColNode->ddlXns(), FALSE);
 
+  if (alterAddColNode->getAddConstraintPK())
+    {
+      // if table already has a primary key, return error.
+      if ((naTable->getClusteringIndex()) && 
+          (NOT naTable->getClusteringIndex()->hasOnlySyskey()))
+        {
+          *CmpCommon::diags()
+            << DgSqlCode(-1256)
+            << DgString0(extTableName);
+          
+          processReturn();
+          
+          return;
+        }
+    }
+  
   if ((alterAddColNode->getAddConstraintPK()) OR
       (alterAddColNode->getAddConstraintCheckArray().entries() NEQ 0) OR
       (alterAddColNode->getAddConstraintUniqueArray().entries() NEQ 0) OR
@@ -5346,8 +5362,8 @@ void CmpSeabaseDDL::alterSeabaseTableDropColumn(
   // this operation cannot be done if a xn is already in progress.
   if (xnInProgress(&cliInterface))
     {
-      *CmpCommon::diags() << DgSqlCode(-20123)
-                          << DgString0("ALTER");
+      *CmpCommon::diags() << DgSqlCode(-20125)
+                          << DgString0("This ALTER");
       
       processReturn();
       return;
@@ -6433,8 +6449,8 @@ void CmpSeabaseDDL::alterSeabaseTableAlterColumnDatatype(
   // this operation cannot be done if a xn is already in progress.
   if ((NOT mdAlterOnly) && (xnInProgress(&cliInterface)))
     {
-      *CmpCommon::diags() << DgSqlCode(-20123)
-                          << DgString0("ALTER");
+      *CmpCommon::diags() << DgSqlCode(-20125)
+                          << DgString0("This ALTER");
 
       processReturn();
       return;


Mime
View raw message