trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmar...@apache.org
Subject [03/10] incubator-trafodion git commit: Merge branch 'master' into trafodion-1788
Date Fri, 12 Aug 2016 00:59:16 GMT
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/cd3d7e7b/core/sql/sqlcat/ReadTableDef.cpp
----------------------------------------------------------------------
diff --cc core/sql/sqlcat/ReadTableDef.cpp
index df0efbc,31bafb7..be64096
--- a/core/sql/sqlcat/ReadTableDef.cpp
+++ b/core/sql/sqlcat/ReadTableDef.cpp
@@@ -157,345 -93,4 +93,3 @@@ ReadTableDef::~ReadTableDef(
    // end any transactions started by "me"
  }
  
- 
- 
- //------------------------------------------------------------------------
- // displayTreeMX()
- //------------------------------------------------------------------------
- void ReadTableDef::displayTree(const desc_struct * top) const
- {
-   displayTreeMX(top, "");
- }
- 
- void ReadTableDef::displayTreeMX(const desc_struct * top,
-                                   const char * caller) const
- {
-   if (top == NULL) return;
- 
-   char title[50];
-   snprintf(title, sizeof(title),
-           ", type %d, address %p, parent %s\n",
-           top->NODETYPE_MX, (void *)top, caller);
-   #undef  TITLE
-   #define TITLE(XXX)    cout << "### " << XXX << title;         \
-                         strcpy(title, XXX)
- 
-   cout.setf(ios::right);
- 
-   switch (top->NODETYPE_MX)
-     {
-     case TYPEMX(CHECK_CONSTRNTS):
-       {
-         TITLE("CHECK_CONSTRNTS");
-         CASTMX(check_constrnts);
-         COUT(check_constrnts, seqnumber);
-         COUT_STRING(check_constrnts, constrnt_text);
-       }
-       break;
- 
-     case TYPEMX(COLUMNS):
-       {
-         TITLE("COLUMNS");
-         CASTMX(columns);
-         COUT(columns, tablename);
-         COUT(columns, colname);
-         COUT(columns, colnumber);
-         COUT(columns, datatype);
-         COUT(columns, length);
-         COUT(columns, scale);
-         COUT(columns, precision);
-         COUT_ENUM(columns, datetimestart);
-         COUT_ENUM(columns, datetimeend);
-         COUT(columns, datetimefractprec);
-         COUT(columns, intervalleadingprec);
-         COUT(columns, offset);
-         COUT(columns, null_flag);
-         COUT(columns, upshift);
-         COUT(columns, colclass);
-         COUT(columns, uec);
-         COUT_STRING(columns, highval);
-         COUT_STRING(columns, lowval);
- 
-         Int32 defaultValueInLocaleLen = 
- #pragma nowarn(1506)   // warning elimination 
-               NAWstrlen((NAWchar*)(columns->defaultvalue));
- #pragma warn(1506)  // warning elimination 
-         char* defaultValueInLocale = new HEAP char[defaultValueInLocaleLen+1];
- 
-         CharInfo::CharSet mapCharSet = SqlParser_ISO_MAPPING;
- 
-         Int32 x = UnicodeStringToLocale(mapCharSet,
-                  (NAWchar*)(columns->defaultvalue), defaultValueInLocaleLen,
-                  defaultValueInLocale, defaultValueInLocaleLen+1
-                              );
-         if (columns->defaultvalue)  {
-           cout << "  " << setw(20) << "defaultvalue"
-                << "  " << defaultValueInLocale << endl;
-         } else {
-           cout << "  " << setw(20) << "defaultvalue" << " is null" << endl;
-         }
-         NADELETEBASIC(defaultValueInLocale, HEAP);
-       }
-       break;
- 
-     case TYPEMX(CONSTRNTS):
-       {
-         TITLE("CONSTRNTS");
-         CASTMX(constrnts);
-         COUT(constrnts, constrntname);
-         COUT(constrnts, tablename);
-         COUT_ENUM(constrnts, type);
-         COUT(constrnts, colcount);
-         COUT_STRING(constrnts, indexname);
-         displayTreeMX(constrnts->check_constrnts_desc, title);
-         displayTreeMX(constrnts->constr_key_cols_desc, title);
-         displayTreeMX(constrnts->referenced_constrnts_desc, title);
-         displayTreeMX(constrnts->referencing_constrnts_desc, title);
-       }
-       break;
- 
-     case TYPEMX(CONSTRNT_KEY_COLS):
-       {
-         TITLE("CONSTRNT_KEY_COLS");
-         CASTMX(constrnt_key_cols);
-         COUT(constrnt_key_cols, colname);
-         COUT(constrnt_key_cols, position);
-       }
-       break;
- 
-     case TYPEMX(FILES):
-       {
-         TITLE("FILES");
-         CASTMX(files);
-         COUT_ENUM(files, fileorganization);
-         COUT(files, audit);
-         COUT(files, auditcompress);
-         COUT(files, compressed);
-         displayTreeMX(files->partns_desc, title);
-       }
-       break;
- 
-     case TYPEMX(HISTOGRAM):
-       {
-         TITLE("HISTOGRAM");
-         CASTMX(histogram);
-         COUT(histogram, tablename);
-         COUT(histogram, tablecolnumber);
-         COUT(histogram, histid);
-         COUT(histogram, colposition);
-         COUT(histogram, rowcount);
-         COUT(histogram, uec);
-         COUT_STRING(histogram, highval);
-         COUT_STRING(histogram, lowval);
-         displayTreeMX(histogram->hist_interval_desc, title);
-       }
-       break;
- 
-     case TYPEMX(HIST_INTERVAL):
-       {
-         TITLE("HIST_INTERVAL");
-         CASTMX(hist_interval);
-         COUT(hist_interval, histid);
-         COUT(hist_interval, intnum);
-         COUT(hist_interval, intboundary);
-         COUT(hist_interval, rowcount);
-         COUT(hist_interval, uec);
-       }
-       break;
- 
-     case TYPEMX(INDEXES):
-       {
-         TITLE("INDEXES");
-         CASTMX(indexes);
-         COUT(indexes, tablename);
-         COUT(indexes, indexname);
-         COUT(indexes, keytag);
-         COUT(indexes, record_length);
-         COUT(indexes, colcount);
-         COUT(indexes, unique);
-         displayTreeMX(indexes->files_desc, title);
-         displayTreeMX(indexes->keys_desc, title);
-     displayTreeMX(indexes->non_keys_desc, title);
-       }
-       break;
- 
-     case TYPEMX(KEYS):
-       {
-         TITLE("KEYS");
-         CASTMX(keys);
-         COUT(keys, indexname);
-         COUT(keys, keyseqnumber);
-         COUT(keys, tablecolnumber);
-         COUT(keys, ordering);
-       }
-       break;
- 
-     case TYPEMX(PARTNS):
-       {
-         TITLE("PARTNS");
-         CASTMX(partns);
-         COUT(partns, tablename);
-         COUT(partns, primarypartition);
-         COUT(partns, partitionname);
-         COUT_STRING(partns, firstkey);
-       }
-       break;
- 
-     case TYPEMX(REF_CONSTRNTS):
-       {
-         TITLE("REF_CONSTRNTS");
-         CASTMX(ref_constrnts);
-         COUT(ref_constrnts, constrntname);
-         COUT(ref_constrnts, tablename);
-       }
-       break;
- 
-     case TYPEMX(TABLE):
-       {
-         TITLE("TABLE");
-         CASTMX(table);
-         COUT_LARGEINT(table, createtime);
-         COUT_LARGEINT(table, redeftime);
-         COUT(table, tablename);
-         COUT(table, record_length);
-         COUT(table, colcount);
-         COUT(table, constr_count);
-         COUT(table, rowcount);
-         displayTreeMX(table->files_desc, title);
-         displayTreeMX(table->columns_desc, title);
-         displayTreeMX(table->views_desc, title);
-         displayTreeMX(table->indexes_desc, title);
-         displayTreeMX(table->constrnts_desc, title);
-         if (table->constrnts_tables_desc != top)
-           displayTreeMX(table->constrnts_tables_desc, title);
-         displayTreeMX(table->referenced_tables_desc, title);
-         displayTreeMX(table->referencing_tables_desc, title);
-         displayTreeMX(table->histograms_desc, title);
-       }
-       break;
- 
-     case TYPEMX(VIEW):
-       {
-         TITLE("VIEW");
-         CASTMX(view);
-         COUT(view, viewname);
-         COUT_STRING(view, viewtext);
-         COUT_STRING(view, viewchecktext);
-         COUT_STRING(view, viewcolusages);
-         COUT(view, updatable);
-         COUT(view, insertable);
-       }
-       break;
- 
-     default:
-       {
-         TITLE("??? UNKNOWN ???");
-       }
-       break;
-     }  // switch
- 
-   displayTreeMX (top->header.next, title);
- 
- } // displayTreeMX
- 
- 
- //------------------------------------------------------------------------
- // deleteTreeMX()
- //------------------------------------------------------------------------
- void ReadTableDef::deleteTree(desc_struct * top) const
- {
-   deleteTreeMX(top);
- }
- 
- void ReadTableDef::deleteTreeMX(desc_struct * top) const
- {
-   if (top == NULL) return;
- 
-   switch (top->NODETYPE_MX)
-     {
-     case TYPEMX(CHECK_CONSTRNTS):
-       break;
- 
-     case TYPEMX(COLUMNS):
-       break;
- 
-     case TYPEMX(CONSTRNTS):
-       {
- 	CASTMX(constrnts);
- 	deleteTreeMX(constrnts->check_constrnts_desc);
- 	deleteTreeMX(constrnts->constr_key_cols_desc);
- 	deleteTreeMX(constrnts->referenced_constrnts_desc);
- 	deleteTreeMX(constrnts->referencing_constrnts_desc);
-       }
-       break;
- 
-     case TYPEMX(CONSTRNT_KEY_COLS):
-       break;
- 
-     case TYPEMX(FILES):
-       {
- 	CASTMX(files);
- 	deleteTreeMX(files->partns_desc);
-       }
-       break;
- 
-     case TYPEMX(HISTOGRAM):
-       {
- 	CASTMX(histogram);
- 	deleteTreeMX(histogram->hist_interval_desc);
-       }
-       break;
- 
-     case TYPEMX(HIST_INTERVAL):
-       break;
- 
-     case TYPEMX(INDEXES):
-       {
- 	CASTMX(indexes);
- 	deleteTreeMX(indexes->keys_desc);
-     deleteTreeMX(indexes->non_keys_desc);
- 	deleteTreeMX(indexes->files_desc);
-       }
-       break;
- 
-     case TYPEMX(KEYS):
-       break;
- 
-     case TYPEMX(PARTNS):
-       break;
- 
-     case TYPEMX(REF_CONSTRNTS):
-       break;
- 
-     case TYPEMX(TABLE):
-       {
- 	CASTMX(table);
- 	deleteTreeMX(table->columns_desc);
- 	deleteTreeMX(table->views_desc);
- 	deleteTreeMX(table->files_desc);
- 	deleteTreeMX(table->indexes_desc);
- 	deleteTreeMX(table->constrnts_desc);
- 	if (table->constrnts_tables_desc != top)
- 	  deleteTreeMX(table->constrnts_tables_desc);
- 	deleteTreeMX(table->referenced_tables_desc);
- 	deleteTreeMX(table->referencing_tables_desc);
- 	deleteTreeMX(table->histograms_desc);
-       }
-       break;
- 
-     case TYPEMX(VIEW):
-       break;
- 
-     default:
-       {
- 	cerr << "ReadTableDef: memory leak at node type " << top->NODETYPE_MX
- 	     << endl;
-       }
-       break;
-     }  // switch
- 
-   deleteTreeMX (top->header.next);
-   NADELETEBASIC(top, HEAP);
- 
- } // deleteTreeWMX
--

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/cd3d7e7b/core/sql/sqlcat/TrafDDLdesc.cpp
----------------------------------------------------------------------
diff --cc core/sql/sqlcat/TrafDDLdesc.cpp
index 0000000,112bfac..977be16
mode 000000,100644..100644
--- a/core/sql/sqlcat/TrafDDLdesc.cpp
+++ b/core/sql/sqlcat/TrafDDLdesc.cpp
@@@ -1,0 -1,617 +1,619 @@@
+ /**********************************************************************
+ // @@@ START COPYRIGHT @@@
+ //
+ // Licensed to the Apache Software Foundation (ASF) under one
+ // or more contributor license agreements.  See the NOTICE file
+ // distributed with this work for additional information
+ // regarding copyright ownership.  The ASF licenses this file
+ // to you under the Apache License, Version 2.0 (the
+ // "License"); you may not use this file except in compliance
+ // with the License.  You may obtain a copy of the License at
+ //
+ //   http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing,
+ // software distributed under the License is distributed on an
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ // KIND, either express or implied.  See the License for the
+ // specific language governing permissions and limitations
+ // under the License.
+ //
+ // @@@ END COPYRIGHT @@@
+ //
+ **********************************************************************/
+ 
+ #include "TrafDDLdesc.h"
+ #include "CmpCommon.h"
+ 
+ // -----------------------------------------------------------------------
+ // Allocate one of the primitive structs and initialize to all zeroes.
+ // Uses HEAP (StatementHeap) of CmpCommon or space.
+ // -----------------------------------------------------------------------
+ TrafDesc *TrafAllocateDDLdesc(desc_nodetype nodetype, Space * space)
+ {
+   size_t size = 0;
+   TrafDesc * desc_ptr = NULL;
+ 
+   switch (nodetype)
+     {
+     case DESC_CHECK_CONSTRNTS_TYPE:
+       desc_ptr = new GENHEAP(space) TrafCheckConstrntsDesc();
+       break;
+     case DESC_COLUMNS_TYPE:
+       desc_ptr = new GENHEAP(space) TrafColumnsDesc();
+       break;
+     case DESC_CONSTRNTS_TYPE:
+       desc_ptr = new GENHEAP(space) TrafConstrntsDesc();
+       break;
+     case DESC_CONSTRNT_KEY_COLS_TYPE:
+       desc_ptr = new GENHEAP(space) TrafConstrntKeyColsDesc();
+       break;
+     case DESC_FILES_TYPE:
+       desc_ptr = new GENHEAP(space) TrafFilesDesc();
+       break;
+     case DESC_HBASE_RANGE_REGION_TYPE:
+       desc_ptr = new GENHEAP(space) TrafHbaseRegionDesc();
+       break;
+     case DESC_HISTOGRAM_TYPE:
+       desc_ptr = new GENHEAP(space) TrafHistogramDesc();
+       break;
+     case DESC_HIST_INTERVAL_TYPE:
+       desc_ptr = new GENHEAP(space) TrafHistIntervalDesc();
+       break;
+     case DESC_INDEXES_TYPE:
+       desc_ptr = new GENHEAP(space) TrafIndexesDesc();
+       break;
+     case DESC_KEYS_TYPE:
+       desc_ptr = new GENHEAP(space) TrafKeysDesc();
+       break;
+     case DESC_LIBRARY_TYPE:
+       desc_ptr = new GENHEAP(space) TrafLibraryDesc();
+       break;
+      case DESC_PARTNS_TYPE:
+       desc_ptr = new GENHEAP(space) TrafPartnsDesc();
+       break;
+     case DESC_REF_CONSTRNTS_TYPE:
+       desc_ptr = new GENHEAP(space) TrafRefConstrntsDesc();
+       break;
+     case DESC_ROUTINE_TYPE:
+       desc_ptr = new GENHEAP(space) TrafRoutineDesc();
+       break;
+     case DESC_SEQUENCE_GENERATOR_TYPE:   
+       desc_ptr = new GENHEAP(space) TrafSequenceGeneratorDesc();
+       break;
+     case DESC_TABLE_TYPE:
+       desc_ptr = new GENHEAP(space) TrafTableDesc();
+       break;
+     case DESC_VIEW_TYPE:
+       desc_ptr = new GENHEAP(space) TrafViewDesc();
+       break;	       
+     case DESC_USING_MV_TYPE: 
+       desc_ptr = new GENHEAP(space) TrafUsingMvDesc();
+       break;
+     default:
+       assert(FALSE);
+       break;
+     }
+ 
+   // if not being allocated from space, memset all bytes to 0.
+   // If allocated from space, it will be set to 0 during space allocation.
+   if (! space)
+     memset((char*)desc_ptr+sizeof(TrafDesc), 0, 
+            desc_ptr->getClassSize()-sizeof(TrafDesc));
+ 
+   return desc_ptr;
+ 
+ }
+ 
+ TrafDesc::TrafDesc(UInt16 nodeType) 
+   : NAVersionedObject(nodeType),
+     nodetype(nodeType),
+     version(CURR_VERSION),
+     descFlags(0),
+     next(NULL)
+ {}
+ 
+ Lng32 TrafDesc::validateSize()
+ {
+   if (getImageSize() != getClassSize())
+     return -1;
+ 
+   return 0;
+ }
+ 
+ Lng32 TrafDesc::validateVersion()
+ {
+   if (version != CURR_VERSION)
+     return -1;
+ 
+   return 0;
+ }
+ 
+ Lng32 TrafDesc::migrateToNewVersion(
+      NAVersionedObject *&newImage)
+ {
+   short tempimagesize = getClassSize();
+   // -----------------------------------------------------------------
+   // The base class implementation of migrateToNewVersion() is only
+   // called with newImage == NULL when the same function is not
+   // redefined at the subclass. That means no new version of that
+   // subclass has been invented yet.
+   // -----------------------------------------------------------------
+   if (newImage == NULL)
+     {
+       if (validateSize())
+         return -1;
+ 
+       if (validateVersion())
+         return -1;
+     }
+ 
+   return NAVersionedObject::migrateToNewVersion(newImage);
+ }
+ 
+ char *TrafDesc::findVTblPtr(short classID)
+ {
+   char *vtblptr = NULL;
+ 
+   switch (classID)
+     {
+     case DESC_CHECK_CONSTRNTS_TYPE:
+       GetVTblPtr(vtblptr, TrafCheckConstrntsDesc);
+       break;
+     case DESC_COLUMNS_TYPE:
+       GetVTblPtr(vtblptr, TrafColumnsDesc);
+       break;
+     case DESC_CONSTRNTS_TYPE:
+       GetVTblPtr(vtblptr, TrafConstrntsDesc);
+       break;
+     case DESC_CONSTRNT_KEY_COLS_TYPE:
+       GetVTblPtr(vtblptr, TrafConstrntKeyColsDesc);
+       break;
+     case DESC_FILES_TYPE:
+       GetVTblPtr(vtblptr, TrafFilesDesc);
+       break;
+     case DESC_HBASE_RANGE_REGION_TYPE:
+       GetVTblPtr(vtblptr, TrafHbaseRegionDesc);
+       break;
+     case DESC_HISTOGRAM_TYPE:
+       GetVTblPtr(vtblptr, TrafHistogramDesc);
+       break;
+     case DESC_HIST_INTERVAL_TYPE:
+       GetVTblPtr(vtblptr, TrafHistIntervalDesc);
+       break;
+     case DESC_INDEXES_TYPE:
+       GetVTblPtr(vtblptr, TrafIndexesDesc);
+       break;
+     case DESC_KEYS_TYPE:
+       GetVTblPtr(vtblptr, TrafKeysDesc);
+       break;
+     case DESC_LIBRARY_TYPE:
+       GetVTblPtr(vtblptr, TrafLibraryDesc);
+       break;
+      case DESC_PARTNS_TYPE:
+       GetVTblPtr(vtblptr, TrafPartnsDesc);
+       break;
+     case DESC_REF_CONSTRNTS_TYPE:
+       GetVTblPtr(vtblptr, TrafRefConstrntsDesc);
+       break;
+     case DESC_ROUTINE_TYPE:
+       GetVTblPtr(vtblptr, TrafRoutineDesc);
+       break;
+     case DESC_SEQUENCE_GENERATOR_TYPE:   
+       GetVTblPtr(vtblptr, TrafSequenceGeneratorDesc);
+       break;
+     case DESC_TABLE_TYPE:
+       GetVTblPtr(vtblptr, TrafTableDesc);
+       break;
+     case DESC_VIEW_TYPE:
+       GetVTblPtr(vtblptr, TrafViewDesc);
+       break;	       
+     case DESC_USING_MV_TYPE: 
+       GetVTblPtr(vtblptr, TrafUsingMvDesc);
+       break;
+     default:
+       assert(FALSE);
+       break;
+     }
+ 
+   return vtblptr;
+ }
+ 
+ // pack and unpack methods for various descriptor structs
+ 
+ Long TrafDesc::pack(void * space)
+ {
+   next.pack(space);
+ 
+   return NAVersionedObject::pack(space);
+ }
+ 
+ Lng32 TrafDesc::unpack(void * base, void * reallocator)
+ {
+   if(next.unpack(base, reallocator)) return -1;
+ 
+   return NAVersionedObject::unpack(base, reallocator);
+ }
+ 
+ Long TrafCheckConstrntsDesc::pack(void * space)
+ {
+   constrnt_text = (constrnt_text ? (char*)(((Space*)space)->convertToOffset(constrnt_text)) : NULL);
+ 
+   return TrafDesc::pack(space);
+ }
+ 
+ Lng32 TrafCheckConstrntsDesc::unpack(void * base, void * reallocator)
+ {
+   constrnt_text = (constrnt_text ? (char*)((char*)base - (Long)constrnt_text) : NULL);
+ 
+   return TrafDesc::unpack(base, reallocator);
+ }
+ 
+ Long TrafColumnsDesc::pack(void * space)
+ {
+   colname = (colname ? (char*)(((Space*)space)->convertToOffset(colname)) : NULL);
+ 
+   pictureText = (pictureText ? (char*)(((Space*)space)->convertToOffset(pictureText)) : NULL);
+ 
+   defaultvalue = (defaultvalue ? (char*)(((Space*)space)->convertToOffset(defaultvalue)) : NULL);
+   heading = (heading ? (char*)(((Space*)space)->convertToOffset(heading)) : NULL);
+   computed_column_text = (computed_column_text ? (char*)(((Space*)space)->convertToOffset(computed_column_text)) : NULL);
+ 
+   hbaseColFam = (hbaseColFam ? (char*)(((Space*)space)->convertToOffset(hbaseColFam)) : NULL);
+   hbaseColQual = (hbaseColQual ? (char*)(((Space*)space)->convertToOffset(hbaseColQual)) : NULL);
+ 
+   return TrafDesc::pack(space);
+ }
+ 
+ Lng32 TrafColumnsDesc::unpack(void * base, void * reallocator)
+ {
+   colname = (colname ? (char*)((char*)base - (Long)colname) : NULL);
+ 
+   pictureText = (pictureText ? (char*)((char*)base - (Long)pictureText) : NULL);
+ 
+   defaultvalue = (defaultvalue ? (char*)((char*)base - (Long)defaultvalue) : NULL);
+   heading = (heading ? (char*)((char*)base - (Long)heading) : NULL);
+   computed_column_text = (computed_column_text ? (char*)((char*)base - (Long)computed_column_text) : NULL);
+ 
+   hbaseColFam = (hbaseColFam ? (char*)((char*)base - (Long)hbaseColFam) : NULL);
+   hbaseColQual = (hbaseColQual ? (char*)((char*)base - (Long)hbaseColQual) : NULL);
+ 
+   return TrafDesc::unpack(base, reallocator);
+ }
+ 
+ Long TrafConstrntsDesc::pack(void * space)
+ {
+   constrntname = (constrntname ? (char*)(((Space*)space)->convertToOffset(constrntname)) : NULL);
+   tablename = (tablename ? (char*)(((Space*)space)->convertToOffset(tablename)) : NULL);
+   
+   check_constrnts_desc.pack(space);
+   constr_key_cols_desc.pack(space);
+   referenced_constrnts_desc.pack(space);
+   referencing_constrnts_desc.pack(space);
+ 
+   return TrafDesc::pack(space);
+ }
+ 
+ Lng32 TrafConstrntsDesc::unpack(void * base, void * reallocator)
+ {
+   constrntname = (constrntname ? (char*)((char*)base - (Long)constrntname) : NULL);
+   tablename = (tablename ? (char*)((char*)base - (Long)tablename) : NULL);
+ 
+   if (check_constrnts_desc.unpack(base, reallocator)) return -1;
+   if (constr_key_cols_desc.unpack(base, reallocator)) return -1;
+   if (referenced_constrnts_desc.unpack(base, reallocator)) return -1;
+   if (referencing_constrnts_desc.unpack(base, reallocator)) return -1;
+ 
+   return TrafDesc::unpack(base, reallocator);
+ }
+ 
+ Long TrafConstrntKeyColsDesc::pack(void * space)
+ {
+   colname = (colname ? (char*)(((Space*)space)->convertToOffset(colname)) : NULL);
+ 
+   return TrafDesc::pack(space);
+ }
+ 
+ Lng32 TrafConstrntKeyColsDesc::unpack(void * base, void * reallocator)
+ {
+   colname = (colname ? (char*)((char*)base - (Long)colname) : NULL);
+ 
+   return TrafDesc::unpack(base, reallocator);
+ }
+ 
+ 
+ Long TrafFilesDesc::pack(void * space)
+ {
+   partns_desc.pack(space);
+ 
+   return TrafDesc::pack(space);
+ }
+ 
+ Lng32 TrafFilesDesc::unpack(void * base, void * reallocator)
+ {
+   if (partns_desc.unpack(base, reallocator)) return -1;
+ 
+   return TrafDesc::unpack(base, reallocator);
+ }
+ 
+ Long TrafHbaseRegionDesc::pack(void * space)
+ {
+   beginKey = (beginKey ? (char*)(((Space*)space)->convertToOffset(beginKey)) : NULL);
+   endKey = (endKey ? (char*)(((Space*)space)->convertToOffset(endKey)) : NULL);
+ 
+   return TrafDesc::pack(space);
+ }
+ 
+ Lng32 TrafHbaseRegionDesc::unpack(void * base, void * reallocator)
+ {
+   beginKey = (beginKey ? (char*)((char*)base - (Long)beginKey) : NULL);
+   endKey = (endKey ? (char*)((char*)base - (Long)endKey) : NULL);
+ 
+   return TrafDesc::unpack(base, reallocator);
+ }
+ 
+ Long TrafHistogramDesc::pack(void * space)
+ {
+   tablename = (tablename ? (char*)(((Space*)space)->convertToOffset(tablename)) : NULL);
+   histid = (histid ? (char*)(((Space*)space)->convertToOffset(histid)) : NULL);
+   highval = (highval ? (char*)(((Space*)space)->convertToOffset(highval)) : NULL);
+   lowval = (lowval ? (char*)(((Space*)space)->convertToOffset(lowval)) : NULL);
+ 
+   hist_interval_desc.pack(space);
+ 
+   return TrafDesc::pack(space);
+ }
+ 
+ Lng32 TrafHistogramDesc::unpack(void * base, void * reallocator)
+ {
+   tablename = (tablename ? (char*)((char*)base - (Long)tablename) : NULL);
+   histid = (histid ? (char*)((char*)base - (Long)histid) : NULL);
+   highval = (highval ? (char*)((char*)base - (Long)highval) : NULL);
+   lowval = (lowval ? (char*)((char*)base - (Long)lowval) : NULL);
+ 
+   if (hist_interval_desc.unpack(base, reallocator)) return -1;
+   
+   return TrafDesc::unpack(base, reallocator);
+ }
+ 
+ Long TrafHistIntervalDesc::pack(void * space)
+ {
+   histid = (histid ? (char*)(((Space*)space)->convertToOffset(histid)) : NULL);
+   intboundary = (intboundary ? (char*)(((Space*)space)->convertToOffset(intboundary)) : NULL);
+ 
+   return TrafDesc::pack(space);
+ }
+ 
+ Lng32 TrafHistIntervalDesc::unpack(void * base, void * reallocator)
+ {
+   histid = (histid ? (char*)((char*)base - (Long)histid) : NULL);
+   intboundary = (intboundary ? (char*)((char*)base - (Long)intboundary) : NULL);
+ 
+   return TrafDesc::unpack(base, reallocator);
+ }
+ 
+ Long TrafIndexesDesc::pack(void * space)
+ {
+   tablename = (tablename ? (char*)(((Space*)space)->convertToOffset(tablename)) : NULL);
+   indexname = (indexname ? (char*)(((Space*)space)->convertToOffset(indexname)) : NULL);
+   hbaseCreateOptions = (hbaseCreateOptions ? (char*)(((Space*)space)->convertToOffset(hbaseCreateOptions)) : NULL);
+ 
+   files_desc.pack(space);
+   keys_desc.pack(space);
+   non_keys_desc.pack(space);
+ 
+   return TrafDesc::pack(space);
+ }
+ 
+ Lng32 TrafIndexesDesc::unpack(void * base, void * reallocator)
+ {
+   tablename = (tablename ? (char*)((char*)base - (Long)tablename) : NULL);
+   indexname = (indexname ? (char*)((char*)base - (Long)indexname) : NULL);
+   hbaseCreateOptions = (hbaseCreateOptions ? (char*)((char*)base - (Long)hbaseCreateOptions) : NULL);
+ 
+   if (files_desc.unpack(base, reallocator)) return -1;
+   if (keys_desc.unpack(base, reallocator)) return -1;
+   if (non_keys_desc.unpack(base, reallocator)) return -1;
+ 
+   return TrafDesc::unpack(base, reallocator);
+ }
+ 
+ Long TrafKeysDesc::pack(void * space)
+ {
+   keyname = (keyname ? (char*)(((Space*)space)->convertToOffset(keyname)) : NULL);
+   hbaseColFam = (hbaseColFam ? (char*)(((Space*)space)->convertToOffset(hbaseColFam)) : NULL);
+   hbaseColQual = (hbaseColQual ? (char*)(((Space*)space)->convertToOffset(hbaseColQual)) : NULL);
+ 
+   return TrafDesc::pack(space);
+ }
+ 
+ Lng32 TrafKeysDesc::unpack(void * base, void * reallocator)
+ {
+   keyname = (keyname ? (char*)((char*)base - (Long)keyname) : NULL);
+   hbaseColFam = (hbaseColFam ? (char*)((char*)base - (Long)hbaseColFam) : NULL);
+   hbaseColQual = (hbaseColQual ? (char*)((char*)base - (Long)hbaseColQual) : NULL);
+ 
+   return TrafDesc::unpack(base, reallocator);
+ }
+ 
+ Long TrafLibraryDesc::pack(void * space)
+ {
+   libraryName = (libraryName ? (char*)(((Space*)space)->convertToOffset(libraryName)) : NULL);
+   libraryFilename = (libraryFilename ? (char*)(((Space*)space)->convertToOffset(libraryFilename)) : NULL);
+ 
+   return TrafDesc::pack(space);
+ }
+ 
+ Lng32 TrafLibraryDesc::unpack(void * base, void * reallocator)
+ {
+   libraryName = (libraryName ? (char*)((char*)base - (Long)libraryName) : NULL);
+   libraryFilename = (libraryFilename ? (char*)((char*)base - (Long)libraryFilename) : NULL);
+ 
+   return TrafDesc::unpack(base, reallocator);
+ }
+ 
+ Long TrafPartnsDesc::pack(void * space)
+ {
+   tablename = (tablename ? (char*)(((Space*)space)->convertToOffset(tablename)) : NULL);
+   partitionname = (partitionname ? (char*)(((Space*)space)->convertToOffset(partitionname)) : NULL);
+   logicalpartitionname = (logicalpartitionname ? (char*)(((Space*)space)->convertToOffset(logicalpartitionname)) : NULL);
+   firstkey = (firstkey ? (char*)(((Space*)space)->convertToOffset(firstkey)) : NULL);
+   encodedkey = (encodedkey ? (char*)(((Space*)space)->convertToOffset(encodedkey)) : NULL);
+   lowKey = (lowKey ? (char*)(((Space*)space)->convertToOffset(lowKey)) : NULL);
+   highKey = (highKey ? (char*)(((Space*)space)->convertToOffset(highKey)) : NULL);
+   givenname = (givenname ? (char*)(((Space*)space)->convertToOffset(givenname)) : NULL);
+ 
+   return TrafDesc::pack(space);
+ }
+ 
+ Lng32 TrafPartnsDesc::unpack(void * base, void * reallocator)
+ {
+   tablename = (tablename ? (char*)((char*)base - (Long)tablename) : NULL);
+   partitionname = (partitionname ? (char*)((char*)base - (Long)partitionname) : NULL);
+   logicalpartitionname = (logicalpartitionname ? (char*)((char*)base - (Long)logicalpartitionname) : NULL);
+   firstkey = (firstkey ? (char*)((char*)base - (Long)firstkey) : NULL);
+   encodedkey = (encodedkey ? (char*)((char*)base - (Long)encodedkey) : NULL);
+   lowKey = (lowKey ? (char*)((char*)base - (Long)lowKey) : NULL);
+   highKey = (highKey ? (char*)((char*)base - (Long)highKey) : NULL);
+   givenname = (givenname ? (char*)((char*)base - (Long)givenname) : NULL);
+ 
+   return TrafDesc::unpack(base, reallocator);
+ }
+ 
+ Long TrafRefConstrntsDesc::pack(void * space)
+ {
+   constrntname = (constrntname ? (char*)(((Space*)space)->convertToOffset(constrntname)) : NULL);
+   tablename = (tablename ? (char*)(((Space*)space)->convertToOffset(tablename)) : NULL);
+ 
+   return TrafDesc::pack(space);
+ }
+ 
+ Lng32 TrafRefConstrntsDesc::unpack(void * base, void * reallocator)
+ {
+   constrntname = (constrntname ? (char*)((char*)base - (Long)constrntname) : NULL);
+   tablename = (tablename ? (char*)((char*)base - (Long)tablename) : NULL);
+ 
+   return TrafDesc::unpack(base, reallocator);
+ }
+ 
+ Long TrafRoutineDesc::pack(void * space)
+ {
+   routineName = (routineName ? (char*)(((Space*)space)->convertToOffset(routineName)) : NULL);
+   externalName = (externalName ? (char*)(((Space*)space)->convertToOffset(externalName)) : NULL);
+   librarySqlName = (librarySqlName ? (char*)(((Space*)space)->convertToOffset(librarySqlName)) : NULL);
+   libraryFileName = (libraryFileName ? (char*)(((Space*)space)->convertToOffset(libraryFileName)) : NULL);
+   signature = (signature ? (char*)(((Space*)space)->convertToOffset(signature)) : NULL);
+ 
+   params.pack(space);
+ 
+   return TrafDesc::pack(space);
+ }
+ 
+ Lng32 TrafRoutineDesc::unpack(void * base, void * reallocator)
+ {
+   routineName = (routineName ? (char*)((char*)base - (Long)routineName) : NULL);
+   externalName = (externalName ? (char*)((char*)base - (Long)externalName) : NULL);
+   librarySqlName = (librarySqlName ? (char*)((char*)base - (Long)librarySqlName) : NULL);
+   libraryFileName = (libraryFileName ? (char*)((char*)base - (Long)libraryFileName) : NULL);
+   signature = (signature ? (char*)((char*)base - (Long)signature) : NULL);
+ 
+   if (params.unpack(base, reallocator)) return -1;
+ 
+   return TrafDesc::unpack(base, reallocator);
+ }
+ 
+ Long TrafSequenceGeneratorDesc::pack(void * space)
+ {
+   sgLocation = (sgLocation ? (char*)(((Space*)space)->convertToOffset(sgLocation)) : NULL);
+ 
+   return TrafDesc::pack(space);
+ }
+ 
+ Lng32 TrafSequenceGeneratorDesc::unpack(void * base, void * reallocator)
+ {
+   sgLocation = (sgLocation ? (char*)((char*)base - (Long)sgLocation) : NULL);
+ 
+   return TrafDesc::unpack(base, reallocator);
+ }
+ 
+ Long TrafTableDesc::pack(void * space)
+ {
+   tablename = (tablename ? (char*)(((Space*)space)->convertToOffset(tablename)) : NULL);
+   snapshotName = (snapshotName ? (char*)(((Space*)space)->convertToOffset(snapshotName)) : NULL);
+   default_col_fam = (default_col_fam ? (char*)(((Space*)space)->convertToOffset(default_col_fam)) : NULL);
+   all_col_fams = (all_col_fams ? (char*)(((Space*)space)->convertToOffset(all_col_fams)) : NULL);
+ 
+   columns_desc.pack(space);
+   indexes_desc.pack(space);
+   constrnts_desc.pack(space);
+   views_desc.pack(space);
+   constrnts_tables_desc.pack(space);
+   referenced_tables_desc.pack(space);
+   referencing_tables_desc.pack(space);
+   histograms_desc.pack(space);
+   files_desc.pack(space);
+   hbase_regionkey_desc.pack(space);
+   sequence_generator_desc.pack(space);
+ 
+   return TrafDesc::pack(space);  
+ }
+ 
+ Lng32 TrafTableDesc::unpack(void * base, void * reallocator)
+ {
+   tablename = (tablename ? (char*)((char*)base - (Long)tablename) : NULL);
+   snapshotName = (snapshotName ? (char*)((char*)base - (Long)snapshotName) : NULL);
+   default_col_fam = (default_col_fam ? (char*)((char*)base - (Long)default_col_fam) : NULL);
+   all_col_fams = (all_col_fams ? (char*)((char*)base - (Long)all_col_fams) : NULL);
+ 
+   if (columns_desc.unpack(base, reallocator)) return -1;
+   if (indexes_desc.unpack(base, reallocator)) return -1;
+   if (constrnts_desc.unpack(base, reallocator)) return -1;
+   if (views_desc.unpack(base, reallocator)) return -1;
+   if (constrnts_tables_desc.unpack(base, reallocator)) return -1;
+   if (referenced_tables_desc.unpack(base, reallocator)) return -1;
+   if (referencing_tables_desc.unpack(base, reallocator)) return -1;
+   if (histograms_desc.unpack(base, reallocator)) return -1;
+   if (files_desc.unpack(base, reallocator)) return -1;
+   if (hbase_regionkey_desc.unpack(base, reallocator)) return -1;
+   if (sequence_generator_desc.unpack(base, reallocator)) return -1;
+ 
+   return TrafDesc::unpack(base, reallocator);
+ }
+ 
+ Long TrafUsingMvDesc::pack(void * space)
+ {
+   mvName = (mvName ? (char*)(((Space*)space)->convertToOffset(mvName)) : NULL);
+ 
+   return TrafDesc::pack(space);
+ }
+ 
+ Lng32 TrafUsingMvDesc::unpack(void * base, void * reallocator)
+ {
+   mvName = (mvName ? (char*)((char*)base - (Long)mvName) : NULL);
+ 
+   return TrafDesc::unpack(base, reallocator);
+ }
+ 
+ Long TrafViewDesc::pack(void * space)
+ {
+   viewname = (viewname ? (char*)(((Space*)space)->convertToOffset(viewname)) : NULL);
+   viewfilename = (viewfilename ? (char*)(((Space*)space)->convertToOffset(viewfilename)) : NULL);
+ 
+   viewtext = (viewtext ? (char*)(((Space*)space)->convertToOffset(viewtext)) : NULL);
+   viewchecktext = (viewchecktext ? (char*)(((Space*)space)->convertToOffset(viewchecktext)) : NULL);
++  viewcolusages = (viewcolusages ? (char*)(((Space*)space)->convertToOffset(viewcolusages)) : NULL);
+ 
+   return TrafDesc::pack(space);
+ }
+ 
+ Lng32 TrafViewDesc::unpack(void * base, void * reallocator)
+ {
+   viewname = (viewname ? (char*)((char*)base - (Long)viewname) : NULL);
+   viewfilename = (viewfilename ? (char*)((char*)base - (Long)viewfilename) : NULL);
+ 
+   viewtext = (viewtext ? (char*)((char*)base - (Long)viewtext) : NULL);
+   viewchecktext = (viewchecktext ? (char*)((char*)base - (Long)viewchecktext) : NULL);
++  viewcolusages = (viewcolusages ? (char*)((char*)base - (Long)viewcolusages) : NULL);
+ 
+   return TrafDesc::unpack(base, reallocator);
+ }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/cd3d7e7b/core/sql/sqlcat/TrafDDLdesc.h
----------------------------------------------------------------------
diff --cc core/sql/sqlcat/TrafDDLdesc.h
index 0000000,3a599e6..3b99c16
mode 000000,100644..100644
--- a/core/sql/sqlcat/TrafDDLdesc.h
+++ b/core/sql/sqlcat/TrafDDLdesc.h
@@@ -1,0 -1,1120 +1,1121 @@@
+ /**********************************************************************
+ // @@@ START COPYRIGHT @@@
+ //
+ // Licensed to the Apache Software Foundation (ASF) under one
+ // or more contributor license agreements.  See the NOTICE file
+ // distributed with this work for additional information
+ // regarding copyright ownership.  The ASF licenses this file
+ // to you under the Apache License, Version 2.0 (the
+ // "License"); you may not use this file except in compliance
+ // with the License.  You may obtain a copy of the License at
+ //
+ //   http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing,
+ // software distributed under the License is distributed on an
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ // KIND, either express or implied.  See the License for the
+ // specific language governing permissions and limitations
+ // under the License.
+ //
+ // @@@ END COPYRIGHT @@@
+ //
+ **********************************************************************/
+ #ifndef TRAF_DDL_DESC_H
+ #define TRAF_DDL_DESC_H
+ 
+ #include "Platform.h"
+ #include "NAVersionedObject.h"
+ #include "charinfo.h"
+ #include "ComSmallDefs.h"
+ 
+ #define GENHEAP(h)    (h ? (NAMemory*)h : CmpCommon::statementHeap())
+ 
+ enum ConstraintType { UNIQUE_CONSTRAINT, PRIMARY_KEY_CONSTRAINT, REF_CONSTRAINT,
+ 		      CHECK_CONSTRAINT
+ 		    };
+ 
+ enum desc_nodetype {
+   DESC_UNKNOWN_TYPE = 0,
+   DESC_CHECK_CONSTRNTS_TYPE,
+   DESC_COLUMNS_TYPE,
+   DESC_CONSTRNTS_TYPE,
+   DESC_CONSTRNT_KEY_COLS_TYPE,
+   DESC_FILES_TYPE,
+   DESC_HBASE_RANGE_REGION_TYPE,
+   DESC_HISTOGRAM_TYPE,
+   DESC_HIST_INTERVAL_TYPE,
+   DESC_INDEXES_TYPE,
+   DESC_KEYS_TYPE,
+   DESC_PARTNS_TYPE,
+   DESC_REF_CONSTRNTS_TYPE,
+   DESC_TABLE_TYPE,
+   DESC_USING_MV_TYPE,  // MV  -- marks an MV using this object
+   DESC_VIEW_TYPE,
+   DESC_SCHEMA_LABEL_TYPE,
+   DESC_SEQUENCE_GENERATOR_TYPE,
+   DESC_ROUTINE_TYPE,
+   DESC_LIBRARY_TYPE
+ };
+ 
+ class TrafDesc;
+ typedef NAVersionedObjectPtrTempl<TrafDesc> DescStructPtr;
+ 
+ class TrafCheckConstrntsDesc;
+ class TrafColumnsDesc;
+ class TrafConstrntsDesc;
+ class TrafConstrntKeyColsDesc;
+ class TrafHbaseRegionDesc;
+ class TrafHistogramDesc;
+ class TrafHistIntervalDesc;
+ class TrafFilesDesc;
+ class TrafKeysDesc;
+ class TrafIndexesDesc;
+ class TrafLibraryDesc;
+ class TrafPartnsDesc;
+ class TrafRefConstrntsDesc;
+ class TrafRoutineDesc;
+ class TrafSequenceGeneratorDesc;
+ class TrafTableDesc;
+ class TrafUsingMvDesc;
+ class TrafViewDesc;
+ 
+ class TrafDesc : public NAVersionedObject {
+ public:
+   enum {CURR_VERSION = 1};
+ 
+   TrafDesc(UInt16 nodeType);
+   TrafDesc() : NAVersionedObject(-1) {}
+ 
+   // ---------------------------------------------------------------------
+   // Redefine virtual functions required for Versioning.
+   //----------------------------------------------------------------------
+   virtual unsigned char getClassVersionID()
+   {
+     return 1;
+   }
+ 
+   virtual void populateImageVersionIDArray()
+   {
+     setImageVersionID(0,getClassVersionID());
+   }
+ 
+   virtual short getClassSize()      { return (short)sizeof(TrafDesc); }
+ 
+   virtual Lng32 migrateToNewVersion(NAVersionedObject *&newImage);
+ 
+   virtual char *findVTblPtr(short classID);
+ 
+   virtual Long pack(void *space);
+   virtual Lng32 unpack(void * base, void * reallocator);
+ 
+   Lng32 validateSize();
+   Lng32 validateVersion();
+  
+   UInt16 nodetype;
+   UInt16 version;
+   UInt32 descFlags;
+   DescStructPtr next;
+   char* descExtension; // extension of descriptor, if it needs to be extended
+ 
+   virtual TrafCheckConstrntsDesc *checkConstrntsDesc() const { return NULL; }
+   virtual TrafColumnsDesc *columnsDesc() const { return NULL; }
+   virtual TrafConstrntsDesc *constrntsDesc() const { return NULL; }
+   virtual TrafConstrntKeyColsDesc *constrntKeyColsDesc() const { return NULL; }
+   virtual TrafFilesDesc *filesDesc() const { return NULL; }
+   virtual TrafHbaseRegionDesc *hbaseRegionDesc() const { return NULL; }
+   virtual TrafHistogramDesc *histogramDesc() const { return NULL; }
+   virtual TrafHistIntervalDesc *histIntervalDesc() const { return NULL; }
+   virtual TrafKeysDesc *keysDesc() const { return NULL; }
+   virtual TrafIndexesDesc *indexesDesc() const { return NULL; }
+   virtual TrafLibraryDesc *libraryDesc() const { return NULL; }
+   virtual TrafPartnsDesc *partnsDesc() const { return NULL; }
+   virtual TrafRefConstrntsDesc *refConstrntsDesc() const { return NULL; }
+   virtual TrafRoutineDesc *routineDesc() const { return NULL; }
+   virtual TrafSequenceGeneratorDesc *sequenceGeneratorDesc() const { return NULL; }
+   virtual TrafTableDesc *tableDesc() const { return NULL; }
+   virtual TrafUsingMvDesc *usingMvDesc() const { return NULL; }
+   virtual TrafViewDesc *viewDesc() const { return NULL; }
+ 
+ };
+ 
+ class TrafCheckConstrntsDesc : public TrafDesc {
+ public:
+   TrafCheckConstrntsDesc() : TrafDesc(DESC_CHECK_CONSTRNTS_TYPE)
+   {}
+ 
+   // ---------------------------------------------------------------------
+   // Redefine virtual functions required for Versioning.
+   //----------------------------------------------------------------------
+   virtual unsigned char getClassVersionID()
+   {
+     return 1;
+   }
+ 
+   virtual void populateImageVersionIDArray()
+   {
+     setImageVersionID(0,getClassVersionID());
+   }
+ 
+   virtual short getClassSize()      { return (short)sizeof(TrafCheckConstrntsDesc); }
+  
+   virtual Long pack(void *space);
+   virtual Lng32 unpack(void * base, void * reallocator);
+ 
+   virtual TrafCheckConstrntsDesc *checkConstrntsDesc() const { return (TrafCheckConstrntsDesc*)this; }
+ 
+   char* constrnt_text;
+   char filler[16];
+ };
+ 
+ class TrafColumnsDesc : public TrafDesc {
+ public:
+   TrafColumnsDesc() : TrafDesc(DESC_COLUMNS_TYPE) 
+   {};
+ 
+   // ---------------------------------------------------------------------
+   // Redefine virtual functions required for Versioning.
+   //----------------------------------------------------------------------
+   virtual unsigned char getClassVersionID()
+   {
+     return 1;
+   }
+ 
+   virtual void populateImageVersionIDArray()
+   {
+     setImageVersionID(0,getClassVersionID());
+   }
+ 
+   virtual short getClassSize()      { return (short)sizeof(TrafColumnsDesc); }
+  
+   virtual Long pack(void *space);
+   virtual Lng32 unpack(void * base, void * reallocator);
+ 
+   virtual TrafColumnsDesc *columnsDesc() const { return (TrafColumnsDesc*)this; }
+ 
+   enum ColumnsDescFlags
+     { 
+       NULLABLE           = 0x0001,  
+       ADDED              = 0x0002,
+       UPSHIFTED          = 0x0004,
+       CASEINSENSITIVE    = 0x0008,
+       OPTIONAL           = 0x0010
+     };
+ 
+   void setNullable(NABoolean v) 
+   {(v ? columnsDescFlags |= NULLABLE : columnsDescFlags &= ~NULLABLE); };
+   NABoolean isNullable() { return (columnsDescFlags & NULLABLE) != 0; };
+ 
+   void setAdded(NABoolean v) 
+   {(v ? columnsDescFlags |= ADDED : columnsDescFlags &= ~ADDED); };
+   NABoolean isAdded() { return (columnsDescFlags & ADDED) != 0; };
+ 
+   void setUpshifted(NABoolean v) 
+   {(v ? columnsDescFlags |= UPSHIFTED : columnsDescFlags &= ~UPSHIFTED); };
+   NABoolean isUpshifted() { return (columnsDescFlags & UPSHIFTED) != 0; };
+ 
+   void setCaseInsensitive(NABoolean v) 
+   {(v ? columnsDescFlags |= CASEINSENSITIVE : columnsDescFlags &= ~CASEINSENSITIVE); };
+   NABoolean isCaseInsensitive() { return (columnsDescFlags & CASEINSENSITIVE) != 0; };
+ 
+   void setOptional(NABoolean v) 
+   {(v ? columnsDescFlags |= OPTIONAL : columnsDescFlags &= ~OPTIONAL); };
+   NABoolean isOptional() { return (columnsDescFlags & OPTIONAL) != 0; };
+ 
+   rec_datetime_field datetimeStart() 
+   { return (rec_datetime_field)datetimestart;}
+   rec_datetime_field datetimeEnd() 
+   { return (rec_datetime_field)datetimeend;}
+ 
+   ComColumnDefaultClass defaultClass() 
+   { return (ComColumnDefaultClass)defaultClass_;}
+   void setDefaultClass(ComColumnDefaultClass v)
+   { defaultClass_ = (Int16)v;}
+ 
+   CharInfo::CharSet characterSet() 
+   { return (CharInfo::CharSet)character_set;}
+   CharInfo::CharSet encodingCharset() 
+   { return (CharInfo::CharSet)encoding_charset;}
+   CharInfo::Collation  collationSequence()
+   {return (CharInfo::Collation)collation_sequence; }
+ 
+   ComParamDirection paramDirection() 
+   { return (ComParamDirection)paramDirection_;}
+   void setParamDirection(ComParamDirection v)
+   {paramDirection_ = (Int16)v; }
+ 
+   char* colname;
+ 
+   Int32 colnumber;
+   Int32 datatype;
+ 
+   Int32 offset;
+   Lng32 length;
+ 
+   Lng32 scale;
+   Lng32 precision;
+ 
+   Int16/*rec_datetime_field*/ datetimestart, datetimeend;
+   Int16 datetimefractprec, intervalleadingprec;
+ 
+   Int16/*ComColumnDefaultClass*/ defaultClass_;
+   Int16/*CharInfo::CharSet*/     character_set;
+   Int16/*CharInfo::CharSet*/     encoding_charset;
+   Int16/*CharInfo::Collation*/   collation_sequence;
+ 
+   ULng32 hbaseColFlags;
+   Int16/*ComParamDirection*/ paramDirection_;
+   char colclass; // 'S' -- system generated, 'U' -- user created
+   char filler0;
+ 
+   Int64 colFlags;
+   Int64 columnsDescFlags; // my flags
+ 
+   char* pictureText;
+   char* defaultvalue;
+   char* heading;
+   char* computed_column_text;
+   char* hbaseColFam;
+   char* hbaseColQual;
+ 
+   char filler[24];
+ };
+ 
+ class TrafConstrntKeyColsDesc : public TrafDesc {
+ public:
+   TrafConstrntKeyColsDesc() : TrafDesc(DESC_CONSTRNT_KEY_COLS_TYPE)
+   {}
+ 
+   // ---------------------------------------------------------------------
+   // Redefine virtual functions required for Versioning.
+   //----------------------------------------------------------------------
+   virtual unsigned char getClassVersionID()
+   {
+     return 1;
+   }
+ 
+   virtual void populateImageVersionIDArray()
+   {
+     setImageVersionID(0,getClassVersionID());
+   }
+ 
+   virtual short getClassSize()      { return (short)sizeof(TrafConstrntKeyColsDesc); }
+  
+   virtual Long pack(void *space);
+   virtual Lng32 unpack(void * base, void * reallocator);
+ 
+   virtual TrafConstrntKeyColsDesc *constrntKeyColsDesc() const { return (TrafConstrntKeyColsDesc*)this; }
+ 
+   char* colname;
+   Int32  position;
+ 
+   Int64 constrntKeyColsDescFlags; // my flags
+ 
+   char filler[16];
+ };
+ 
+ class TrafConstrntsDesc : public TrafDesc {
+ public:
+   TrafConstrntsDesc() : TrafDesc(DESC_CONSTRNTS_TYPE)
+   {}
+ 
+   // ---------------------------------------------------------------------
+   // Redefine virtual functions required for Versioning.
+   //----------------------------------------------------------------------
+   virtual unsigned char getClassVersionID()
+   {
+     return 1;
+   }
+ 
+   virtual void populateImageVersionIDArray()
+   {
+     setImageVersionID(0,getClassVersionID());
+   }
+ 
+   virtual short getClassSize()      { return (short)sizeof(TrafConstrntsDesc); }
+  
+   virtual Long pack(void *space);
+   virtual Lng32 unpack(void * base, void * reallocator);
+ 
+   virtual TrafConstrntsDesc *constrntsDesc() const { return (TrafConstrntsDesc*)this; }
+ 
+   enum ConstrntsDescFlags
+     { 
+       ENFORCED           = 0x0001
+     };
+ 
+   void setEnforced(NABoolean v) 
+   {(v ? constrntsDescFlags |= ENFORCED : constrntsDescFlags &= ~ENFORCED); };
+   NABoolean isEnforced() { return (constrntsDescFlags & ENFORCED) != 0; };
+ 
+   char* constrntname;
+   char* tablename;
+ 
+   Int16 /*ConstraintType*/ type;
+   Int16 fillerInt16;
+   Int32  colcount;
+ 
+   Int64 constrntsDescFlags; // my flags
+ 
+   DescStructPtr check_constrnts_desc;
+   DescStructPtr constr_key_cols_desc;
+   DescStructPtr referenced_constrnts_desc;
+   DescStructPtr referencing_constrnts_desc;
+ 
+   char filler[24];
+ };
+ 
+ class TrafFilesDesc : public TrafDesc {
+ public:
+   TrafFilesDesc() : TrafDesc(DESC_FILES_TYPE)
+   {}
+ 
+   // ---------------------------------------------------------------------
+   // Redefine virtual functions required for Versioning.
+   //----------------------------------------------------------------------
+   virtual unsigned char getClassVersionID()
+   {
+     return 1;
+   }
+ 
+   virtual void populateImageVersionIDArray()
+   {
+     setImageVersionID(0,getClassVersionID());
+   }
+ 
+   virtual short getClassSize()      { return (short)sizeof(TrafFilesDesc); }
+  
+   virtual Long pack(void *space);
+   virtual Lng32 unpack(void * base, void * reallocator);
+ 
+   virtual TrafFilesDesc *filesDesc() const { return (TrafFilesDesc*)this; }
+ 
+   enum FilesDescFlags
+     { 
+       AUDITED           = 0x0001
+     };
+ 
+   void setAudited(NABoolean v) 
+   {(v ? filesDescFlags |= AUDITED : filesDescFlags &= ~AUDITED); };
+   NABoolean isAudited() { return (filesDescFlags & AUDITED) != 0; };
+ 
+   Int64 filesDescFlags; // my flags
+   DescStructPtr partns_desc;
+ };
+ 
+ class TrafHbaseRegionDesc : public TrafDesc {
+ public:
+   TrafHbaseRegionDesc() : TrafDesc(DESC_HBASE_RANGE_REGION_TYPE)
+   {}
+ 
+   // ---------------------------------------------------------------------
+   // Redefine virtual functions required for Versioning.
+   //----------------------------------------------------------------------
+   virtual unsigned char getClassVersionID()
+   {
+     return 1;
+   }
+ 
+   virtual void populateImageVersionIDArray()
+   {
+     setImageVersionID(0,getClassVersionID());
+   }
+ 
+   virtual short getClassSize()      { return (short)sizeof(TrafHbaseRegionDesc); }
+  
+   virtual Long pack(void *space);
+   virtual Lng32 unpack(void * base, void * reallocator);
+ 
+   virtual TrafHbaseRegionDesc *hbaseRegionDesc() const { return (TrafHbaseRegionDesc*)this; }
+ 
+   Int64  hbaseRegionDescFlags; // my flags
+ 
+   Lng32  beginKeyLen;
+   Lng32  endKeyLen;
+ 
+   char*  beginKey;
+   char*  endKey;
+ 
+   char filler[16];
+ };
+ 
+ class TrafHistogramDesc : public TrafDesc {
+ public:
+   TrafHistogramDesc() : TrafDesc(DESC_HISTOGRAM_TYPE)
+   {}
+ 
+   // ---------------------------------------------------------------------
+   // Redefine virtual functions required for Versioning.
+   //----------------------------------------------------------------------
+   virtual unsigned char getClassVersionID()
+   {
+     return 1;
+   }
+ 
+   virtual void populateImageVersionIDArray()
+   {
+     setImageVersionID(0,getClassVersionID());
+   }
+ 
+   virtual short getClassSize()      { return (short)sizeof(TrafHistogramDesc); }
+  
+   virtual Long pack(void *space);
+   virtual Lng32 unpack(void * base, void * reallocator);
+ 
+   virtual TrafHistogramDesc *histogramDesc() const { return (TrafHistogramDesc*)this; }
+ 
+   char*   tablename;
+   char*   histid;
+ 
+   Int32   tablecolnumber;
+   Int32   colposition;
+ 
+   Float32 rowcount;
+   Float32 uec;
+ 
+   char*   highval;
+   char*   lowval;
+ 
+   Int64 histogramDescFlags; // my flags
+ 
+   DescStructPtr hist_interval_desc;
+ 
+   char filler[24];
+ };
+ 
+ class TrafHistIntervalDesc : public TrafDesc {
+ public:
+   TrafHistIntervalDesc() : TrafDesc(DESC_HIST_INTERVAL_TYPE)
+   {}
+ 
+   // ---------------------------------------------------------------------
+   // Redefine virtual functions required for Versioning.
+   //----------------------------------------------------------------------
+   virtual unsigned char getClassVersionID()
+   {
+     return 1;
+   }
+ 
+   virtual void populateImageVersionIDArray()
+   {
+     setImageVersionID(0,getClassVersionID());
+   }
+ 
+   virtual short getClassSize()      { return (short)sizeof(TrafHistIntervalDesc); }
+  
+   virtual Long pack(void *space);
+   virtual Lng32 unpack(void * base, void * reallocator);
+ 
+   virtual TrafHistIntervalDesc *histIntervalDesc() const { return (TrafHistIntervalDesc*)this; }
+ 
+   char*   histid;
+   char*   intboundary;
+ 
+   Float32  rowcount;
+   Float32  uec;
+ 
+   Int32   intnum;
+   Int32   fillerInt32;
+ 
+   Int64 histIntervalDescFlags; // my flags
+ 
+   char filler[16];
+ };
+ 
+ class TrafIndexesDesc : public TrafDesc {
+ public:
+   TrafIndexesDesc() : TrafDesc(DESC_INDEXES_TYPE)
+   {}
+ 
+   // ---------------------------------------------------------------------
+   // Redefine virtual functions required for Versioning.
+   //----------------------------------------------------------------------
+   virtual unsigned char getClassVersionID()
+   {
+     return 1;
+   }
+ 
+   virtual void populateImageVersionIDArray()
+   {
+     setImageVersionID(0,getClassVersionID());
+   }
+ 
+   virtual short getClassSize()      { return (short)sizeof(TrafIndexesDesc); }
+  
+   virtual Long pack(void *space);
+   virtual Lng32 unpack(void * base, void * reallocator);
+ 
+   virtual TrafIndexesDesc *indexesDesc() const { return (TrafIndexesDesc*)this; }
+ 
+   enum IndexesDescFlags
+     { 
+       SYSTEM_TABLE_CODE = 0x0001,  
+       EXPLICIT          = 0x0002,
+       VOLATILE          = 0x0004,
+       IN_MEM_OBJ        = 0x0008,
+       UNIQUE            = 0x0010
+     };
+ 
+   void setSystemTableCode(NABoolean v) 
+   {(v ? indexesDescFlags |= SYSTEM_TABLE_CODE : indexesDescFlags &= ~SYSTEM_TABLE_CODE); };
+   NABoolean isSystemTableCode() { return (indexesDescFlags & SYSTEM_TABLE_CODE) != 0; };
+ 
+   void setExplicit(NABoolean v) 
+   {(v ? indexesDescFlags |= EXPLICIT : indexesDescFlags &= ~EXPLICIT); };
+   NABoolean isExplicit() { return (indexesDescFlags & EXPLICIT) != 0; };
+ 
+   void setVolatile(NABoolean v) 
+   {(v ? indexesDescFlags |= VOLATILE : indexesDescFlags &= ~VOLATILE); };
+   NABoolean isVolatile() { return (indexesDescFlags & VOLATILE) != 0; };
+ 
+   void setInMemoryObject(NABoolean v) 
+   {(v ? indexesDescFlags |= IN_MEM_OBJ : indexesDescFlags &= ~IN_MEM_OBJ); };
+   NABoolean isInMemoryObject() { return (indexesDescFlags & IN_MEM_OBJ) != 0; };
+ 
+   void setUnique(NABoolean v) 
+   {(v ? indexesDescFlags |= UNIQUE : indexesDescFlags &= ~UNIQUE); };
+   NABoolean isUnique() { return (indexesDescFlags & UNIQUE) != 0; };
+ 
+   ComPartitioningScheme partitioningScheme() 
+   { return (ComPartitioningScheme)partitioningScheme_; }
+   void setPartitioningScheme(ComPartitioningScheme v) 
+   { partitioningScheme_ = (Int16)v; }
+   ComRowFormat rowFormat() { return (ComRowFormat)rowFormat_; }
+   void setRowFormat(ComRowFormat v) { rowFormat_ = (Int16)v; }
+ 
+   char* tablename;  // name of the base table
+   char* indexname;  // physical name of index. Different from ext_indexname
+                     // for ARK tables.
+   Int64 indexUID;
+ 
+   Int32 keytag;
+   Int32 record_length;
+   Int32 colcount;
+   Int32 blocksize;
+ 
+   Int16 /*ComPartitioningScheme*/ partitioningScheme_; 
+   Int16 /*ComRowFormat*/          rowFormat_;
+   Lng32 numSaltPartns; // number of salted partns created for a seabase table.
+ 
+   Int64 indexesDescFlags; // my flags
+ 
+   char*  hbaseCreateOptions;
+ 
+   DescStructPtr files_desc;
+ 
+   // Clustering keys columns
+   DescStructPtr keys_desc;
+ 
+   // Columns that are not part of the clustering key.
+   // Used specially for vertical partition column(s).
+   DescStructPtr non_keys_desc;
+ 
+   char filler[24];
+ };
+ 
+ class TrafKeysDesc : public TrafDesc {
+ public:
+   TrafKeysDesc() : TrafDesc(DESC_KEYS_TYPE)
+   {}
+ 
+   // ---------------------------------------------------------------------
+   // Redefine virtual functions required for Versioning.
+   //----------------------------------------------------------------------
+   virtual unsigned char getClassVersionID()
+   {
+     return 1;
+   }
+ 
+   virtual void populateImageVersionIDArray()
+   {
+     setImageVersionID(0,getClassVersionID());
+   }
+ 
+   virtual short getClassSize()      { return (short)sizeof(TrafKeysDesc); }
+  
+   virtual Long pack(void *space);
+   virtual Lng32 unpack(void * base, void * reallocator);
+ 
+   virtual TrafKeysDesc *keysDesc() const { return (TrafKeysDesc*)this; }
+ 
+   enum KeysDescFlags
+     { 
+       DESCENDING           = 0x0001
+     };
+ 
+   void setDescending(NABoolean v) 
+   {(v ? keysDescFlags |= DESCENDING : keysDescFlags &= ~DESCENDING); };
+   NABoolean isDescending() { return (keysDescFlags & DESCENDING) != 0; };
+ 
+   char* keyname;
+   Int32 keyseqnumber;
+   Int32 tablecolnumber;
+ 
+   Int64 keysDescFlags; // my flags
+ 
+   char* hbaseColFam;
+   char* hbaseColQual;
+ 
+   char filler[16];
+ };
+ 
+ class TrafLibraryDesc : public TrafDesc {
+ public:
+   TrafLibraryDesc() : TrafDesc(DESC_LIBRARY_TYPE)
+   {}
+ 
+   // ---------------------------------------------------------------------
+   // Redefine virtual functions required for Versioning.
+   //----------------------------------------------------------------------
+   virtual unsigned char getClassVersionID()
+   {
+     return 1;
+   }
+ 
+   virtual void populateImageVersionIDArray()
+   {
+     setImageVersionID(0,getClassVersionID());
+   }
+ 
+   virtual short getClassSize()      { return (short)sizeof(TrafLibraryDesc); }
+  
+   virtual Long pack(void *space);
+   virtual Lng32 unpack(void * base, void * reallocator);
+ 
+   virtual TrafLibraryDesc *libraryDesc() const { return (TrafLibraryDesc*)this; }
+ 
+   char* libraryName;
+   char* libraryFilename;
+   Int64 libraryUID;
+   Int32 libraryVersion;
+   Int32 libraryOwnerID;
+   Int32 librarySchemaOwnerID;
+ 
+   char filler[20];
+ };
+ 
+ class TrafPartnsDesc : public TrafDesc {
+ public:
+   TrafPartnsDesc() : TrafDesc(DESC_PARTNS_TYPE)
+   {}
+ 
+   // ---------------------------------------------------------------------
+   // Redefine virtual functions required for Versioning.
+   //----------------------------------------------------------------------
+   virtual unsigned char getClassVersionID()
+   {
+     return 1;
+   }
+ 
+   virtual void populateImageVersionIDArray()
+   {
+     setImageVersionID(0,getClassVersionID());
+   }
+ 
+   virtual short getClassSize()      { return (short)sizeof(TrafPartnsDesc); }
+  
+   virtual Long pack(void *space);
+   virtual Lng32 unpack(void * base, void * reallocator);
+ 
+   virtual TrafPartnsDesc *partnsDesc() const { return (TrafPartnsDesc*)this; }
+ 
+   char*  tablename;
+   Int32 primarypartition;
+   char*  partitionname;
+   char*  logicalpartitionname;
+   char*  firstkey;
+   Lng32 firstkeylen;         //soln:10-031112-1256
+   Lng32 encodedkeylen;
+   char*  encodedkey;
+   char*  lowKey;
+   char*  highKey;
+   Int32    indexlevel;
+   Int32  priExt;
+   Int32  secExt;
+   Int32  maxExt;
+   char*  givenname;
+ };
+ 
+ class TrafRefConstrntsDesc : public TrafDesc {
+ public:
+   TrafRefConstrntsDesc() : TrafDesc(DESC_REF_CONSTRNTS_TYPE)
+   {}
+ 
+   // ---------------------------------------------------------------------
+   // Redefine virtual functions required for Versioning.
+   //----------------------------------------------------------------------
+   virtual unsigned char getClassVersionID()
+   {
+     return 1;
+   }
+ 
+   virtual void populateImageVersionIDArray()
+   {
+     setImageVersionID(0,getClassVersionID());
+   }
+ 
+   virtual short getClassSize()      { return (short)sizeof(TrafRefConstrntsDesc); }
+  
+   virtual Long pack(void *space);
+   virtual Lng32 unpack(void * base, void * reallocator);
+ 
+   virtual TrafRefConstrntsDesc *refConstrntsDesc() const { return (TrafRefConstrntsDesc*)this; }
+ 
+   Int64 refConstrntsDescFlags; // my flags
+   char* constrntname;
+   char* tablename;
+ 
+   char filler[16];
+ };
+ 
+ class TrafRoutineDesc : public TrafDesc {
+ public:
+   TrafRoutineDesc() : TrafDesc(DESC_ROUTINE_TYPE)
+   {}
+ 
+   // ---------------------------------------------------------------------
+   // Redefine virtual functions required for Versioning.
+   //----------------------------------------------------------------------
+   virtual unsigned char getClassVersionID()
+   {
+     return 1;
+   }
+ 
+   virtual void populateImageVersionIDArray()
+   {
+     setImageVersionID(0,getClassVersionID());
+   }
+ 
+   virtual short getClassSize()      { return (short)sizeof(TrafRoutineDesc); }
+  
+   virtual Long pack(void *space);
+   virtual Lng32 unpack(void * base, void * reallocator);
+ 
+   virtual TrafRoutineDesc *routineDesc() const { return (TrafRoutineDesc*)this; }
+ 
+   Int64 objectUID;
+   char* routineName;
+   char* externalName;
+   char* librarySqlName;
+   char* libraryFileName;
+   char* signature;
+   ComSInt32 paramsCount;
+   DescStructPtr params;
+   ComRoutineLanguage language;
+   ComRoutineType UDRType;
+   ComRoutineSQLAccess sqlAccess;
+   ComRoutineTransactionAttributes transactionAttributes;
+   ComSInt32 maxResults;
+   ComRoutineParamStyle paramStyle;
+   NABoolean isDeterministic;
+   NABoolean isCallOnNull;
+   NABoolean isIsolate;
+   ComRoutineExternalSecurity externalSecurity;
+   ComRoutineExecutionMode executionMode;
+   Int32 stateAreaSize;
+   ComRoutineParallelism parallelism;
+   Int32 owner;
+   Int32 schemaOwner;
+ 
+   Int64 routineDescFlags; // my flags
+ 
+   char filler[24];
+ };
+ 
+ class TrafSequenceGeneratorDesc : public TrafDesc {
+ public:
+   TrafSequenceGeneratorDesc() : TrafDesc(DESC_SEQUENCE_GENERATOR_TYPE)
+   {}
+ 
+   // ---------------------------------------------------------------------
+   // Redefine virtual functions required for Versioning.
+   //----------------------------------------------------------------------
+   virtual unsigned char getClassVersionID()
+   {
+     return 1;
+   }
+ 
+   virtual void populateImageVersionIDArray()
+   {
+     setImageVersionID(0,getClassVersionID());
+   }
+ 
+   virtual short getClassSize()      { return (short)sizeof(TrafSequenceGeneratorDesc); }
+  
+   virtual Long pack(void *space);
+   virtual Lng32 unpack(void * base, void * reallocator);
+ 
+   virtual TrafSequenceGeneratorDesc *sequenceGeneratorDesc() const { return (TrafSequenceGeneratorDesc*)this; }
+ 
+   ComSequenceGeneratorType sgType() 
+   { return (ComSequenceGeneratorType)sgType_; }
+   void setSgType(ComSequenceGeneratorType v) 
+   { sgType_ = (Int16)v; }
+ 
+   Int64                     startValue;
+   Int64                     increment;
+ 
+   Int16 /*ComSequenceGeneratorType*/  sgType_;
+   Int16 /*ComSQLDataType*/  sqlDataType;
+   Int16 /*ComFSDataType*/   fsDataType;
+   Int16                     cycleOption;
+ 
+   Int64                     maxValue;
+   Int64                     minValue;
+   Int64                     cache;
+   Int64                     objectUID;
+   char*                     sgLocation;
+   Int64                     nextValue;
+   Int64                     redefTime;
+ 
+   Int64 sequenceGeneratorDescFlags; // my flags
+ 
+   char filler[16];
+ };
+ 
+ class TrafTableDesc : public TrafDesc {
+ public:
+   TrafTableDesc() : TrafDesc(DESC_TABLE_TYPE)
+   {}
+ 
+   // ---------------------------------------------------------------------
+   // Redefine virtual functions required for Versioning.
+   //----------------------------------------------------------------------
+   virtual unsigned char getClassVersionID()
+   {
+     return 1;
+   }
+ 
+   virtual void populateImageVersionIDArray()
+   {
+     setImageVersionID(0,getClassVersionID());
+   }
+ 
+   virtual short getClassSize()      { return (short)sizeof(TrafTableDesc); }
+  
+   virtual Long pack(void *space);
+   virtual Lng32 unpack(void * base, void * reallocator);
+ 
+   virtual TrafTableDesc *tableDesc() const { return (TrafTableDesc*)this; }
+ 
+   enum TableDescFlags
+     { 
+       SYSTEM_TABLE_CODE = 0x0001,  
+       UMD_TABLE         = 0x0002,
+       MV_TABLE          = 0x0004,
+       IUD_LOG           = 0x0008,
+       MV_MD_OBJECT      = 0x0010,
+       SYN_TRANS_DONE    = 0x0020,
+       VOLATILE          = 0x0040,
+       IN_MEM_OBJ        = 0x0080,
+       DROPPABLE         = 0x0100,
+       INSERT_ONLY       = 0x0200
+     };
+ 
+   void setSystemTableCode(NABoolean v) 
+   {(v ? tableDescFlags |= SYSTEM_TABLE_CODE : tableDescFlags &= ~SYSTEM_TABLE_CODE); };
+   NABoolean isSystemTableCode() { return (tableDescFlags & SYSTEM_TABLE_CODE) != 0; };
+ 
+   void setUMDTable(NABoolean v) 
+   {(v ? tableDescFlags |= UMD_TABLE : tableDescFlags &= ~UMD_TABLE); };
+   NABoolean isUMDTable() { return (tableDescFlags & UMD_TABLE) != 0; };
+ 
+   void setMVTable(NABoolean v) 
+   {(v ? tableDescFlags |= MV_TABLE : tableDescFlags &= ~MV_TABLE); };
+   NABoolean isMVTable() { return (tableDescFlags & MV_TABLE) != 0; };
+ 
+   void setIUDLog(NABoolean v) 
+   {(v ? tableDescFlags |= IUD_LOG : tableDescFlags &= ~IUD_LOG); };
+   NABoolean isIUDLog() { return (tableDescFlags & IUD_LOG) != 0; };
+ 
+   void setMVMetadataObject(NABoolean v) 
+   {(v ? tableDescFlags |= MV_MD_OBJECT : tableDescFlags &= ~MV_MD_OBJECT); };
+   NABoolean isMVMetadataObject() { return (tableDescFlags & MV_MD_OBJECT) != 0; };
+ 
+   void setSynonymTranslationDone(NABoolean v) 
+   {(v ? tableDescFlags |= SYN_TRANS_DONE : tableDescFlags &= ~SYN_TRANS_DONE); };
+   NABoolean isSynonymTranslationDone() { return (tableDescFlags & SYN_TRANS_DONE) != 0; };
+ 
+   void setVolatileTable(NABoolean v) 
+   {(v ? tableDescFlags |= VOLATILE : tableDescFlags &= ~VOLATILE); };
+   NABoolean isVolatileTable() { return (tableDescFlags & VOLATILE) != 0; };
+ 
+   void setInMemoryObject(NABoolean v) 
+   {(v ? tableDescFlags |= IN_MEM_OBJ : tableDescFlags &= ~IN_MEM_OBJ); };
+   NABoolean isInMemoryObject() { return (tableDescFlags & IN_MEM_OBJ) != 0; };
+ 
+   void setDroppable(NABoolean v) 
+   {(v ? tableDescFlags |= DROPPABLE : tableDescFlags &= ~DROPPABLE); };
+   NABoolean isDroppable() { return (tableDescFlags & DROPPABLE) != 0; };
+ 
+   void setInsertOnly(NABoolean v) 
+   {(v ? tableDescFlags |= INSERT_ONLY : tableDescFlags &= ~INSERT_ONLY); };
+   NABoolean isInsertOnly() { return (tableDescFlags & INSERT_ONLY) != 0; };
+ 
+   ComInsertMode insertMode() { return (ComInsertMode)insertMode_;}
+   void setInsertMode(ComInsertMode v) {insertMode_ = (Int16)v;}
+ 
+   ComPartitioningScheme partitioningScheme() 
+   { return (ComPartitioningScheme)partitioningScheme_; }
+   void setPartitioningScheme(ComPartitioningScheme v) 
+   { partitioningScheme_ = (Int16)v; }
+   ComRowFormat rowFormat() { return (ComRowFormat)rowFormat_; }
+   void setRowFormat(ComRowFormat v) { rowFormat_ = (Int16)v; }
+   ComObjectType objectType() { return (ComObjectType)objectType_; }
+   void setObjectType(ComObjectType v) { objectType_ = (Int16)v; }
+ 
+   char* tablename;
+ 
+   Int64 createTime;
+   Int64 redefTime;
+   Int64 cacheTime;
+ 
+   Int32 mvAttributesBitmap;
+   Int32 record_length;
+   Int32 colcount;
+   Int32 constr_count;
+ 
+   Int16 /*ComInsertMode*/ insertMode_;
+   Int16 /*ComPartitioningScheme*/ partitioningScheme_; 
+   Int16 /*ComRowFormat*/  rowFormat_;
+   Int16 /*ComObjectType*/ objectType_; 
+ 
+   Int64 catUID;
+   Int64 schemaUID;
+   Int64 objectUID;
+ 
+   Lng32 owner;
+   Lng32 schemaOwner;
+ 
+   char*  snapshotName;
+   char*  default_col_fam;
+   char*  all_col_fams;
+   Int64 objectFlags;
+   Int64 tablesFlags;
+ 
+   Int64 tableDescFlags; // my flags
+ 
+   DescStructPtr columns_desc;
+   DescStructPtr indexes_desc;
+   DescStructPtr constrnts_desc;
+   DescStructPtr views_desc;
+   DescStructPtr constrnts_tables_desc;
+   DescStructPtr referenced_tables_desc;
+   DescStructPtr referencing_tables_desc;
+   DescStructPtr histograms_desc;
+   DescStructPtr files_desc;
+ 
+   // for hbase's region keys
+   DescStructPtr hbase_regionkey_desc;
+   DescStructPtr sequence_generator_desc;
+ 
+   char filler[32];
+ };
+ 
+ class TrafUsingMvDesc : public TrafDesc {
+ public:
+   TrafUsingMvDesc() : TrafDesc(DESC_USING_MV_TYPE)
+   {}
+ 
+   // ---------------------------------------------------------------------
+   // Redefine virtual functions required for Versioning.
+   //----------------------------------------------------------------------
+   virtual unsigned char getClassVersionID()
+   {
+     return 1;
+   }
+ 
+   virtual void populateImageVersionIDArray()
+   {
+     setImageVersionID(0,getClassVersionID());
+   }
+ 
+   virtual short getClassSize()      { return (short)sizeof(TrafUsingMvDesc); }
+  
+   virtual Long pack(void *space);
+   virtual Lng32 unpack(void * base, void * reallocator);
+ 
+   virtual TrafUsingMvDesc *usingMvDesc() const { return (TrafUsingMvDesc*)this; }
+ 
+   ComMVRefreshType refreshType() { return (ComMVRefreshType)refreshType_;}
+   void setRefreshType(ComMVRefreshType v) 
+   { refreshType_ = (Int16)v;}
+ 
+   char* mvName;
+   Int32  rewriteEnabled;
+   Int32  isInitialized;
+   Int16 /*ComMVRefreshType*/ refreshType_; // unknown here means "non incremental"
+ 
+   char filler[14];
+ };
+ 
+ class TrafViewDesc : public TrafDesc {
+ public:
+   TrafViewDesc() : TrafDesc(DESC_VIEW_TYPE)
+   {}
+ 
+   // ---------------------------------------------------------------------
+   // Redefine virtual functions required for Versioning.
+   //----------------------------------------------------------------------
+   virtual unsigned char getClassVersionID()
+   {
+     return 1;
+   }
+ 
+   virtual void populateImageVersionIDArray()
+   {
+     setImageVersionID(0,getClassVersionID());
+   }
+ 
+   virtual short getClassSize()      { return (short)sizeof(TrafViewDesc); }
+  
+   virtual Long pack(void *space);
+   virtual Lng32 unpack(void * base, void * reallocator);
+ 
+   virtual TrafViewDesc *viewDesc() const { return (TrafViewDesc*)this; }
+ 
+   enum ViewDescFlags
+     { 
+       UPDATABLE           = 0x0001,
+       INSERTABLE          = 0x0002
+     };
+ 
+   void setUpdatable(NABoolean v) 
+   {(v ? viewDescFlags |= UPDATABLE : viewDescFlags &= ~UPDATABLE); };
+   NABoolean isUpdatable() { return (viewDescFlags & UPDATABLE) != 0; };
+ 
+   void setInsertable(NABoolean v) 
+   {(v ? viewDescFlags |= INSERTABLE : viewDescFlags &= ~INSERTABLE); };
+   NABoolean isInsertable() { return (viewDescFlags & INSERTABLE) != 0; };
+ 
+   char*  viewname;
+   char*  viewfilename;    // the physical file, to be Opened for auth-cking.
+   char*  viewtext;
+   char*  viewchecktext;
++  char*  viewcolusages;
+ 
+   Int64 viewDescFlags; // my flags
+ 
+   Int16 /*CharInfo::CharSet*/ viewtextcharset;
+ 
+   char filler[22];
+ };
+ 
+ // if space is passed in, use it. Otherwise use HEAP of CmpCommon
+ TrafDesc *TrafAllocateDDLdesc(desc_nodetype nodetype, 
+                                  Space *space);
+ 
+ TrafDesc *TrafMakeColumnDesc
+ (
+      const char *tablename,
+      const char *colname,
+      Lng32 &colnumber,		  // INOUT
+      Int32 datatype,
+      Lng32 length,
+      Lng32 &offset,		  // INOUT
+      NABoolean null_flag,
+      SQLCHARSET_CODE datacharset, // i.e., use CharInfo::DefaultCharSet;
+      Space * space
+  );
+ 
+ #endif

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/cd3d7e7b/core/sql/sqlcomp/CmpDDLCatErrorCodes.h
----------------------------------------------------------------------
diff --cc core/sql/sqlcomp/CmpDDLCatErrorCodes.h
index d79bf2a,25f439c..55d0468
--- a/core/sql/sqlcomp/CmpDDLCatErrorCodes.h
+++ b/core/sql/sqlcomp/CmpDDLCatErrorCodes.h
@@@ -59,7 -59,7 +59,7 @@@ enum CatErrorCode { CAT_FIRST_ERROR = 1
                    , CAT_FS_ERROR                                  = 1024
                    , CAT_DEPENDENT_OBJECTS_EXIST                   = 1025
                    , CAT_SCHEMA_ID_AND_USER_ID_DO_NOT_MATCH        = 1026
--                  , CAT_DEFINITION_SCHEMA_CAN_NOT_BE_DROPPED_BY_USER
++                  , CAT_COLUMN_PRIVILEGE_NOT_ALLOWED              = 1027
                    , CAT_SCHEMA_IS_NOT_EMPTY                       = 1028
                    , CAT_UNABLE_TO_CREATE_OBJECT                   = 1029
                    , CAT_HBASE_NAME_TOO_LONG                       = 1030

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/cd3d7e7b/core/sql/sqlcomp/CmpSeabaseDDL.h
----------------------------------------------------------------------
diff --cc core/sql/sqlcomp/CmpSeabaseDDL.h
index 4d71dff,3b583e7..594a9eb
--- a/core/sql/sqlcomp/CmpSeabaseDDL.h
+++ b/core/sql/sqlcomp/CmpSeabaseDDL.h
@@@ -826,7 -852,6 +856,7 @@@ protected
    short gatherViewPrivileges (const StmtDDLCreateView * createViewParseNode,
                                ExeCliInterface * cliInterface,
                                NABoolean viewCreator,
-                               Int32 schemaID,
++                              Int32 userID,
                                PrivMgrBitmap &privilegesBitmap,
                                PrivMgrBitmap &grantableBitmap);
  

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

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/cd3d7e7b/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
----------------------------------------------------------------------
diff --cc core/sql/sqlcomp/CmpSeabaseDDLview.cpp
index 8211b4a,b423d9b..f9c5c33
--- a/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
@@@ -68,7 -66,6 +67,7 @@@ static bool checkAccessPrivileges
     const ParTableUsageList & vtul,
     const ParViewColTableColsUsageList & vctcul,
     NABoolean viewCreator,
-    Int32 schemaID,
++   Int32 userID,
     PrivMgrBitmap & privilegesBitmap,
     PrivMgrBitmap & grantableBitmap);
  
