Repository: incubator-trafodion
Updated Branches:
  refs/heads/master 98b00b625 -> 71c2d35af


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/19c96b1e/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp 
b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
index f30bdb6..9454a97 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
@@ -53,6 +53,8 @@
 #include "PrivMgrRoles.h"
 #include "PrivMgrComponentPrivileges.h"
 
+#include "TrafDDLdesc.h"
+
 // defined in CmpDescribe.cpp
 extern short CmpDescribeSeabaseTable ( 
                              const CorrName  &dtName,
@@ -129,97 +131,90 @@ static bool isValidPrivTypeForObject(
 void CmpSeabaseDDL::convertVirtTableColumnInfoToDescStruct( 
      const ComTdbVirtTableColumnInfo * colInfo,
      const ComObjectName * objectName,
-     desc_struct * column_desc)
+     TrafDesc * column_desc)
 {
-  column_desc->body.columns_desc.tablename = 
-    convertNAString(objectName->getExternalName(), STMTHEAP);
-  
   char * col_name = new(STMTHEAP) char[strlen(colInfo->colName) + 1];
   strcpy(col_name, colInfo->colName);
-  column_desc->body.columns_desc.colname = col_name;
-  column_desc->body.columns_desc.colnumber = colInfo->colNumber;
-  column_desc->body.columns_desc.datatype  = colInfo->datatype;
-  column_desc->body.columns_desc.length    = colInfo->length;
+  column_desc->columnsDesc()->colname = col_name;
+  column_desc->columnsDesc()->colnumber = colInfo->colNumber;
+  column_desc->columnsDesc()->datatype  = colInfo->datatype;
+  column_desc->columnsDesc()->length    = colInfo->length;
   if (!(DFS2REC::isInterval(colInfo->datatype)))
-    column_desc->body.columns_desc.scale     = colInfo->scale;
+    column_desc->columnsDesc()->scale     = colInfo->scale;
   else
-    column_desc->body.columns_desc.scale = 0;
-  column_desc->body.columns_desc.precision = colInfo->precision;
-  column_desc->body.columns_desc.datetimestart = (rec_datetime_field) 
colInfo->dtStart;
-  column_desc->body.columns_desc.datetimeend = (rec_datetime_field) 
colInfo->dtEnd;
+    column_desc->columnsDesc()->scale = 0;
+  column_desc->columnsDesc()->precision = colInfo->precision;
+  column_desc->columnsDesc()->datetimestart = (rec_datetime_field) 
colInfo->dtStart;
+  column_desc->columnsDesc()->datetimeend = (rec_datetime_field) 
colInfo->dtEnd;
   if (DFS2REC::isDateTime(colInfo->datatype) || 
DFS2REC::isInterval(colInfo->datatype))
-    column_desc->body.columns_desc.datetimefractprec = colInfo->scale;
+    column_desc->columnsDesc()->datetimefractprec = colInfo->scale;
   else
-    column_desc->body.columns_desc.datetimefractprec = 0;
+    column_desc->columnsDesc()->datetimefractprec = 0;
   if (DFS2REC::isInterval(colInfo->datatype))
-    column_desc->body.columns_desc.intervalleadingprec = colInfo->precision;
+    column_desc->columnsDesc()->intervalleadingprec = colInfo->precision;
   else
-    column_desc->body.columns_desc.intervalleadingprec = 0 ;
-  column_desc->body.columns_desc.null_flag = colInfo->nullable;
-  column_desc->body.columns_desc.upshift   = colInfo->upshifted;
-  column_desc->body.columns_desc.character_set = (CharInfo::CharSet) 
colInfo->charset;
+    column_desc->columnsDesc()->intervalleadingprec = 0 ;
+  column_desc->columnsDesc()->setNullable(colInfo->nullable);
+  column_desc->columnsDesc()->setUpshifted(colInfo->upshifted);
+  column_desc->columnsDesc()->character_set = (CharInfo::CharSet) 
colInfo->charset;
   switch (colInfo->columnClass)
     {
     case COM_USER_COLUMN:
-      column_desc->body.columns_desc.colclass = 'U';
+      column_desc->columnsDesc()->colclass = 'U';
       break;
     case COM_SYSTEM_COLUMN:
-      column_desc->body.columns_desc.colclass = 'S';
+      column_desc->columnsDesc()->colclass = 'S';
       break;
     default:
       CMPASSERT(0);
     }
-  column_desc->body.columns_desc.defaultClass = colInfo->defaultClass;
-  column_desc->body.columns_desc.colFlags = colInfo->colFlags;
+  column_desc->columnsDesc()->setDefaultClass(colInfo->defaultClass);
+  column_desc->columnsDesc()->colFlags = colInfo->colFlags;
   
   
-  column_desc->body.columns_desc.pictureText =
+  column_desc->columnsDesc()->pictureText =
     (char *)STMTHEAP->allocateMemory(340);
-  NAType::convertTypeToText(column_desc->body.columns_desc.pictureText,  //OUT
-                            column_desc->body.columns_desc.datatype,
-                            column_desc->body.columns_desc.length,
-                            column_desc->body.columns_desc.precision,
-                            column_desc->body.columns_desc.scale,
-                            column_desc->body.columns_desc.datetimestart,
-                            column_desc->body.columns_desc.datetimeend,
-                            column_desc->body.columns_desc.datetimefractprec,
-                            column_desc->body.columns_desc.intervalleadingprec,
-                            column_desc->body.columns_desc.upshift,
-                            column_desc->body.columns_desc.caseinsensitive,
-                            
(CharInfo::CharSet)column_desc->body.columns_desc.character_set,
+  NAType::convertTypeToText(column_desc->columnsDesc()->pictureText,  //OUT
+                            column_desc->columnsDesc()->datatype,
+                            column_desc->columnsDesc()->length,
+                            column_desc->columnsDesc()->precision,
+                            column_desc->columnsDesc()->scale,
+                            column_desc->columnsDesc()->datetimeStart(),
+                            column_desc->columnsDesc()->datetimeEnd(),
+                            column_desc->columnsDesc()->datetimefractprec,
+                            column_desc->columnsDesc()->intervalleadingprec,
+                            column_desc->columnsDesc()->isUpshifted(),
+                            column_desc->columnsDesc()->isCaseInsensitive(),
+                            
(CharInfo::CharSet)column_desc->columnsDesc()->character_set,
                             (CharInfo::Collation) 1, // default collation
                             NULL, // displayDataType
                             0); // displayCaseSpecific
   
 
-  column_desc->body.columns_desc.offset    = -1; // not present in colInfo
-  column_desc->body.columns_desc.caseinsensitive = (short)FALSE; // not 
present in colInfo
-  column_desc->body.columns_desc.encoding_charset = (CharInfo::CharSet) 
column_desc->body.columns_desc.character_set ; // not present in colInfo so we 
go with the column's charset here. 
-  column_desc->body.columns_desc.collation_sequence = (CharInfo::Collation)1; 
// not present in colInfo, so we go with default collation here (used in 
buildEncodeTree for some error handling)
-  column_desc->body.columns_desc.uec     = (Cardinality)0; // not present in 
colInfo
-  column_desc->body.columns_desc.highval = 0; // not present in colInfo
-  column_desc->body.columns_desc.lowval  = 0; // not present in colInfo
-  column_desc->body.columns_desc.defaultvalue = NULL ; // not present in 
colInfo
-  column_desc->body.columns_desc.stored_on_disk = 0 ; // not present in colInfo
-  column_desc->body.columns_desc.computed_column_text = NULL; // not present 
in colInfo
+  column_desc->columnsDesc()->offset    = -1; // not present in colInfo
+  column_desc->columnsDesc()->setCaseInsensitive(FALSE); // not present in 
colInfo
+  column_desc->columnsDesc()->encoding_charset = (CharInfo::CharSet) 
column_desc->columnsDesc()->character_set ; // not present in colInfo so we go 
with the column's charset here. 
+  column_desc->columnsDesc()->collation_sequence = (CharInfo::Collation)1; // 
not present in colInfo, so we go with default collation here (used in 
buildEncodeTree for some error handling)
+  column_desc->columnsDesc()->defaultvalue = NULL ; // not present in colInfo
+  column_desc->columnsDesc()->computed_column_text = NULL; // not present in 
colInfo
 }
 
-desc_struct * CmpSeabaseDDL::convertVirtTableColumnInfoArrayToDescStructs(
+TrafDesc * CmpSeabaseDDL::convertVirtTableColumnInfoArrayToDescStructs(
      const ComObjectName * objectName,
      const ComTdbVirtTableColumnInfo * colInfoArray,
      Lng32 numCols)
 {
-  desc_struct * prev_column_desc  = NULL;
-  desc_struct * first_column_desc = NULL;
+  TrafDesc * prev_column_desc  = NULL;
+  TrafDesc * first_column_desc = NULL;
   for (Int32 i = 0; i < numCols; i++)
   {
     const ComTdbVirtTableColumnInfo* colInfo = &(colInfoArray[i]);
 
-    // readtabledef_allocate_desc() requires that HEAP (STMTHEAP) 
+    // TrafAllocateDDLdesc() requires that HEAP (STMTHEAP) 
     // be used for operator new herein
-    desc_struct * column_desc = readtabledef_allocate_desc(DESC_COLUMNS_TYPE);
+    TrafDesc * column_desc = TrafAllocateDDLdesc(DESC_COLUMNS_TYPE, NULL);
     if (prev_column_desc != NULL)
-      prev_column_desc->header.next = column_desc;
+      prev_column_desc->next = column_desc;
     else
       first_column_desc = column_desc;      
     
@@ -230,27 +225,27 @@ desc_struct * 
CmpSeabaseDDL::convertVirtTableColumnInfoArrayToDescStructs(
   return first_column_desc;
 }
 
-desc_struct * CmpSeabaseDDL::convertVirtTableKeyInfoArrayToDescStructs(
+TrafDesc * CmpSeabaseDDL::convertVirtTableKeyInfoArrayToDescStructs(
      const ComTdbVirtTableKeyInfo *keyInfoArray,
      const ComTdbVirtTableColumnInfo *colInfoArray,
      Lng32 numKeys)
 {
-  desc_struct * prev_key_desc  = NULL;
-  desc_struct * first_key_desc = NULL;
+  TrafDesc * prev_key_desc  = NULL;
+  TrafDesc * first_key_desc = NULL;
   for (Int32 i = 0; i < numKeys; i++)
     {
       const ComTdbVirtTableColumnInfo * colInfo = 
&(colInfoArray[keyInfoArray[i].tableColNum]);
-      desc_struct * key_desc = readtabledef_allocate_desc(DESC_KEYS_TYPE);
+      TrafDesc * key_desc = TrafAllocateDDLdesc(DESC_KEYS_TYPE, NULL);
       if (prev_key_desc != NULL)
-        prev_key_desc->header.next = key_desc;
+        prev_key_desc->next = key_desc;
       else
        first_key_desc = key_desc;      
       
       prev_key_desc = key_desc;
       
-      key_desc->body.keys_desc.tablecolnumber = keyInfoArray[i].tableColNum;
-      key_desc->body.keys_desc.keyseqnumber = i;
-      key_desc->body.keys_desc.ordering = keyInfoArray[i].ordering;
+      key_desc->keysDesc()->tablecolnumber = keyInfoArray[i].tableColNum;
+      key_desc->keysDesc()->keyseqnumber = i;
+      key_desc->keysDesc()->setDescending(keyInfoArray[i].ordering == -1 ? 
TRUE : FALSE);
     }
 
   return first_key_desc;
@@ -1451,7 +1446,8 @@ short CmpSeabaseDDL::createSeabaseTable2(
                                          ExeCliInterface &cliInterface,
                                          StmtDDLCreateTable * createTableNode,
                                          NAString &currCatName, NAString 
&currSchName,
-                                         NABoolean isCompound)
+                                         NABoolean isCompound,
+                                         Int64 &outObjUID)
 {
   Lng32 retcode = 0;
   Lng32 cliRC = 0;
@@ -2039,11 +2035,11 @@ short CmpSeabaseDDL::createSeabaseTable2(
   char ** encodedKeysBuffer = NULL;
   if (numSplits > 0) {
 
-    desc_struct * colDescs = 
+    TrafDesc * colDescs = 
       convertVirtTableColumnInfoArrayToDescStructs(&tableName,
                                                    colInfoArray,
                                                    numCols) ;
-    desc_struct * keyDescs = 
+    TrafDesc * keyDescs = 
       convertVirtTableKeyInfoArrayToDescStructs(keyInfoArray,
                                                 colInfoArray,
                                                 numKeys) ;
@@ -2167,6 +2163,8 @@ short CmpSeabaseDDL::createSeabaseTable2(
       return -1;
     }
 
+  outObjUID = objUID;
+
   // update TEXT table with column families.
   // Column families are stored separated by a blank space character.
   NAString allColFams;
@@ -2440,18 +2438,28 @@ short CmpSeabaseDDL::createSeabaseTable2(
 void CmpSeabaseDDL::createSeabaseTable(
                                        StmtDDLCreateTable * createTableNode,
                                        NAString &currCatName, NAString 
&currSchName,
-                                       NABoolean isCompound)
+                                       NABoolean isCompound,
+                                       Int64 *retObjUID)
 {
   NABoolean xnWasStartedHere = FALSE;
   ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, 
   CmpCommon::context()->sqlSession()->getParentQid());
 
+  ComObjectName tableName(createTableNode->getTableName());
+  ComAnsiNamePart currCatAnsiName(currCatName);
+  ComAnsiNamePart currSchAnsiName(currSchName);
+  tableName.applyDefaults(currCatAnsiName, currSchAnsiName);
+  const NAString catalogNamePart = tableName.getCatalogNamePartAsAnsiString();
+  const NAString schemaNamePart = 
tableName.getSchemaNamePartAsAnsiString(TRUE);
+  const NAString objectNamePart = 
tableName.getObjectNamePartAsAnsiString(TRUE);
+  
   if (beginXnIfNotInProgress(&cliInterface, xnWasStartedHere))
     return;
 
+  Int64 objUID = 0;
   short rc =
     createSeabaseTable2(cliInterface, createTableNode, currCatName, 
currSchName,
-                        isCompound);
+                        isCompound, objUID);
   if ((CmpCommon::diags()->getNumber(DgSqlCode::ERROR_)) &&
       (rc < 0))
     {
@@ -2459,15 +2467,7 @@ void CmpSeabaseDDL::createSeabaseTable(
 
       if (rc == -2) // cleanup before returning error..
         {
-          ComObjectName tableName(createTableNode->getTableName());
-          ComAnsiNamePart currCatAnsiName(currCatName);
-          ComAnsiNamePart currSchAnsiName(currSchName);
-          tableName.applyDefaults(currCatAnsiName, currSchAnsiName);
-          const NAString catalogNamePart = 
tableName.getCatalogNamePartAsAnsiString();
-          const NAString schemaNamePart = 
tableName.getSchemaNamePartAsAnsiString(TRUE);
-          const NAString objectNamePart = 
tableName.getObjectNamePartAsAnsiString(TRUE);
-
-          cleanupObjectAfterError(cliInterface,
+           cleanupObjectAfterError(cliInterface,
                                   catalogNamePart, schemaNamePart, 
objectNamePart,
                                   COM_BASE_TABLE_OBJECT,
                                   createTableNode->ddlXns());
@@ -2476,6 +2476,23 @@ void CmpSeabaseDDL::createSeabaseTable(
       return;
     }
 
+  if (retObjUID)
+    *retObjUID = objUID;
+
+  if (NOT isCompound)
+    {
+      if (updateObjectRedefTime(&cliInterface, 
+                                catalogNamePart, schemaNamePart, 
objectNamePart,
+                                COM_BASE_TABLE_OBJECT_LIT, -1, objUID))
+        {
+          endXnIfStartedHere(&cliInterface, xnWasStartedHere, -1);
+          
+          processReturn();
+          
+          return;
+        }
+    }
+
   endXnIfStartedHere(&cliInterface, xnWasStartedHere, 0);
 
   return;
@@ -2779,6 +2796,7 @@ void CmpSeabaseDDL::createSeabaseTableCompound(
   const NAString extTableName = tableName.getExternalName(TRUE);
 
   NABoolean xnWasStartedHere = FALSE;
+  Int64 objUID = 0;
 
   if ((createTableNode->isVolatile()) &&
       ((createTableNode->getAddConstraintUniqueArray().entries() > 0) ||
@@ -2792,7 +2810,7 @@ void CmpSeabaseDDL::createSeabaseTableCompound(
       goto label_error;
     }
 
-  createSeabaseTable(createTableNode, currCatName, currSchName, TRUE);
+  createSeabaseTable(createTableNode, currCatName, currSchName, TRUE, &objUID);
   if (CmpCommon::diags()->getNumber(DgSqlCode::ERROR_))
     {
       return;
@@ -2849,6 +2867,15 @@ void CmpSeabaseDDL::createSeabaseTableCompound(
 
       goto label_error;
     }
+
+  if (updateObjectRedefTime(&cliInterface, 
+                            catalogNamePart, schemaNamePart, objectNamePart,
+                            COM_BASE_TABLE_OBJECT_LIT, -1, objUID))
+    {
+      endXnIfStartedHere(&cliInterface, xnWasStartedHere, -1);
+      
+      goto label_error;
+    }
   
   endXnIfStartedHere(&cliInterface, xnWasStartedHere, cliRC);
 
@@ -3472,7 +3499,21 @@ short CmpSeabaseDDL::dropSeabaseTable2(
           processReturn();
           
           return -1;
-        }     
+        }    
+
+      if (updateObjectRedefTime
+          (cliInterface,
+           otherNaTable->getTableName().getCatalogName(),
+           otherNaTable->getTableName().getSchemaName(),
+           otherNaTable->getTableName().getObjectName(),
+           COM_BASE_TABLE_OBJECT_LIT, -1, 
+           otherNaTable->objectUid().castToInt64()))
+        {
+          processReturn();
+          deallocEHI(ehi);
+          
+          return -1;      
+        }
     }
 
   // drop all check constraints from metadata if 'no check' is not specified.
@@ -4140,6 +4181,197 @@ void CmpSeabaseDDL::renameSeabaseTable(
   return;
 }
 
+void CmpSeabaseDDL::alterSeabaseTableStoredDesc(
+     StmtDDLAlterTableStoredDesc * alterStoredDesc,
+     NAString &currCatName, NAString &currSchName)
+{
+  Lng32 retcode = 0;
+  Lng32 cliRC = 0;
+
+  ComObjectName tableName(alterStoredDesc->getTableName());
+  ComAnsiNamePart currCatAnsiName(currCatName);
+  ComAnsiNamePart currSchAnsiName(currSchName);
+  tableName.applyDefaults(currCatAnsiName, currSchAnsiName);
+  const NAString catalogNamePart = tableName.getCatalogNamePartAsAnsiString();
+  const NAString schemaNamePart = 
tableName.getSchemaNamePartAsAnsiString(TRUE);
+  const NAString objectNamePart = 
tableName.getObjectNamePartAsAnsiString(TRUE);
+  const NAString extTableName = tableName.getExternalName(TRUE);
+  const NAString extNameForHbase = catalogNamePart + "." + schemaNamePart + 
"." + objectNamePart;
+
+  ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, 
+  CmpCommon::context()->sqlSession()->getParentQid());
+  
+  ExpHbaseInterface * ehi = allocEHI();
+  if (ehi == NULL)
+    {
+      processReturn();
+
+      return;
+    }
+
+  if ((isSeabaseReservedSchema(tableName)) &&
+      (!Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)))
+    {
+      *CmpCommon::diags() << DgSqlCode(-CAT_SMD_CANNOT_BE_ALTERED)
+                          << DgTableName(extTableName);
+      deallocEHI(ehi); 
+
+      processReturn();
+
+      return;
+    }
+  
+  if (CmpCommon::context()->sqlSession()->volatileSchemaInUse())
+    {
+      QualifiedName *qn =
+        CmpCommon::context()->sqlSession()->
+        updateVolatileQualifiedName
+        (alterStoredDesc->getTableNameAsQualifiedName().getObjectName());
+      
+      if (qn == NULL)
+        {
+          *CmpCommon::diags()
+            << DgSqlCode(-1427);
+          
+          processReturn();
+          
+          return;
+        }
+      
+      ComObjectName volTabName (qn->getQualifiedNameAsAnsiString());
+      volTabName.applyDefaults(currCatAnsiName, currSchAnsiName);
+      
+      NAString vtCatNamePart = volTabName.getCatalogNamePartAsAnsiString();
+      NAString vtSchNamePart = volTabName.getSchemaNamePartAsAnsiString(TRUE);
+      NAString vtObjNamePart = volTabName.getObjectNamePartAsAnsiString(TRUE);
+      
+      retcode = existsInSeabaseMDTable(&cliInterface, 
+                                       vtCatNamePart, vtSchNamePart, 
vtObjNamePart,
+                                       COM_BASE_TABLE_OBJECT);
+      
+      if (retcode < 0)
+        {
+          processReturn();
+          
+          return;
+        }
+      
+      if (retcode == 1)
+        {
+          // table found in volatile schema. cannot alter it.
+          *CmpCommon::diags()
+            << DgSqlCode(-3242)
+            << DgString0("Operation not allowed on volatile tables.");
+          
+          processReturn();
+          return;
+        }
+    }
+  
+  BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
+
+  CorrName cn(objectNamePart,
+              STMTHEAP,
+              schemaNamePart,
+              catalogNamePart);
+  
+  NATable *naTable = bindWA.getNATable(cn); 
+  if (naTable == NULL || bindWA.errStatus())
+    {
+      CmpCommon::diags()->clear();
+      
+      *CmpCommon::diags() << DgSqlCode(-CAT_OBJECT_DOES_NOT_EXIST_IN_TRAFODION)
+                          << DgString0(extTableName);
+  
+      processReturn();
+      
+      return;
+    }
+ 
+  // Make sure user has the privilege to perform the rename
+ if (alterStoredDesc->getType() != StmtDDLAlterTableStoredDesc::CHECK)
+   {
+     if (!isDDLOperationAuthorized(SQLOperation::ALTER_TABLE,
+                                   
naTable->getOwner(),naTable->getSchemaOwner()))
+       {
+         *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED);
+         
+         processReturn ();
+         
+         return;
+       }
+   }
+
+  Int64 objUID = naTable->objectUid().castToInt64();
+
+  if (alterStoredDesc->getType() == StmtDDLAlterTableStoredDesc::GENERATE)
+    {
+      cliRC = 
+        updateObjectRedefTime(&cliInterface, 
+                              catalogNamePart, schemaNamePart, objectNamePart,
+                              COM_BASE_TABLE_OBJECT_LIT,
+                              -1, objUID, TRUE);
+      if (cliRC < 0)
+        {
+          processReturn ();
+          
+          return;
+        }
+    }
+  else if (alterStoredDesc->getType() == StmtDDLAlterTableStoredDesc::DELETE)
+    {
+      cliRC = deleteFromTextTable
+        (&cliInterface, objUID, COM_STORED_DESC_TEXT, 0);
+     if (cliRC < 0)
+       {
+         processReturn ();
+         return;
+       }    
+
+     Int64 flags = MD_OBJECTS_STORED_DESC | MD_OBJECTS_DISABLE_STORED_DESC;
+     cliRC = updateObjectFlags(&cliInterface, objUID, flags, TRUE);
+     if (cliRC < 0)
+       {
+         processReturn ();
+         return;
+       }    
+    }
+  else if (alterStoredDesc->getType() == StmtDDLAlterTableStoredDesc::ENABLE)
+    {
+     Int64 flags = MD_OBJECTS_DISABLE_STORED_DESC;
+     cliRC = updateObjectFlags(&cliInterface, objUID, flags, TRUE);
+     if (cliRC < 0)
+       {
+         processReturn ();
+         return;
+       }    
+    }
+  else if (alterStoredDesc->getType() == StmtDDLAlterTableStoredDesc::DISABLE)
+    {
+     Int64 flags = MD_OBJECTS_DISABLE_STORED_DESC;
+     cliRC = updateObjectFlags(&cliInterface, objUID, flags, FALSE);
+     if (cliRC < 0)
+       {
+         processReturn ();
+         return;
+       }    
+    }
+  else if (alterStoredDesc->getType() == StmtDDLAlterTableStoredDesc::CHECK)
+    {
+      checkAndGetStoredObjectDesc(&cliInterface, objUID, NULL);
+      processReturn();
+ 
+      return;
+    }
+
+  ActiveSchemaDB()->getNATableDB()->removeNATable
+    (cn,
+     ComQiScope::REMOVE_FROM_ALL_USERS, COM_BASE_TABLE_OBJECT,
+     alterStoredDesc->ddlXns(), FALSE);
+
+  return;
+}
+
 void CmpSeabaseDDL::alterSeabaseTableHBaseOptions(
                                        StmtDDLAlterTableHBaseOptions * 
hbaseOptionsNode,
                                        NAString &currCatName, NAString 
&currSchName)
@@ -4274,6 +4506,18 @@ void CmpSeabaseDDL::alterSeabaseTableHBaseOptions(
       return;
     }   
 
+  cliRC = updateObjectRedefTime(&cliInterface,
+                                catalogNamePart, schemaNamePart, 
objectNamePart,
+                                COM_BASE_TABLE_OBJECT_LIT, -1, objUID);
+  if (cliRC < 0)
+    {
+      cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
+
+      deallocEHI(ehi);
+      processReturn();
+      return;
+    }
+
   // invalidate cached NATable info on this table for all users
 
   ActiveSchemaDB()->getNATableDB()->removeNATable
@@ -4911,7 +5155,7 @@ void CmpSeabaseDDL::alterSeabaseTableAddColumn(
 
   if (updateObjectRedefTime(&cliInterface, 
                             catalogNamePart, schemaNamePart, objectNamePart,
-                            COM_BASE_TABLE_OBJECT_LIT))
+                            COM_BASE_TABLE_OBJECT_LIT, -1, objUID))
     {
       processReturn();
 
@@ -5554,7 +5798,7 @@ void CmpSeabaseDDL::alterSeabaseTableDropColumn(
 
   cliRC = updateObjectRedefTime(&cliInterface,
                                 catalogNamePart, schemaNamePart, 
objectNamePart,
-                                COM_BASE_TABLE_OBJECT_LIT);
+                                COM_BASE_TABLE_OBJECT_LIT, -1, objUID);
   if (cliRC < 0)
     {
       goto label_error;
@@ -5753,6 +5997,18 @@ void CmpSeabaseDDL::alterSeabaseTableAlterIdentityColumn(
         }
     }
 
+  cliRC = updateObjectRedefTime(&cliInterface,
+                                catalogNamePart, schemaNamePart, 
objectNamePart,
+                                COM_BASE_TABLE_OBJECT_LIT, -1, 
naTable->objectUid().castToInt64());
+  if (cliRC < 0)
+    {
+      cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
+
+      processReturn();
+      
+      return;
+    }
+
   ActiveSchemaDB()->getNATableDB()->removeNATable
     (cn,
      ComQiScope::REMOVE_FROM_ALL_USERS, COM_BASE_TABLE_OBJECT,
@@ -5886,6 +6142,7 @@ short CmpSeabaseDDL::recreateUsingViews(ExeCliInterface 
*cliInterface,
   cliRC = 0;
   
 label_return:
+ 
   for (Lng32 i = 0; i < viewDefnList.entries(); i++)
     {
       ComObjectName tableName(viewNameList[i], COM_TABLE_NAME);
@@ -6651,7 +6908,7 @@ void CmpSeabaseDDL::alterSeabaseTableAlterColumnDatatype(
 
   cliRC = updateObjectRedefTime(&cliInterface,
                                 catalogNamePart, schemaNamePart, 
objectNamePart,
-                                COM_BASE_TABLE_OBJECT_LIT);
+                                COM_BASE_TABLE_OBJECT_LIT, -1, objUID);
   if (cliRC < 0)
     {
       goto label_error;
@@ -7005,7 +7262,7 @@ void CmpSeabaseDDL::alterSeabaseTableAlterColumnRename(
 
   cliRC = updateObjectRedefTime(&cliInterface,
                                 catalogNamePart, schemaNamePart, 
objectNamePart,
-                                COM_BASE_TABLE_OBJECT_LIT);
+                                COM_BASE_TABLE_OBJECT_LIT, -1, objUID);
   if (cliRC < 0)
     {
       return;
@@ -7298,7 +7555,7 @@ void CmpSeabaseDDL::alterSeabaseTableAddPKeyConstraint(
 
   if (updateObjectRedefTime(&cliInterface,
                             catalogNamePart, schemaNamePart, objectNamePart,
-                            COM_BASE_TABLE_OBJECT_LIT))
+                            COM_BASE_TABLE_OBJECT_LIT, -1, tableUID))
     {
       processReturn();
 
@@ -7478,7 +7735,7 @@ void CmpSeabaseDDL::alterSeabaseTableAddUniqueConstraint(
 
   if (updateObjectRedefTime(&cliInterface,
                             catalogNamePart, schemaNamePart, objectNamePart,
-                            COM_BASE_TABLE_OBJECT_LIT))
+                            COM_BASE_TABLE_OBJECT_LIT, -1, tableUID))
     {
       processReturn();
 
@@ -8077,7 +8334,7 @@ void CmpSeabaseDDL::alterSeabaseTableAddRIConstraint(
 
   if (updateObjectRedefTime(&cliInterface,
                             catalogNamePart, schemaNamePart, objectNamePart,
-                            COM_BASE_TABLE_OBJECT_LIT))
+                            COM_BASE_TABLE_OBJECT_LIT, -1, tableUID))
     {
       processReturn();
 
@@ -8103,6 +8360,22 @@ void CmpSeabaseDDL::alterSeabaseTableAddRIConstraint(
      COM_BASE_TABLE_OBJECT,
      alterAddConstraint->ddlXns(), FALSE);
 
+  // regenerate and store packed descriptor in metadata for referenced table.
+  if (updateObjectRedefTime
+      (&cliInterface,
+       referencedTableName.getCatalogNamePart().getInternalName(),
+       referencedTableName.getSchemaNamePart().getInternalName(),
+       referencedTableName.getObjectNamePart().getInternalName(),       
+       COM_BASE_TABLE_OBJECT_LIT, -1, 
+       refdNaTable->objectUid().castToInt64()))
+    {
+      processReturn();
+
+      deallocEHI(ehi);
+
+      return;
+    }
+  
   return;
 }
 
@@ -8231,8 +8504,6 @@ short 
CmpSeabaseDDL::getCheckConstraintText(StmtDDLAddConstraintCheck *addCheckN
   
   PrettifySqlText(qualifiedText, NULL);
 
-  //                  
CharType::getCharSetAsPrefix(SqlParser_NATIONAL_CHARSET));
-  
   return 0;
 }
 
@@ -8269,7 +8540,7 @@ short CmpSeabaseDDL::getTextFromMD(const char * 
catalogName,
 
   char query[1000];
 
-  str_sprintf(query, "select text from %s.\"%s\".%s where text_uid = %Ld and 
text_type = %d and sub_id = %d for read committed access order by seq_num",
+  str_sprintf(query, "select octet_length(text), text from %s.\"%s\".%s where 
text_uid = %Ld and text_type = %d and sub_id = %d for read committed access 
order by seq_num",
               catalogName, SEABASE_MD_SCHEMA, SEABASE_TEXT,
               textUID, static_cast<int>(textType), textSubID);
   
@@ -8287,9 +8558,11 @@ short CmpSeabaseDDL::getTextFromMD(const char * 
catalogName,
     {
       OutputInfo * vi = (OutputInfo*)textQueue->getNext(); 
     
-      char * text = (char*)vi->get(0);
+      Lng32 len = *(Lng32*)vi->get(0);
+
+      char * text = (char*)vi->get(1);
    
-      outText += text;
+      outText.append(text, len);
     }
 
   return 0;
@@ -8487,7 +8760,7 @@ void CmpSeabaseDDL::alterSeabaseTableAddCheckConstraint(
 
   if (updateObjectRedefTime(&cliInterface,
                             catalogNamePart, schemaNamePart, objectNamePart,
-                            COM_BASE_TABLE_OBJECT_LIT))
+                            COM_BASE_TABLE_OBJECT_LIT, -1, tableUID))
     {
       processReturn();
 
@@ -8839,9 +9112,10 @@ void CmpSeabaseDDL::alterSeabaseTableDropConstraint(
         }
     }
 
+  Int64 tableUID = naTable->objectUid().castToInt64();
   if (updateObjectRedefTime(&cliInterface,
                             catalogNamePart, schemaNamePart, objectNamePart,
-                            COM_BASE_TABLE_OBJECT_LIT))
+                            COM_BASE_TABLE_OBJECT_LIT, -1, tableUID))
     {
       processReturn();
 
@@ -8857,9 +9131,25 @@ void CmpSeabaseDDL::alterSeabaseTableDropConstraint(
      alterDropConstraint->ddlXns(), FALSE);
 
   if (isRefConstr && otherNaTable)
-  {
-    CorrName otherCn(
-      otherNaTable->getExtendedQualName().getQualifiedNameObj(), STMTHEAP);
+    {
+      CorrName otherCn(
+           otherNaTable->getExtendedQualName().getQualifiedNameObj(), 
STMTHEAP);
+      
+      if (updateObjectRedefTime
+          (&cliInterface,
+           otherCn.getQualifiedNameObj().getCatalogName(),
+           otherCn.getQualifiedNameObj().getSchemaName(),
+           otherCn.getQualifiedNameObj().getObjectName(),
+           COM_BASE_TABLE_OBJECT_LIT, -1, 
+           otherNaTable->objectUid().castToInt64()))
+        {
+          processReturn();
+          
+          deallocEHI(ehi);
+          
+          return;
+        }
+      
     ActiveSchemaDB()->getNATableDB()->removeNATable
       (otherCn,
        ComQiScope::REMOVE_FROM_ALL_USERS, COM_BASE_TABLE_OBJECT,
@@ -9545,7 +9835,7 @@ short CmpSeabaseDDL::getSpecialTableInfo
   return -1;
 }
 
-desc_struct * CmpSeabaseDDL::getSeabaseMDTableDesc(
+TrafDesc * CmpSeabaseDDL::getSeabaseMDTableDesc(
                                                    const NAString &catName, 
                                                    const NAString &schName, 
                                                    const NAString &objName,
@@ -9553,7 +9843,7 @@ desc_struct * CmpSeabaseDDL::getSeabaseMDTableDesc(
 {
   Lng32 cliRC = 0;
 
-  desc_struct * tableDesc = NULL;
+  TrafDesc * tableDesc = NULL;
   NAString schNameL = "\"";
   schNameL += schName;
   schNameL += "\"";
@@ -9620,13 +9910,13 @@ desc_struct * CmpSeabaseDDL::getSeabaseMDTableDesc(
 
 }
 
-desc_struct * CmpSeabaseDDL::getSeabaseHistTableDesc(const NAString &catName, 
+TrafDesc * CmpSeabaseDDL::getSeabaseHistTableDesc(const NAString &catName, 
                                                      const NAString &schName, 
                                                      const NAString &objName)
 {
   Lng32 cliRC = 0;
 
-  desc_struct * tableDesc = NULL;
+  TrafDesc * tableDesc = NULL;
   NAString schNameL = "\"";
   schNameL += schName;
   schNameL += "\"";  // transforms internal format schName to external format
@@ -10006,14 +10296,14 @@ ComTdbVirtTableSequenceInfo * 
CmpSeabaseDDL::getSeabaseSequenceInfo(
   return seqInfo;
 }
 
-desc_struct * CmpSeabaseDDL::getSeabaseLibraryDesc(
+TrafDesc * CmpSeabaseDDL::getSeabaseLibraryDesc(
    const NAString &catName, 
    const NAString &schName, 
    const NAString &libraryName)
    
 {
 
-  desc_struct * tableDesc = NULL;
+  TrafDesc * tableDesc = NULL;
 
   NAString extLibName;
   Int32 objectOwner = 0;
@@ -10089,9 +10379,9 @@ desc_struct * CmpSeabaseDDL::getSeabaseLibraryDesc(
   libraryInfo->schema_owner_id = schemaOwner;
   libraryInfo->library_UID = libUID;
   
-  desc_struct *library_desc = Generator::createVirtualLibraryDesc(
+  TrafDesc *library_desc = Generator::createVirtualLibraryDesc(
             libraryName.data(),
-            libraryInfo);
+            libraryInfo, NULL);
 
   processReturn();
   return library_desc;
@@ -10100,11 +10390,11 @@ desc_struct * CmpSeabaseDDL::getSeabaseLibraryDesc(
 
 
 
-desc_struct * CmpSeabaseDDL::getSeabaseSequenceDesc(const NAString &catName, 
+TrafDesc * CmpSeabaseDDL::getSeabaseSequenceDesc(const NAString &catName, 
                                                     const NAString &schName, 
                                                     const NAString &seqName)
 {
-  desc_struct * tableDesc = NULL;
+  TrafDesc * tableDesc = NULL;
 
   NAString extSeqName;
   Int32 objectOwner = 0;
@@ -10147,27 +10437,13 @@ desc_struct * 
CmpSeabaseDDL::getSeabaseSequenceDesc(const NAString &catName,
   return tableDesc;
 }
 
-void populateRegionDescForEndKey(char* buf, Int32 len, struct desc_struct* 
target)
-{
-   target->body.hbase_region_desc.beginKey = NULL;
-   target->body.hbase_region_desc.beginKeyLen = 0;
-   target->body.hbase_region_desc.endKey = buf;
-   target->body.hbase_region_desc.endKeyLen = len;
-}
-
-void populateRegionDescAsRANGE(char* buf, Int32 len, struct desc_struct* 
target, NAMemory*)
-{
-   target->header.nodetype = DESC_HBASE_RANGE_REGION_TYPE;
-   populateRegionDescForEndKey(buf, len, target);
-}
-
-
-desc_struct * CmpSeabaseDDL::getSeabaseUserTableDesc(const NAString &catName, 
+TrafDesc * CmpSeabaseDDL::getSeabaseUserTableDesc(const NAString &catName, 
                                                      const NAString &schName, 
                                                      const NAString &objName,
                                                      const ComObjectType 
objType,
                                                      NABoolean 
includeInvalidDefs,
-                                                     Int32 ctlFlags)
+                                                     Int32 ctlFlags,
+                                                     Int32 &packedDescLen)
 {
   Lng32 retcode = 0;
   Lng32 cliRC = 0;
@@ -10176,7 +10452,7 @@ desc_struct * 
CmpSeabaseDDL::getSeabaseUserTableDesc(const NAString &catName,
   ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, 
   CmpCommon::context()->sqlSession()->getParentQid());
   
-  desc_struct * tableDesc = NULL;
+  TrafDesc * tableDesc = NULL;
 
   Int32 objectOwner =  0 ;
   Int32 schemaOwner =  0 ;
@@ -10251,6 +10527,26 @@ desc_struct * 
CmpSeabaseDDL::getSeabaseUserTableDesc(const NAString &catName,
     }
   }
 
+  if ((ctlFlags & READ_OBJECT_DESC) && // read stored descriptor
+      ((objectFlags & MD_OBJECTS_STORED_DESC) != 0) && // stored desc available
+      ((objectFlags & MD_OBJECTS_DISABLE_STORED_DESC) == 0)) // not disabled
+    {
+
+      TrafDesc * desc = NULL;
+
+      // if good stored desc was retrieved, return it.
+      // Otherwise, continue and generate descriptor the old fashioned way.
+      if (! checkAndGetStoredObjectDesc(&cliInterface, objUID, &desc))
+        {
+          CmpCommon::diags()->clear();
+
+          return desc;
+        }
+
+      // clear diags and continue
+      CmpCommon::diags()->clear();
+    }
+
   str_sprintf(query, "select is_audited, num_salt_partns, row_format, flags 
from %s.\"%s\".%s where table_uid = %Ld for read committed access",
               getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_TABLES,
               objUID);
@@ -10916,17 +11212,45 @@ desc_struct * 
CmpSeabaseDDL::getSeabaseUserTableDesc(const NAString &catName,
       char * colFamBufPtr = colFamBuf;
       strcpy(colFamBufPtr, colFamStr.data());
       strsep(&colFamBufPtr, " ");
-      tableInfo->defaultColFam = colFamBuf;
-      tableInfo->allColFams = colFamBufPtr;
+      tableInfo->defaultColFam = new(STMTHEAP) char[strlen(colFamBuf)+1];
+      strcpy((char*)tableInfo->defaultColFam, colFamBuf);
+      tableInfo->allColFams = new(STMTHEAP) char[strlen(colFamBufPtr)+1];
+      strcpy((char*)tableInfo->allColFams, colFamBufPtr);
     }
   else
     {
-      tableInfo->defaultColFam = SEABASE_DEFAULT_COL_FAMILY;
+      tableInfo->defaultColFam = new(STMTHEAP) 
char[strlen(SEABASE_DEFAULT_COL_FAMILY)+1];
+      strcpy((char*)tableInfo->defaultColFam, SEABASE_DEFAULT_COL_FAMILY);
       tableInfo->allColFams = NULL;
     }
   tableInfo->objectFlags = objectFlags;
   tableInfo->tablesFlags = tablesFlags;
 
+  // request the default
+  ExpHbaseInterface* ehi = CmpSeabaseDDL::allocEHI();
+  if (ehi == NULL) 
+    return NULL;
+  
+  NAArray<HbaseStr>* endKeyArray  = ehi->getRegionEndKeys(extNameForHbase);
+
+  char * snapshotName = NULL;
+  if (ctlFlags & GET_SNAPSHOTS)
+    {
+      Lng32 retcode = 
+        ehi->getLatestSnapshot(extNameForHbase.data(), snapshotName, STMTHEAP);
+      if (retcode < 0)
+        {
+          *CmpCommon::diags()
+            << DgSqlCode(-8448)
+            << DgString0((char*)"ExpHbaseInterface::getLatestSnapshot()")
+            << DgString1(getHbaseErrStr(-retcode))
+            << DgInt0(-retcode)
+            << DgString2((char*)GetCliGlobals()->getJniErrorStr().data());
+          delete ehi;
+        }
+    }
+
+  
   tableDesc =
     Generator::createVirtualTableDesc
     (
@@ -10942,73 +11266,43 @@ desc_struct * 
CmpSeabaseDDL::getSeabaseUserTableDesc(const NAString &catName,
      viewInfoQueue->numEntries(),
      viewInfoArray,
      tableInfo,
-     seqInfo);
-
- // reset the SMD table flag
-  tableDesc->body.table_desc.issystemtablecode = 0;
-
+     seqInfo,
+     endKeyArray,
+     snapshotName,
+     ((ctlFlags & GEN_PACKED_DESC) != 0),
+     &packedDescLen,
+     TRUE /*user table*/);
+  
+  deleteNAArray(heap_, endKeyArray);
+  
   if ( tableDesc ) {
-
-       // request the default
-      ExpHbaseInterface* ehi =CmpSeabaseDDL::allocEHI();
-      if (ehi == NULL) 
-         return NULL;
-      
-      NAArray<HbaseStr>* endKeyArray  = ehi->getRegionEndKeys(extNameForHbase);
-
-      // create a list of region descriptors
-      ((table_desc_struct*)tableDesc)->hbase_regionkey_desc = 
-        assembleDescs(endKeyArray , populateRegionDescAsRANGE, STMTHEAP);
-      deleteNAArray(heap_, endKeyArray);
-
-      // if this is base table or index and hbase object doesn't exist, then 
this object
-      // is corrupted.
-      if (!objectFlags & SEABASE_OBJECT_IS_EXTERNAL_HIVE &&
-          !objectFlags & SEABASE_OBJECT_IS_EXTERNAL_HBASE)
-        {
-          if ((tableDesc->body.table_desc.objectType == COM_BASE_TABLE_OBJECT) 
&&
-              (existsInHbase(extNameForHbase, ehi) == 0))
-            {
-              *CmpCommon::diags() << DgSqlCode(-4254)
-                                  << DgString0(*extTableName);
-          
-              tableDesc = NULL;
-          
-              return NULL;
-            }
-        }
-
-      if (ctlFlags & GET_SNAPSHOTS)
+    // if this is base table or index and hbase object doesn't exist,
+    // then this object is corrupted.
+    if (!objectFlags & SEABASE_OBJECT_IS_EXTERNAL_HIVE &&
+        !objectFlags & SEABASE_OBJECT_IS_EXTERNAL_HBASE)
       {
-        char * snapName = NULL;
-        Lng32 retcode = ehi->getLatestSnapshot(extNameForHbase.data(), 
snapName, STMTHEAP);
-        if (retcode < 0)
-        {
-          *CmpCommon::diags()
-                    << DgSqlCode(-8448)
-                    << 
DgString0((char*)"ExpHbaseInterface::getLatestSnapshot()")
-                    << DgString1(getHbaseErrStr(-retcode))
-                    << DgInt0(-retcode)
-                    << 
DgString2((char*)GetCliGlobals()->getJniErrorStr().data());
-          delete ehi;
-        }
-        if (snapName != NULL)
-        {
-          tableDesc->body.table_desc.snapshotName=snapName;
-        }
+        if ((tableDesc->tableDesc()->objectType() == COM_BASE_TABLE_OBJECT) &&
+            (existsInHbase(extNameForHbase, ehi) == 0))
+          {
+            *CmpCommon::diags() << DgSqlCode(-4254)
+                                << DgString0(*extTableName);
+            
+            tableDesc = NULL;
+            
+            return NULL;
+          }
       }
-      //test return code
-      CmpSeabaseDDL::deallocEHI(ehi);
   }
 
-
+  CmpSeabaseDDL::deallocEHI(ehi);
+    
   if (! tableDesc)
     processReturn();
   
   return tableDesc;
 }
 
-desc_struct * CmpSeabaseDDL::getSeabaseTableDesc(const NAString &catName, 
+TrafDesc * CmpSeabaseDDL::getSeabaseTableDesc(const NAString &catName, 
                                                      const NAString &schName, 
                                                      const NAString &objName,
                                                      const ComObjectType 
objType,
@@ -11030,7 +11324,7 @@ desc_struct * CmpSeabaseDDL::getSeabaseTableDesc(const 
NAString &catName,
       return NULL;
     }
 
-  desc_struct *tDesc = NULL;
+  TrafDesc *tDesc = NULL;
   NABoolean isMDTable = (isSeabaseMD(catName, schName, objName) || 
                         isSeabasePrivMgrMD(catName, schName));
   if (isMDTable)
@@ -11077,6 +11371,12 @@ desc_struct * CmpSeabaseDDL::getSeabaseTableDesc(const 
NAString &catName,
         }
       else
         {
+          Int32 ctlFlags = GET_SNAPSHOTS; // get snapshot
+          if ((CmpCommon::getDefault(TRAF_READ_OBJECT_DESC) == DF_ON) &&
+              (!Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)) &&
+              (NOT includeInvalidDefs))
+            ctlFlags |= READ_OBJECT_DESC;
+
           if (switchCompiler(CmpContextInfo::CMPCONTEXT_TYPE_META))
             return NULL;
          switch (objType)
@@ -11088,9 +11388,13 @@ desc_struct * CmpSeabaseDDL::getSeabaseTableDesc(const 
NAString &catName,
               tDesc = getSeabaseLibraryDesc(catName, schName, objName);
               break;
             default:
+              Int32 packedDescLen = 0;
+
               tDesc = getSeabaseUserTableDesc(catName, schName, objName, 
                                               objType, includeInvalidDefs,
-                                              GET_SNAPSHOTS /* get snapshot 
*/);
+                                              ctlFlags, packedDescLen);
+              break;
+                 
          }
           switchBackCompiler();
         }
@@ -11099,57 +11403,15 @@ desc_struct * 
CmpSeabaseDDL::getSeabaseTableDesc(const NAString &catName,
   return tDesc;
 }
 
-//
-// Produce a list of desc_struct objects. In each object, the body_struct
-// field points at hbase_region_desc. The order of the keyinfo, obtained from
-// org.apache.hadoop.hbase.client.HTable.getEndKey(), is preserved.
-//
-// Allocate space from STMTHEAP, per the call of this function
-// in CmpSeabaseDDL::getSeabaseTableDesc() and the
-// Generator::createVirtualTableDesc() call make before this one that
-// uses STMTPHEAP througout.
-//
-desc_struct* assembleDescs(NAArray<HbaseStr >* keyArray, populateFuncT func, 
NAMemory* heap)
-{
-   if (keyArray == NULL)
-      return NULL;
-
-   desc_struct *result = NULL;
-   Int32 entries = keyArray->entries();
-   Int32 len = 0;
-   char* buf = NULL;
-
-   for (Int32 i=entries-1; i>=0; i-- ) {
-      len = keyArray->at(i).len;
-      if ( len > 0 ) { 
-         buf = new (heap) char[len];
-         memcpy(buf, keyArray->at(i).val, len); 
-      } else
-         buf = NULL;
-
-      desc_struct* wrapper = NULL;
-      wrapper = new (heap) desc_struct();
-      wrapper->header.OSV = 0; // TBD
-      wrapper->header.OFV = 0; // TBD
-
-      (*func)(buf, len, wrapper, heap);
-
-      wrapper->header.next = result;
-      result = wrapper;
-   }
-
-   return result;
-}
-
 // a wrapper method to getSeabaseRoutineDescInternal so 
 // CmpContext context switching can take place. 
 // getSeabaseRoutineDescInternal prepares and executes
 // several queries on metadata tables
-desc_struct *CmpSeabaseDDL::getSeabaseRoutineDesc(const NAString &catName,
+TrafDesc *CmpSeabaseDDL::getSeabaseRoutineDesc(const NAString &catName,
                                       const NAString &schName,
                                       const NAString &objName)
 {
-   desc_struct *result = NULL;
+   TrafDesc *result = NULL;
 
    if (switchCompiler(CmpContextInfo::CMPCONTEXT_TYPE_META))
      return NULL;
@@ -11162,14 +11424,14 @@ desc_struct 
*CmpSeabaseDDL::getSeabaseRoutineDesc(const NAString &catName,
 }
 
 
-desc_struct *CmpSeabaseDDL::getSeabaseRoutineDescInternal(const NAString 
&catName,
+TrafDesc *CmpSeabaseDDL::getSeabaseRoutineDescInternal(const NAString &catName,
                                       const NAString &schName,
                                       const NAString &objName)
 {
   Lng32 retcode = 0;
   Lng32 cliRC = 0;
 
-  desc_struct *result;
+  TrafDesc *result;
   char query[4000];
   char buf[4000];
 
@@ -11338,12 +11600,13 @@ desc_struct 
*CmpSeabaseDDL::getSeabaseRoutineDescInternal(const NAString &catNam
       return NULL;
     } 
   
-  desc_struct *routine_desc = NULL;
+  TrafDesc *routine_desc = NULL;
   routine_desc = Generator::createVirtualRoutineDesc(
-            objName.data(),
-            routineInfo,
-            numParams,
-            paramsArray);
+       objName.data(),
+       routineInfo,
+       numParams,
+       paramsArray,
+       NULL);
 
   if (routine_desc == NULL)
      processReturn();

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/19c96b1e/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLview.cpp 
b/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
index 3cb7bbb..b423d9b 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
@@ -53,7 +53,6 @@
 
 #include "ExExeUtilCli.h"
 #include "Generator.h"
-#include "desc.h"
 
 // for privilege checking
 #include "PrivMgrCommands.h"
@@ -941,6 +940,17 @@ void CmpSeabaseDDL::createSeabaseView(
       return;
     }
 
+  if (updateObjectRedefTime(&cliInterface, 
+                            catalogNamePart, schemaNamePart, objectNamePart,
+                            COM_VIEW_OBJECT_LIT, -2, objUID))
+    {
+      deallocEHI(ehi);
+
+      processReturn();
+      
+      return;
+    }
+
   CorrName cn(objectNamePart, STMTHEAP, schemaNamePart, catalogNamePart);
   ActiveSchemaDB()->getNATableDB()->removeNATable
     (cn,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/19c96b1e/core/sql/sqlcomp/DefaultConstants.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/DefaultConstants.h 
b/core/sql/sqlcomp/DefaultConstants.h
index b274b94..245e4bf 100644
--- a/core/sql/sqlcomp/DefaultConstants.h
+++ b/core/sql/sqlcomp/DefaultConstants.h
@@ -3859,6 +3859,12 @@ enum DefaultConstants
   // if TRUE, create tinyint literal insteadl of smallint.
   TRAF_CREATE_TINYINT_LITERAL,
 
+  // if ON, generate object descriptor during DDL and store it in metadata.
+  TRAF_STORE_OBJECT_DESC,
+
+  // if ON, read object descriptor from metadata, if it was stored.
+  TRAF_READ_OBJECT_DESC,
+
   // This enum constant must be the LAST one in the list; it's a count,
   // not an Attribute (it's not IN DefaultDefaults; it's the SIZE of it)!
   __NUM_DEFAULT_ATTRIBUTES

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/19c96b1e/core/sql/sqlcomp/nadefaults.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/nadefaults.cpp b/core/sql/sqlcomp/nadefaults.cpp
index 25c5672..b6311f6 100644
--- a/core/sql/sqlcomp/nadefaults.cpp
+++ b/core/sql/sqlcomp/nadefaults.cpp
@@ -3336,10 +3336,10 @@ XDDkwd__(SUBQUERY_UNNESTING,                    "ON"),
   DDansi_(TRAF_CREATE_TABLE_WITH_UID,          ""),
 
   DDkwd__(TRAF_CREATE_TINYINT_LITERAL,        "ON"),   
-
- DDkwd__(TRAF_DEFAULT_COL_CHARSET,            (char 
*)SQLCHARSETSTRING_ISO88591),
  
- DDkwd__(TRAF_ENABLE_ORC_FORMAT,                 "OFF"),   
+  DDkwd__(TRAF_DEFAULT_COL_CHARSET,            (char 
*)SQLCHARSETSTRING_ISO88591),
+ 
+  DDkwd__(TRAF_ENABLE_ORC_FORMAT,                 "OFF"),   
 
   DDkwd__(TRAF_INDEX_ALIGNED_ROW_FORMAT,        "ON"),   
   DDkwd__(TRAF_INDEX_CREATE_OPT,          "OFF"),
@@ -3383,10 +3383,14 @@ XDDkwd__(SUBQUERY_UNNESTING,                    "ON"),
 
   DDint__(TRAF_NUM_OF_SALT_PARTNS,                     "-1"),
 
+  DDkwd__(TRAF_READ_OBJECT_DESC,                       "OFF"),   
+
   DDkwd__(TRAF_RELOAD_NATABLE_CACHE,                   "OFF"),
   DD_____(TRAF_SAMPLE_TABLE_LOCATION,                  "/sample/"),
   DDint__(TRAF_SEQUENCE_CACHE_SIZE,        "-1"),
 
+  DDkwd__(TRAF_STORE_OBJECT_DESC,                    "OFF"),   
+
   DDkwd__(TRAF_STRING_AUTO_TRUNCATE,      "OFF"),
   DDkwd__(TRAF_STRING_AUTO_TRUNCATE_WARNING,      "OFF"),
 

Reply via email to