@@@ -429,8 -367,6 +428,8 @@@ short CmpSeabaseDDL::updateViewUsage(St
  //    createViewNode - for list of objects and isUpdatable/isInsertable flags
  //    cliInterface - used to get UID of referenced object
  //    viewCreator - determines which authID to use to gather privs
- //    schemaID - schemaID to use when root is performing operations on behalf 
++//    userID - userID to use when root is performing operations on behalf 
 +//      of another user.
  //    privilegeBitmap - returns privileges this user has on the view
  //    grantableBitmap - returns privileges this user can grant
  //
@@@ -441,7 -377,6 +440,7 @@@
  short CmpSeabaseDDL::gatherViewPrivileges (const StmtDDLCreateView * createViewNode,
  				           ExeCliInterface * cliInterface,
                                             NABoolean viewCreator,
-                                            Int32 schemaID,
++                                           Int32 userID,
                                             PrivMgrBitmap &privilegesBitmap,
                                             PrivMgrBitmap &grantableBitmap)
  {
@@@ -459,7 -394,8 +458,7 @@@
    const ParViewColTableColsUsageList &vctcul = vu.getViewColTableColsUsageList();
  
    // If DB__ROOT, no need to gather privileges
-   if (!checkAccessPrivileges(vtul,vctcul,viewCreator,schemaID,privilegesBitmap,grantableBitmap))
 -  if (!ComUser::isRootUserID() && 
 -      !checkAccessPrivileges(vtul,vctcul,viewCreator,privilegesBitmap,grantableBitmap))
++  if (!checkAccessPrivileges(vtul,vctcul,viewCreator,userID,privilegesBitmap,grantableBitmap))
      return -1;
  
    // If view is not updatable or insertable, turn off privs in bitmaps
@@@ -1534,6 -1457,6 +1544,10 @@@ short CmpSeabaseDDL::dropMetadataViews(
  // *    If TRUE, gather privileges for the view creator, if FALSE,             *
  // *    gather privileges for the view owner                                   *
  // *                                                                           *
++// *  <userID>               Int32                                  In         *
++// *     userID to use when root is performing operations on behalf            *
++// *     of another user.                                                      *
++// *                                                                           *
  // *  <privilegesBitmap>       PrivMgrBitmap &                        Out      *
  // *    passes back the union of privileges the user has on the referenced     *
  // *    objects.                                                               *
@@@ -1555,21 -1478,20 +1569,20 @@@ static bool checkAccessPrivileges
     const ParTableUsageList & vtul,
     const ParViewColTableColsUsageList & vctcul,
     NABoolean viewCreator,
-    Int32 schemaID,
++   Int32 userID,
     PrivMgrBitmap & privilegesBitmap,
     PrivMgrBitmap & grantableBitmap)
     
  {
    BindWA bindWA(ActiveSchemaDB(),CmpCommon::context(),FALSE/*inDDL*/);
--  bool missingPrivilege = false;
--  NAString extUsedObjName;
++  PrivStatus retcode = STATUS_GOOD;
  
    NAString privMgrMDLoc;
    CONCAT_CATSCH(privMgrMDLoc,CmpSeabaseDDL::getSystemCatalogStatic(),SEABASE_PRIVMGR_SCHEMA);
    PrivMgrCommands privInterface(std::string(privMgrMDLoc.data()),
                                  CmpCommon::diags());
  
--  // generate the lists of privileges and grantable privileges
++  // generate the list of privileges and grantable privileges to assign to the view
    // a side effect is to return an error if basic privileges are not granted
     for (CollIndex i = 0; i < vtul.entries(); i++)
     {
@@@ -1579,7 -1501,7 +1592,7 @@@
        const NAString catalogNamePart = usedObjName.getCatalogNamePartAsAnsiString();
        const NAString schemaNamePart = usedObjName.getSchemaNamePartAsAnsiString(TRUE);
        const NAString objectNamePart = usedObjName.getObjectNamePartAsAnsiString(TRUE);
--      NAString extUsedObjName = usedObjName.getExternalName(TRUE);
++      NAString refdUsedObjName = usedObjName.getExternalName(TRUE);
        CorrName cn(objectNamePart,STMTHEAP, schemaNamePart,catalogNamePart);
   
        // If a sequence, set correct type to get a valid NATable entry
@@@ -1590,7 -1512,7 +1603,7 @@@
        NATable *naTable = bindWA.getNATable(cn);
        if (naTable == NULL)
        {
--          SEABASEDDL_INTERNAL_ERROR("Bad NATable pointer in checkAccessPrivileges");
++         SEABASEDDL_INTERNAL_ERROR("Bad NATable pointer in checkAccessPrivileges");
           return false; 
        }
  
@@@ -1602,28 -1523,8 +1614,28 @@@
        // contains the privileges we want to use to create bitmaps
        if (viewCreator)
        {
 -        pPrivInfo = naTable->getPrivInfo();
 -        CMPASSERT(pPrivInfo != NULL);
 +        // If the viewCreator is not the current user (DB__ROOT running request)
 +        // on behalf of the schema owner), get actual owner privs.
 +        if (ComUser::isRootUserID() &&
 +            ComUser::getRootUserID() != naTable->getSchemaOwner())
 +        {
 +          retcode = privInterface.getPrivileges((int64_t)naTable->objectUid().get_value(),
 +                                                 naTable->getObjectType(),
-                                                  schemaID,
++                                                 userID,
 +                                                 privs);
 +
 +          if (retcode == STATUS_ERROR)
 +          {         
 +             *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_PRIVS);
 +             return false;
 +          }
 +          pPrivInfo = &privs;
 +        }
 +        else
 +        {
 +          pPrivInfo = naTable->getPrivInfo();
 +          CMPASSERT(pPrivInfo != NULL);
 +        }
        }
        
        // If the view owner is not the view creator, then we need to get schema
@@@ -1645,140 -1546,119 +1657,78 @@@
  
        // Requester must have at least select privilege
        // For sequence generators USAGE is needed instead of SELECT
++      bool noObjRequiredPriv = true;
        if  (isSeq)
--        missingPrivilege = !pPrivInfo->hasUsagePriv() ? true : false;
++        noObjRequiredPriv = !pPrivInfo->hasUsagePriv() ? true : false;
        else  
--        missingPrivilege = !pPrivInfo->hasSelectPriv() ? true : false; 
++        noObjRequiredPriv = !pPrivInfo->hasSelectPriv() ? true : false; 
  
        // Summarize privileges
        privilegesBitmap &= pPrivInfo->getObjectBitmap();
        grantableBitmap &= pPrivInfo->getGrantableBitmap();
--   }
     
-    PrivColumnBitmap colPrivBitmap;
-    PrivColumnBitmap colGrantableBitmap;
- 
-    PrivMgrPrivileges::setColumnPrivs(colPrivBitmap);
-    PrivMgrPrivileges::setColumnPrivs(colGrantableBitmap);
- 
-    //  To create a view you need at least select privilege, missingPrivilege
 -   //  To create a view you need at least select privilege, noSelectPriv
--   //  is true if the auth ID does not have select privilege at the object
--   //  level.  The view can still be created if select exists at the column
--   //  level.
--   bool noObjPriv = missingPrivilege;
--   missingPrivilege = false;   
- 
 -      
--   // Gather column level privs to attach to the bitmap.
--   // Even though privileges are granted on the column, they show up as
--   // object privileges on the view.
 -   PrivColumnBitmap colPrivBitmap;
 -   PrivColumnBitmap colGrantableBitmap;
 -
 -   PrivMgrPrivileges::setColumnPrivs(colPrivBitmap);
 -   PrivMgrPrivileges::setColumnPrivs(colGrantableBitmap);
 -
--   for (size_t i = 0; i < vctcul.entries(); i++)
--   {
--      const ParViewColTableColsUsage &vctcu = vctcul[i];
--      int32_t usingColNum = vctcu.getUsingViewColumnNumber();
--      const ColRefName &usedColRef = vctcu.getUsedObjectColumnName();
--      
--      ComObjectName usedObjName;
--
--      usedObjName = usedColRef.getCorrNameObj().getQualifiedNameObj().
--                    getQualifiedNameAsAnsiString();
--
--      const NAString catalogNamePart = usedObjName.getCatalogNamePartAsAnsiString();
--      const NAString schemaNamePart = usedObjName.getSchemaNamePartAsAnsiString(TRUE);
--      const NAString objectNamePart = usedObjName.getObjectNamePartAsAnsiString(TRUE);
--      extUsedObjName = usedObjName.getExternalName(TRUE);
--      CorrName cn(objectNamePart,STMTHEAP,schemaNamePart,catalogNamePart);
--
--      NATable *naTable = bindWA.getNATable(cn);
--      if (naTable == NULL)
-       {
-          SEABASEDDL_INTERNAL_ERROR("Bad NATable pointer in checkAccessPrivileges");
-          return -1; 
-       }
- 
-       const NAColumnArray &nacolArr = naTable->getNAColumnArray();
-       ComString usedObjColName(usedColRef.getColName());
-       const NAColumn * naCol = nacolArr.getColumn(usedObjColName);
-       if (naCol == NULL)
++      // Gather column level privs to attach to the bitmap.
++      // Even though privileges are granted on the column, they show up as
++      // object privileges on the view.
++      PrivColumnBitmap colPrivBitmap;
++      PrivColumnBitmap colGrantableBitmap;
++
++      PrivMgrPrivileges::setColumnPrivs(colPrivBitmap);
++      PrivMgrPrivileges::setColumnPrivs(colGrantableBitmap);
++
++      // Check for column privileges on each view column 
++      // This loop is performed for each object referenced by the view.
++      // Only those columns that belong to the referenced object have their
++      // privileges summarized.
++      for (size_t i = 0; i < vctcul.entries(); i++)
        {
 -         SEABASEDDL_INTERNAL_ERROR("Bad NATable pointer in checkAccessPrivileges");
 -         return -1; 
 -      }
 -
 -      const NAColumnArray &nacolArr = naTable->getNAColumnArray();
 -      ComString usedObjColName(usedColRef.getColName());
 -      const NAColumn * naCol = nacolArr.getColumn(usedObjColName);
 -      if (naCol == NULL)
 -      {
--         *CmpCommon::diags() << DgSqlCode(-CAT_COLUMN_DOES_NOT_EXIST_ERROR)
--                             << DgColumnName(usedObjColName);
--         return false;
--      }
--      int32_t usedColNumber = naCol->getPosition();
++         const ParViewColTableColsUsage &vctcu = vctcul[i];
++         const ColRefName &usedColRef = vctcu.getUsedObjectColumnName();
++         ComObjectName usedObjName = 
++            usedColRef.getCorrNameObj().getQualifiedNameObj().getQualifiedNameAsAnsiString();
++         NAString colUsedObjName = usedObjName.getExternalName(TRUE);
++
++         // If column is part of the used object, summarize column privs
++         if (colUsedObjName == refdUsedObjName)
++         {
++            // Get the refd object details
++            const NAColumnArray &nacolArr = naTable->getNAColumnArray();
++            ComString usedObjColName(usedColRef.getColName());
++            const NAColumn * naCol = nacolArr.getColumn(usedObjColName);
++            if (naCol == NULL)
++            {
++               *CmpCommon::diags() << DgSqlCode(-CAT_COLUMN_DOES_NOT_EXIST_ERROR)
++                                   << DgColumnName(usedObjColName);
++               return false;
++            }
++            int32_t usedColNumber = naCol->getPosition();
       
--      PrivMgrUserPrivs privs;
--      PrivMgrUserPrivs *pPrivInfo = NULL;
-       PrivStatus retcode = STATUS_GOOD;
--      if (viewCreator)
-       {
-         // If the viewCreator is not the current user (DB__ROOT running request)
-         // on behalf of the schema owner), get actual owner privs.
-         if (ComUser::isRootUserID() &&
-             ComUser::getRootUserID() != naTable->getSchemaOwner())
-         {
-           retcode = privInterface.getPrivileges((int64_t)naTable->objectUid().get_value(),
-                                                  naTable->getObjectType(),
-                                                  schemaID,
-                                                  privs);
- 
-           if (retcode == STATUS_ERROR)
-           {         
-              *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_PRIVS);
-              return false;
-           }
-           pPrivInfo = &privs;
-         }
-         else
-           pPrivInfo = naTable->getPrivInfo();
-       }
 -        pPrivInfo = naTable->getPrivInfo();
--      else
--      {
-         retcode = privInterface.getPrivileges((int64_t)naTable->objectUid().get_value(),
-                                                 naTable->getObjectType(),
-                                                 naTable->getOwner(),
-                                                 privs);
 -        PrivStatus retcode = privInterface.getPrivileges((int64_t)naTable->objectUid().get_value(),
 -                                                           naTable->getObjectType(),
 -                                                           naTable->getOwner(),
 -                                                           privs);
--
--        if (retcode == STATUS_ERROR)
--        {
--           *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_PRIVS);
--           return false;
--        }
--        pPrivInfo = &privs;
--      }
--
--      if (pPrivInfo == NULL) 
--      {         
--         *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_PRIVS);
--         return false;
--      }
--
--      // If the user is missing SELECT at the object level and on at least one 
--      // column-level privilege, view cannot be created.  No need to proceed.
--      if (noObjPriv && !pPrivInfo->hasColSelectPriv(usedColNumber))
--      {
--         missingPrivilege = true;
--         break;
--      }        
++            // If the user is missing SELECT at the object level and on at least one 
++            // column, view cannot be created.  No need to proceed.
++            // Can't have sequences on views, so only need to check for SELECT
++            if (noObjRequiredPriv && !pPrivInfo->hasColSelectPriv(usedColNumber))
++            {
++              *CmpCommon::diags() << DgSqlCode(-4481)
++                                  << DgString0("SELECT")
++                                  << DgString1(colUsedObjName.data());
++              return false;
++            }        
        
--      colPrivBitmap &= pPrivInfo->getColumnPrivBitmap(usedColNumber);
--      colGrantableBitmap &= pPrivInfo->getColumnGrantableBitmap(usedColNumber);
--   }
- 
 -  
--   if (noObjPriv && missingPrivilege)
--     {
--        *CmpCommon::diags() << DgSqlCode(-4481)
--                            << DgString0("SELECT")
--                            << DgString1(extUsedObjName.data());
--        return false;
--     }
--  
--   for (size_t i = FIRST_DML_COL_PRIV; i <= LAST_DML_COL_PRIV; i++ )
--   {
--      if (colPrivBitmap.test(PrivType(i)))
--         privilegesBitmap.set(PrivType(i));   
++            colPrivBitmap &= pPrivInfo->getColumnPrivBitmap(usedColNumber);
++            colGrantableBitmap &= pPrivInfo->getColumnGrantableBitmap(usedColNumber);
++         } // done with current view col 
++      } // done checking privs for all view cols
++
++      // Add summarize column privileges to the official bitmaps, bit is only
++      // set if all cols have priv set.
++      for (size_t i = FIRST_DML_COL_PRIV; i <= LAST_DML_COL_PRIV; i++ )
++      {
++         if (colPrivBitmap.test(PrivType(i)))
++            privilegesBitmap.set(PrivType(i));   
   
--      if (colGrantableBitmap.test(PrivType(i)))
--         grantableBitmap.set(PrivType(i));   
++         if (colGrantableBitmap.test(PrivType(i)))
++            grantableBitmap.set(PrivType(i));   
++      }
     }
     
     return true;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/cd3d7e7b/core/sql/sqlcomp/PrivMgr.h
----------------------------------------------------------------------
diff --cc core/sql/sqlcomp/PrivMgr.h
index fb3c1aa,da7145e..e7f412e
--- a/core/sql/sqlcomp/PrivMgr.h
+++ b/core/sql/sqlcomp/PrivMgr.h
@@@ -68,14 -68,11 +68,27 @@@ class PrivMg
                            };
  
      enum PrivCommand { GRANT_OBJECT           = 30,
 -                       REVOKE_OBJECT_RESTRICT = 31,
 -                       REVOKE_OBJECT_CASCADE  = 32,
 -                       UNKNOWN_PRIV_COMMAND   = 33
 +                       GRANT_COLUMN           = 31,
 +                       REVOKE_OBJECT_RESTRICT = 32,
 +                       REVOKE_OBJECT_CASCADE  = 33,
 +                       REVOKE_COLUMN_RESTRICT = 34,
 +                       REVOKE_COLUMN_CASCADE  = 35,
 +                       UNKNOWN_PRIV_COMMAND   = 36
                       };
  
++    bool isRevokeCommand (const PrivCommand command)
++    {
++      return (command == REVOKE_OBJECT_RESTRICT ||
++              command == REVOKE_OBJECT_CASCADE ||
++              command == REVOKE_COLUMN_RESTRICT ||
++              command == REVOKE_COLUMN_CASCADE);
++    }
++
++    bool isGrantCommand (const PrivCommand command)
++    {
++      return (command == GRANT_OBJECT || command == GRANT_COLUMN);
++    }
++
      // -------------------------------------------------------------------
      // Static functions:
      // -------------------------------------------------------------------



Mime
View raw message