metadata access performance improvement for accessing traf objects Packed version of descriptor structures is now stored in traf TEXT table during various DDL operations. During dml, if packed descriptors exist, then they are read and used. If they dont exist, then descriptors are generated on the fly.
Descriptor classes are defined in file sqlcat/TrafDDLdesc.h and are based off the older desc structures from desc.h. These are simplified and class'ified version of the older structures and are versioned. Changes to these classes should be done carefully by either using filler bytes or versioning them. 2 new cqds, traf_store_object_descriptor and traf_read_object_descriptor, are added to control if packed descs should be stored/read. These are currently set to OFF by default but are enabled during regressions run. Once this feature is tested, these cqds will be turned on by default. In addition, some helper commands have been added to manipulate descrs. Syntax: alter table t [check|generate|delete|disable|enable] stored descritors If authorization is enabled, then auth/priv specific info is generated on the fly and currently not stored in metadata. In a later checkin, these will also be stored in metadata. Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/19c96b1e Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/19c96b1e Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/19c96b1e Branch: refs/heads/master Commit: 19c96b1ec830f7b340854b37d8b5e6fea72554fd Parents: 2d7a91f Author: Anoop Sharma <anoop.sha...@esgyn.com> Authored: Tue Aug 2 19:46:35 2016 +0000 Committer: Anoop Sharma <anoop.sha...@esgyn.com> Committed: Tue Aug 2 19:46:35 2016 +0000 ---------------------------------------------------------------------- core/sql/arkcmp/CmpStoredProc.cpp | 96 +- core/sql/arkcmp/CmpStoredProc.h | 21 +- core/sql/bin/SqlciErrors.txt | 3 +- core/sql/common/CmpCommon.h | 1 + core/sql/common/ComSmallDefs.h | 3 +- core/sql/common/OperTypeEnum.h | 2 + core/sql/generator/GenExplain.cpp | 99 +- core/sql/generator/GenPreCode.cpp | 4 +- core/sql/generator/GenRelExeUtil.cpp | 43 +- core/sql/generator/GenRelMisc.cpp | 129 +- core/sql/generator/GenRelScan.cpp | 41 +- core/sql/generator/GenUdr.cpp | 4 +- core/sql/generator/Generator.cpp | 782 ++++--- core/sql/generator/Generator.h | 78 +- core/sql/nskgmake/sqlcat/Makefile | 1 + core/sql/optimizer/BindItemExpr.cpp | 7 +- core/sql/optimizer/BindRI.cpp | 28 +- core/sql/optimizer/BindRelExpr.cpp | 97 +- core/sql/optimizer/BindWA.h | 6 +- core/sql/optimizer/EncodedKeyValue.cpp | 77 +- core/sql/optimizer/EncodedKeyValue.h | 21 +- core/sql/optimizer/ItemConstr.h | 5 +- core/sql/optimizer/NAColumn.cpp | 192 +- core/sql/optimizer/NAColumn.h | 4 +- core/sql/optimizer/NAFileSet.cpp | 2 +- core/sql/optimizer/NAFileSet.h | 10 +- core/sql/optimizer/NARoutine.cpp | 66 +- core/sql/optimizer/NARoutine.h | 2 +- core/sql/optimizer/NATable.cpp | 2067 +++++++++--------- core/sql/optimizer/NATable.h | 14 +- core/sql/optimizer/RelExeUtil.cpp | 24 +- core/sql/optimizer/RelExeUtil.h | 20 +- core/sql/optimizer/RelMisc.h | 2 +- core/sql/optimizer/RelRoutine.cpp | 15 +- core/sql/optimizer/RelRoutine.h | 28 +- core/sql/optimizer/RelScan.h | 10 +- core/sql/optimizer/RelStoredProc.cpp | 2 +- core/sql/optimizer/ValueDesc.cpp | 7 +- core/sql/parser/AllStmtDDL.h | 1 + core/sql/parser/AllStmtDDLAlterTable.h | 1 + core/sql/parser/BindStmtDDL.cpp | 31 + core/sql/parser/ElemDDLNode.cpp | 12 + core/sql/parser/ElemDDLNode.h | 4 + core/sql/parser/StmtDDLAlter.cpp | 91 + core/sql/parser/StmtDDLAlterSchema.h | 177 ++ core/sql/parser/sqlparser.y | 80 +- core/sql/regress/executor/EXPECTED013.SB | 2 + core/sql/regress/executor/TEST122 | 6 + core/sql/regress/fullstack2/EXPECTED062 | 6 + core/sql/regress/fullstack2/EXPECTED062.RELEASE | 6 + core/sql/regress/hive/EXPECTED018 | 187 +- core/sql/regress/hive/TEST018 | 3 + core/sql/regress/seabase/EXPECTED031 | 270 ++- core/sql/regress/seabase/TEST031 | 48 +- core/sql/regress/tools/sbdefs | 2 + core/sql/sqlcat/ReadTableDef.cpp | 404 ---- core/sql/sqlcat/ReadTableDef.h | 17 - core/sql/sqlcat/TrafDDLdesc.cpp | 617 ++++++ core/sql/sqlcat/TrafDDLdesc.h | 1120 ++++++++++ core/sql/sqlcat/desc.h | 473 +--- core/sql/sqlcat/readRealArk.cpp | 146 +- core/sql/sqlcat/readRealArk.h | 1 - core/sql/sqlcomp/CmpDDLCatErrorCodes.h | 1 + core/sql/sqlcomp/CmpDescribe.cpp | 23 +- core/sql/sqlcomp/CmpSeabaseDDL.h | 85 +- core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp | 323 ++- core/sql/sqlcomp/CmpSeabaseDDLincludes.h | 2 +- core/sql/sqlcomp/CmpSeabaseDDLindex.cpp | 40 +- core/sql/sqlcomp/CmpSeabaseDDLmd.h | 7 +- core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp | 1 - core/sql/sqlcomp/CmpSeabaseDDLschema.cpp | 246 +++ core/sql/sqlcomp/CmpSeabaseDDLtable.cpp | 731 +++++-- core/sql/sqlcomp/CmpSeabaseDDLview.cpp | 12 +- core/sql/sqlcomp/DefaultConstants.h | 6 + core/sql/sqlcomp/nadefaults.cpp | 10 +- 75 files changed, 5829 insertions(+), 3376 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/19c96b1e/core/sql/arkcmp/CmpStoredProc.cpp ---------------------------------------------------------------------- diff --git a/core/sql/arkcmp/CmpStoredProc.cpp b/core/sql/arkcmp/CmpStoredProc.cpp index 0df7813..bd44e9b 100644 --- a/core/sql/arkcmp/CmpStoredProc.cpp +++ b/core/sql/arkcmp/CmpStoredProc.cpp @@ -41,7 +41,7 @@ #define SQLPARSERGLOBALS_NADEFAULTS #include "CmpStoredProc.h" -#include "desc.h" +#include "TrafDDLdesc.h" #include "parser.h" #include "str.h" @@ -273,7 +273,7 @@ NABoolean CmpSPOutputFormat::SetFormat(Lng32 nCols, nCols_ = nCols; // set up tableDesc_, allocate the storage from allocate routine, // so the delete of the tableDesc_ could be done correctly. - // As in sqlcat/desc.h readtabledef_allocate_desc(), allocate routine gets + // As in sqlcat/desc.h TrafAllocateDDLdesc(), allocate routine gets // the storage from HEAP ( i.e. CmpCommon::statementHeap() ). // Likewise, copyString should be the same implementation as in // readRealArk.cpp. It was externalized originally, but being put as @@ -281,44 +281,43 @@ NABoolean CmpSPOutputFormat::SetFormat(Lng32 nCols, // in the beginning of the file. ( which will allocate the memory from // statementHeap ). - desc_struct* table_desc = readtabledef_allocate_desc(DESC_TABLE_TYPE); + TrafDesc* table_desc = TrafAllocateDDLdesc(DESC_TABLE_TYPE, NULL); tableDesc_ = table_desc; char* objName = copyString(NAString(tableName)); - table_desc->body.table_desc.tablename = objName; + table_desc->tableDesc()->tablename = objName; - table_desc->body.table_desc.record_length = 0; // to be set later in generator. - table_desc->body.table_desc.colcount = (Int32)nCols; + table_desc->tableDesc()->record_length = 0; // to be set later in generator. + table_desc->tableDesc()->colcount = (Int32)nCols; - desc_struct * files_desc = readtabledef_allocate_desc(DESC_FILES_TYPE); - table_desc->body.table_desc.files_desc = files_desc; - files_desc->body.files_desc.fileorganization = KEY_SEQUENCED_FILE; + TrafDesc * files_desc = TrafAllocateDDLdesc(DESC_FILES_TYPE, NULL); + table_desc->tableDesc()->files_desc = files_desc; - // populate the columns_desc_struct - desc_struct* prev_col_desc = 0; - desc_struct* first_col_desc = 0; + // populate the TrafColumnsDesc + TrafDesc* prev_col_desc = 0; + TrafDesc* first_col_desc = 0; for ( Int32 i=0; i < nCols; i++ ) { - desc_struct* column_desc = readtabledef_allocate_desc(DESC_COLUMNS_TYPE); + TrafDesc* column_desc = TrafAllocateDDLdesc(DESC_COLUMNS_TYPE, NULL); if (prev_col_desc) - prev_col_desc->header.next = column_desc; + prev_col_desc->next = column_desc; else first_col_desc = column_desc; prev_col_desc = column_desc; - if ( !getColumnDesc( &(fields[i]), &(column_desc->body.columns_desc) ) ) + if ( !getColumnDesc( &(fields[i]), (column_desc->columnsDesc()))) { *(context_->diags()) << DgSqlCode(arkcmpErrorISPFieldDef); tableDesc_ = 0; // since HEAP is from statement heap, it will // be removed automatically at the end of statement. return FALSE; } - column_desc->body.columns_desc.colnumber = i; + column_desc->columnsDesc()->colnumber = i; } - table_desc->body.table_desc.columns_desc = first_col_desc; + table_desc->tableDesc()->columns_desc = first_col_desc; // populate index_desc and key_desc - desc_struct* keys_desc = 0; + TrafDesc* keys_desc = 0; if ( !getKeysDesc( nKeys, keys, keys_desc) ) { *(context_->diags()) << DgSqlCode(arkcmpErrorISPFieldDef); @@ -326,24 +325,23 @@ NABoolean CmpSPOutputFormat::SetFormat(Lng32 nCols, return FALSE; } - desc_struct * index_desc = readtabledef_allocate_desc(DESC_INDEXES_TYPE); - index_desc->body.indexes_desc.tablename = objName; - index_desc->body.indexes_desc.indexname = objName; - index_desc->body.indexes_desc.keytag = 0; // primary index - index_desc->body.indexes_desc.record_length = - table_desc->body.table_desc.record_length; - index_desc->body.indexes_desc.colcount = - table_desc->body.table_desc.colcount; - index_desc->body.indexes_desc.blocksize = 4096; // anything > 0 + TrafDesc * index_desc = TrafAllocateDDLdesc(DESC_INDEXES_TYPE, NULL); + index_desc->indexesDesc()->tablename = objName; + index_desc->indexesDesc()->indexname = objName; + index_desc->indexesDesc()->keytag = 0; // primary index + index_desc->indexesDesc()->record_length = + table_desc->tableDesc()->record_length; + index_desc->indexesDesc()->colcount = + table_desc->tableDesc()->colcount; + index_desc->indexesDesc()->blocksize = 4096; // anything > 0 // cannot simply point to same files desc as the table one, // because then ReadTableDef::deleteTree frees same memory twice (error) - desc_struct * i_files_desc = readtabledef_allocate_desc(DESC_FILES_TYPE); - index_desc->body.indexes_desc.files_desc = i_files_desc; - i_files_desc->body.files_desc.fileorganization = KEY_SEQUENCED_FILE; + TrafDesc * i_files_desc = TrafAllocateDDLdesc(DESC_FILES_TYPE, NULL); + index_desc->indexesDesc()->files_desc = i_files_desc; - index_desc->body.indexes_desc.keys_desc = keys_desc; - table_desc->body.table_desc.indexes_desc = index_desc; + index_desc->indexesDesc()->keys_desc = keys_desc; + table_desc->tableDesc()->indexes_desc = index_desc; return TRUE; } @@ -353,7 +351,7 @@ CmpSPOutputFormat::~CmpSPOutputFormat() } NABoolean CmpSPOutputFormat::getColumnDesc(SP_FIELDDESC_STRUCT* fDesc, - columns_desc_struct* colsDesc ) + TrafColumnsDesc* colsDesc ) { ElemDDLColDef* elemDDL; @@ -363,7 +361,7 @@ NABoolean CmpSPOutputFormat::getColumnDesc(SP_FIELDDESC_STRUCT* fDesc, { // convert ElemDDLColViewDef into CatColumn, then column_desc if ( !ElemDDLColDef2ColumnDescStruct - (elemDDL, tableDesc_->body.table_desc.tablename, colsDesc) ) + (elemDDL, tableDesc_->tableDesc()->tablename, colsDesc) ) return FALSE; } @@ -372,23 +370,23 @@ NABoolean CmpSPOutputFormat::getColumnDesc(SP_FIELDDESC_STRUCT* fDesc, NABoolean CmpSPOutputFormat::getKeysDesc(Lng32 nKeys, SP_KEYDESC_STRUCT* keys, - desc_struct* &keysDesc) + TrafDesc* &keysDesc) { // key is not supported yet in FCS ( Sep. 97 release ) needs to rework on this. - desc_struct* prev_key_desc = 0; - desc_struct* first_key_desc = 0; + TrafDesc* prev_key_desc = 0; + TrafDesc* first_key_desc = 0; for ( Int32 i=0; i < nKeys; i++ ) { - desc_struct* key_desc = readtabledef_allocate_desc(DESC_KEYS_TYPE); + TrafDesc* key_desc = TrafAllocateDDLdesc(DESC_KEYS_TYPE, NULL); if (prev_key_desc) - 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.keyseqnumber = i; + key_desc->keysDesc()->keyseqnumber = i; // TODO, find out the tablecolnumber from column name ???? - key_desc->body.keys_desc.tablecolnumber = 0; - key_desc->body.keys_desc.ordering = 0; // ????? + key_desc->keysDesc()->tablecolnumber = 0; + key_desc->keysDesc()->setDescending(FALSE); } keysDesc = first_key_desc; return TRUE; @@ -400,18 +398,18 @@ NABoolean CmpSPOutputFormat::getKeysDesc(Lng32 nKeys, NABoolean CmpSPOutputFormat::ElemDDLColDef2ColumnDescStruct (ElemDDLColDef* elem, const char* tableName, - columns_desc_struct* colDesc) + TrafColumnsDesc* colDesc) { // Just copy the pointer for this name -- // no need to alloc + strcpy a la copyString - colDesc->tablename = (char *)tableName; + // colDesc->tablename = (char *)tableName; colDesc->colname = copyString(elem->getColumnName()); // colDesc->colnumber, filled outside NAType* genericType = elem->getColumnDataType(); - colDesc->datatype = (DataType) genericType->getFSDatatype(); + colDesc->datatype = genericType->getFSDatatype(); colDesc->length = genericType->getNominalSize(); colDesc->pictureText = (char *)emptyString; @@ -451,7 +449,7 @@ NABoolean CmpSPOutputFormat::ElemDDLColDef2ColumnDescStruct colDesc->character_set = charType.getCharSet(); colDesc->encoding_charset = charType.getEncodingCharSet(); colDesc->collation_sequence = charType.getCollation(); - colDesc->upshift = charType.isUpshifted(); + colDesc->setUpshifted(charType.isUpshifted()); } if ( genericType->getTypeQualifier() == NA_DATETIME_TYPE || @@ -468,12 +466,10 @@ NABoolean CmpSPOutputFormat::ElemDDLColDef2ColumnDescStruct // offset, to be done (do we need it?) - colDesc->null_flag = NOT elem->isNotNullConstraintSpecified(); + colDesc->setNullable(NOT elem->isNotNullConstraintSpecified()); colDesc->colclass = 'U'; - colDesc->addedColumn = 0; - colDesc->uec = (Cardinality)0; - colDesc->highval = colDesc->lowval = 0; + colDesc->setAdded(FALSE); // defaultclass, to be done? (not referenced, not needed) http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/19c96b1e/core/sql/arkcmp/CmpStoredProc.h ---------------------------------------------------------------------- diff --git a/core/sql/arkcmp/CmpStoredProc.h b/core/sql/arkcmp/CmpStoredProc.h index df0ad68..90d281a 100644 --- a/core/sql/arkcmp/CmpStoredProc.h +++ b/core/sql/arkcmp/CmpStoredProc.h @@ -47,8 +47,7 @@ // for the table descriptions #include "enum.h" -#include "desc.h" - +#include "CmpCommon.h" #include "Collections.h" // for NAList #include "Int64.h" @@ -73,6 +72,8 @@ class CmpISPDataObject; // the data object for internal stored procedure executi class ElemDDLColDef; class ItemExpr; class CmpMessageISPRequest; +class TrafDesc; +class TrafColumnsDesc; // ----------------------------------------------------------------------- // CmpSPInputFormat class contains the definition of input data for the @@ -133,34 +134,34 @@ public: ); // generate the table_desc for binder, this method will create the - // desc_struct for the virtual table. The memory is allocated from + // TrafDesc for the virtual table. The memory is allocated from // sqlcat/read.C allocate routine, i.e. HEAP defined in common/CmpCommon.h // The memory allocated belongs to the caller, // the caller should delete it accordingly. - desc_struct* tableDesc() { return tableDesc_; } + TrafDesc* tableDesc() { return tableDesc_; } NABoolean ValidTableFormat() { return !tableDesc_ ; } - // static function to convert an ElemDDLColDef into columns_desc_struct + // static function to convert an ElemDDLColDef into TrafColumnsDesc // return TRUE if success, FALSE if not. static NABoolean ElemDDLColDef2ColumnDescStruct(ElemDDLColDef* elemDDL, const char* tableName, - columns_desc_struct* colDesc); + TrafColumnsDesc* colDesc); private: - // output format is described as a table_desc_struct - desc_struct* tableDesc_; + // output format is described as TrafTableDesc + TrafDesc* tableDesc_; Lng32 nCols_; CmpContext* context_; // methods to pupulate column_desc from SP_FIELDDESC_STRUCT // return TRUE : success, FALSE : fail NABoolean getColumnDesc(SP_FIELDDESC_STRUCT* fDesc, - columns_desc_struct* colsDesc); + TrafColumnsDesc* colsDesc); NABoolean getKeysDesc(Lng32 nkeys, SP_KEYDESC_STRUCT* keys, - desc_struct* &keysDesc); + TrafDesc* &keysDesc); CmpSPOutputFormat(const CmpSPOutputFormat&); const CmpSPOutputFormat& operator=(const CmpSPOutputFormat&); http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/19c96b1e/core/sql/bin/SqlciErrors.txt ---------------------------------------------------------------------- diff --git a/core/sql/bin/SqlciErrors.txt b/core/sql/bin/SqlciErrors.txt index 88ea933..f21cf09 100644 --- a/core/sql/bin/SqlciErrors.txt +++ b/core/sql/bin/SqlciErrors.txt @@ -290,7 +290,7 @@ 1295 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Target column $0~ColumnName has mismatching default type. 1296 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Character data type of target column and literal are different. 1297 ZZZZZ 99999 BEGINNER MAJOR DBADMIN The $0~string0 command cannot be executed because volatile schema $1~string1 exists. -1298 ZZZZZ 99999 UUUUUUUU UUUUU UUUUUUU ----- Msg used in Trafodion ------ +1298 ZZZZZ 99999 BEGINNER MINOR DBADMIN Schema $0~SchemaName could not be altered. $0~String0 1299 ZZZZZ 99999 BEGINNER MAJOR DBADMIN You cannot specify some columns with just the name and others with name & data attributes. 1300 ZZZZZ 99999 ADVANCED MAJOR DIALOUT Catman generated unknown Exception for procedure $0~TableName. 1301 ZZZZZ 99999 BEGINNER MAJOR DBADMIN NO ACTION referential action for $0~string0 clause is not yet supported as specified by ANSI SQL99 standard. To alter the behavior, set an appropriate value for the REF_CONSTRAINT_NO_ACTION_LIKE_RESTRICT default. @@ -1433,6 +1433,7 @@ $1~String1 -------------------------------- 4490 ZZZZZ 99999 BEGINNER MINOR LOGONLY BULK LOAD into a salted table is not supported if ESP parallelism is turned off. 4491 42000 99999 BEGINNER MINOR LOGONLY The user does not have $0~string0 privilege on sequence $1~string1$2~string2. 4492 ZZZZZ 99999 BEGINNER MINOR LOGONLY BULK LOAD option UPDATE STATISTICS cannot be used with UPSERT USING LOAD option. +4493 ZZZZZ 99999 BEGINNER MINOR LOGONLY Stored Descriptor Status: $0~String0 5000 ZZZZZ 99999 ADVANCED MAJOR DBADMIN Internal error in the query normalizer. 6000 ZZZZZ 99999 ADVANCED MAJOR DBADMIN Internal error in the query optimizer. 6001 0A000 99999 BEGINNER MAJOR DBADMIN DISTINCT aggregates can be computed for only one column per table expression. http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/19c96b1e/core/sql/common/CmpCommon.h ---------------------------------------------------------------------- diff --git a/core/sql/common/CmpCommon.h b/core/sql/common/CmpCommon.h index a8a5db9..91716b9 100644 --- a/core/sql/common/CmpCommon.h +++ b/core/sql/common/CmpCommon.h @@ -131,6 +131,7 @@ public: #define CTXTHEAP (CmpCommon::contextHeap()) #define STMTHEAP (CmpCommon::statementHeap()) #define HEAP STMTHEAP // the commonest case + static NAMemory * contextHeap(); static NAHeap * statementHeap(); http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/19c96b1e/core/sql/common/ComSmallDefs.h ---------------------------------------------------------------------- diff --git a/core/sql/common/ComSmallDefs.h b/core/sql/common/ComSmallDefs.h index cf06803..5a25b62 100644 --- a/core/sql/common/ComSmallDefs.h +++ b/core/sql/common/ComSmallDefs.h @@ -641,7 +641,8 @@ enum ComTextType {COM_VIEW_TEXT = 0, COM_TABLE_COMMENT_TEXT = 3, COM_COMPUTED_COL_TEXT = 4, COM_HBASE_COL_FAMILY_TEXT = 5, - COM_HBASE_SPLIT_TEXT = 6 + COM_HBASE_SPLIT_TEXT = 6, + COM_STORED_DESC_TEXT = 7 }; enum ComColumnDirection { COM_UNKNOWN_DIRECTION http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/19c96b1e/core/sql/common/OperTypeEnum.h ---------------------------------------------------------------------- diff --git a/core/sql/common/OperTypeEnum.h b/core/sql/common/OperTypeEnum.h index b37e315..9dcbd6a 100644 --- a/core/sql/common/OperTypeEnum.h +++ b/core/sql/common/OperTypeEnum.h @@ -828,6 +828,7 @@ enum OperatorTypeEnum { DDL_FIRST_STMT_OP = DDL_FIRST_DDL_OP, DDL_ALTER_AUDIT_CONFIG, DDL_ALTER_CATALOG, + DDL_ALTER_SCHEMA, DDL_ALTER_INDEX_ATTRIBUTE, DDL_ALTER_INDEX_ALTER_HBASE_OPTIONS, DDL_ALTER_LIBRARY, @@ -850,6 +851,7 @@ enum OperatorTypeEnum { DDL_ALTER_TABLE_MOVE, DDL_ALTER_TABLE_PARTITION, DDL_ALTER_TABLE_RENAME, + DDL_ALTER_TABLE_STORED_DESC, DDL_ALTER_TABLE_SET_CONSTRAINT, DDL_ALTER_TABLE_DROPPABLE, DDL_ALTER_TABLE_INSERT_ONLY, http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/19c96b1e/core/sql/generator/GenExplain.cpp ---------------------------------------------------------------------- diff --git a/core/sql/generator/GenExplain.cpp b/core/sql/generator/GenExplain.cpp index 42a29df..eeed24b 100644 --- a/core/sql/generator/GenExplain.cpp +++ b/core/sql/generator/GenExplain.cpp @@ -63,6 +63,7 @@ #include "StmtDDLCreateTable.h" #include "StmtDDLCreateIndex.h" #include "ComDistribution.h" +#include "TrafDDLdesc.h" void RelExpr::addExplainPredicates(ExplainTupleMaster * explainTuple, @@ -1350,6 +1351,21 @@ static NABoolean isInternalCQD(DefaultConstants attr) else return FALSE; } + +// explain root displays user specified cqds. +// Some cqds are disabled or enabled in regress/tools/sbdefs during +// regressions run. That can cause explain plan diffs. +// Specify those cqds in these methods so they are not displayed. +// This method is only called during regressions run. +static NABoolean displayDuringRegressRun(DefaultConstants attr) +{ + if ((attr == TRAF_READ_OBJECT_DESC) || + (attr == TRAF_STORE_OBJECT_DESC)) + return FALSE; + else + return TRUE; +} + ExplainTuple * RelRoot::addSpecificExplainInfo(ExplainTupleMaster *explainTuple, ComTdb * tdb, @@ -1357,12 +1373,14 @@ RelRoot::addSpecificExplainInfo(ExplainTupleMaster *explainTuple, { NAString statement; + NABoolean sqlmxRegress = (getenv("SQLMX_REGRESS") != NULL); + // if regressions are running and this explain is for a DDL, then // do not return root specific explain info. This is done to avoid // differences in root explain information during regression runs // on different systems. if ((child(0) && child(0)->castToRelExpr()->getOperatorType() == REL_DDL) && - (getenv("SQLMX_REGRESS") != NULL)) + (sqlmxRegress)) // (val = ActiveControlDB()->getControlSessionValue("EXPLAIN")) && // (*val == "ON")) { @@ -1576,7 +1594,8 @@ RelRoot::addSpecificExplainInfo(ExplainTupleMaster *explainTuple, for (CollIndex i = 0; i < cdb->getCQDList().entries(); i++) { ControlQueryDefault * cqd = cdb->getCQDList()[i]; - if ((NOT isInternalCQD(cqd->getAttrEnum())) && !cqd->reset()) + if ((NOT isInternalCQD(cqd->getAttrEnum())) && (!cqd->reset()) && + (sqlmxRegress && displayDuringRegressRun(cqd->getAttrEnum()))) { statement += cqd->getToken().data(); statement += ": "; @@ -2077,7 +2096,7 @@ const char * ExplainFunc::getVirtualTableName() //{ return "EXPLAIN__"; } {return getVirtualTableNameStr();} -desc_struct * ExplainFunc::createVirtualTableDesc() +TrafDesc * ExplainFunc::createVirtualTableDesc() { // Create a descriptor for this 'virtual' table called EXPLAIN__. // The table has 14 columns: @@ -2098,20 +2117,17 @@ desc_struct * ExplainFunc::createVirtualTableDesc() // // - // readtabledef_allocate_desc() requires that HEAP (STMTHEAP) be used for new + // TrafAllocateDDLdesc() requires that HEAP (STMTHEAP) be used for new - desc_struct *tableDesc = readtabledef_allocate_desc(DESC_TABLE_TYPE); + TrafDesc *tableDesc = TrafAllocateDDLdesc(DESC_TABLE_TYPE, NULL); const char *tableName = getVirtualTableName(); - tableDesc->body.table_desc.tablename = new HEAP char[strlen(tableName)+1]; - strcpy(tableDesc->body.table_desc.tablename, tableName); - - desc_struct *filesDesc = readtabledef_allocate_desc(DESC_FILES_TYPE); - tableDesc->body.table_desc.files_desc = filesDesc; - filesDesc->body.files_desc.fileorganization = KEY_SEQUENCED_FILE; + tableDesc->tableDesc()->tablename = new HEAP char[strlen(tableName)+1]; + strcpy(tableDesc->tableDesc()->tablename, tableName); - tableDesc->body.table_desc.underlyingFileType = SQLMX; + TrafDesc *filesDesc = TrafAllocateDDLdesc(DESC_FILES_TYPE, NULL); + tableDesc->tableDesc()->files_desc = filesDesc; - desc_struct *columnDesc; + TrafDesc *columnDesc; UInt32 offset = 0; Int32 colnumber = ComTdbExplain::getVirtTableNumCols(); ComTdbVirtTableColumnInfo * vtci = ComTdbExplain::getVirtTableColumnInfo(); @@ -2132,35 +2148,36 @@ desc_struct * ExplainFunc::createVirtualTableDesc() columnDesc = Generator::createColDescs(getVirtualTableName(), vtci, //ComTdbExplain::getVirtTableColumnInfo(), colnumber, - offset); - columnDesc->body.columns_desc.colclass = 'S'; + offset, NULL); + columnDesc->columnsDesc()->colclass = 'S'; // CMPASSERT(colnumber == 14 && offset == 3492); // Sanity check - tableDesc->body.table_desc.columns_desc = columnDesc; - tableDesc->body.table_desc.colcount = colnumber; - tableDesc->body.table_desc.record_length = (Lng32) offset; - - - desc_struct *indexDesc = readtabledef_allocate_desc(DESC_INDEXES_TYPE); - tableDesc->body.table_desc.indexes_desc = indexDesc; - indexDesc->body.indexes_desc.tablename = tableDesc->body.table_desc.tablename; - indexDesc->body.indexes_desc.indexname = tableDesc->body.table_desc.tablename; - indexDesc->body.indexes_desc.ext_indexname = tableDesc->body.table_desc.tablename; - desc_struct *indFilesDesc = readtabledef_allocate_desc(DESC_FILES_TYPE); - indexDesc->body.indexes_desc.files_desc = indFilesDesc; - indFilesDesc->body.files_desc.fileorganization = KEY_SEQUENCED_FILE; - - indexDesc->body.indexes_desc.keytag = 0; - indexDesc->body.indexes_desc.record_length = 4; - indexDesc->body.indexes_desc.colcount = 1; - indexDesc->body.indexes_desc.unique = -1; - indexDesc->body.indexes_desc.blocksize = 4096; // doesn't matter. - - desc_struct *keyDesc = readtabledef_allocate_desc(DESC_KEYS_TYPE); - indexDesc->body.indexes_desc.keys_desc = keyDesc; - keyDesc->body.keys_desc.indexname = indexDesc->body.indexes_desc.indexname; - keyDesc->body.keys_desc.keyseqnumber = 0; - keyDesc->body.keys_desc.tablecolnumber = 0; - keyDesc->body.keys_desc.ordering = 0; + tableDesc->tableDesc()->columns_desc = columnDesc; + tableDesc->tableDesc()->colcount = colnumber; + tableDesc->tableDesc()->record_length = (Lng32) offset; + + ComUID comUID; + comUID.make_UID(); + Int64 objUID = comUID.get_value(); + tableDesc->tableDesc()->objectUID = objUID; + + TrafDesc *indexDesc = TrafAllocateDDLdesc(DESC_INDEXES_TYPE, NULL); + tableDesc->tableDesc()->indexes_desc = indexDesc; + indexDesc->indexesDesc()->tablename = tableDesc->tableDesc()->tablename; + indexDesc->indexesDesc()->indexname = tableDesc->tableDesc()->tablename; + TrafDesc *indFilesDesc = TrafAllocateDDLdesc(DESC_FILES_TYPE, NULL); + indexDesc->indexesDesc()->files_desc = indFilesDesc; + + indexDesc->indexesDesc()->keytag = 0; + indexDesc->indexesDesc()->record_length = 4; + indexDesc->indexesDesc()->colcount = 1; + indexDesc->indexesDesc()->setUnique(TRUE); + indexDesc->indexesDesc()->blocksize = 4096; // doesn't matter. + + TrafDesc *keyDesc = TrafAllocateDDLdesc(DESC_KEYS_TYPE, NULL); + indexDesc->indexesDesc()->keys_desc = keyDesc; + keyDesc->keysDesc()->keyseqnumber = 0; + keyDesc->keysDesc()->tablecolnumber = 0; + keyDesc->keysDesc()->setDescending(FALSE); return tableDesc; } http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/19c96b1e/core/sql/generator/GenPreCode.cpp ---------------------------------------------------------------------- diff --git a/core/sql/generator/GenPreCode.cpp b/core/sql/generator/GenPreCode.cpp index a122a44..d40f115 100644 --- a/core/sql/generator/GenPreCode.cpp +++ b/core/sql/generator/GenPreCode.cpp @@ -2839,6 +2839,7 @@ short DDLExpr::ddlXnsInfo(NABoolean &isDDLxn, NABoolean &xnCanBeStarted) ddlNode->castToStmtDDLNode()->ddlXns()) && ((ddlNode->getOperatorType() == DDL_CLEANUP_OBJECTS) || (ddlNode->getOperatorType() == DDL_ALTER_TABLE_DROP_COLUMN) || + (ddlNode->getOperatorType() == DDL_ALTER_SCHEMA) || (ddlNode->getOperatorType() == DDL_CREATE_INDEX) || (ddlNode->getOperatorType() == DDL_POPULATE_INDEX) || (ddlNode->getOperatorType() == DDL_ALTER_TABLE_ALTER_COLUMN_DATATYPE))) @@ -2860,7 +2861,8 @@ RelExpr * DDLExpr::preCodeGen(Generator * generator, if (! GenericUtilExpr::preCodeGen(generator,externalInputs,pulledNewInputs)) return NULL; - if (specialDDL()) + if ((specialDDL()) || + (initHbase_)) { generator->setAqrEnabled(FALSE); } http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/19c96b1e/core/sql/generator/GenRelExeUtil.cpp ---------------------------------------------------------------------- diff --git a/core/sql/generator/GenRelExeUtil.cpp b/core/sql/generator/GenRelExeUtil.cpp index cf72a7f..82ffd07 100644 --- a/core/sql/generator/GenRelExeUtil.cpp +++ b/core/sql/generator/GenRelExeUtil.cpp @@ -100,16 +100,15 @@ #include "ComSmallDefs.h" #include "sql_buffer_size.h" #include "ExSqlComp.h" // for NAExecTrans - - +#include "TrafDDLdesc.h" #include "ComCextdecs.h" #include "SqlParserGlobals.h" // Parser Flags // this comes from GenExplain.cpp (sorry, should have a header file) -desc_struct * createVirtExplainTableDesc(); -void deleteVirtExplainTableDesc(desc_struct *); +TrafDesc * createVirtExplainTableDesc(); +void deleteVirtExplainTableDesc(TrafDesc *); short GenericUtilExpr::processOutputRow(Generator * generator, @@ -276,9 +275,9 @@ short ExeUtilProcessVolatileTable::codeGen(Generator * generator) const char * ExeUtilExpr::getVirtualTableName() { return ("EXE_UTIL_EXPR__"); } -desc_struct *ExeUtilExpr::createVirtualTableDesc() +TrafDesc *ExeUtilExpr::createVirtualTableDesc() { - desc_struct * table_desc = + TrafDesc * table_desc = Generator::createVirtualTableDesc(getVirtualTableName(), ComTdbExeUtil::getVirtTableNumCols(), ComTdbExeUtil::getVirtTableColumnInfo(), @@ -295,7 +294,7 @@ desc_struct *ExeUtilExpr::createVirtualTableDesc() const char * ExeUtilDisplayExplain::getVirtualTableName() { return "EXE_UTIL_DISPLAY_EXPLAIN__"; } -desc_struct *ExeUtilDisplayExplain::createVirtualTableDesc() +TrafDesc *ExeUtilDisplayExplain::createVirtualTableDesc() { Lng32 outputRowSize = (Lng32) CmpCommon::getDefaultNumeric(EXPLAIN_OUTPUT_ROW_SIZE); @@ -309,7 +308,7 @@ desc_struct *ExeUtilDisplayExplain::createVirtualTableDesc() else vtci = ComTdbExeUtilDisplayExplain::getVirtTableColumnInfo(); - desc_struct * table_desc = + TrafDesc * table_desc = Generator::createVirtualTableDesc (getVirtualTableName(), ComTdbExeUtilDisplayExplain::getVirtTableNumCols(), @@ -390,17 +389,17 @@ short ExeUtilDisplayExplain::codeGen(Generator * generator) } ExplainFunc ef; - desc_struct * desc = ef.createVirtualTableDesc(); + TrafDesc * desc = ef.createVirtualTableDesc(); - desc_struct * column_desc = desc->body.table_desc.columns_desc; + TrafDesc * column_desc = desc->tableDesc()->columns_desc; Lng32 ij = 0; while (ij < EXPLAIN_DESCRIPTION_INDEX) { - column_desc = column_desc->header.next; + column_desc = column_desc->next; ij++; } - Lng32 colDescSize = column_desc->body.columns_desc.length; + Lng32 colDescSize = column_desc->columnsDesc()->length; Lng32 outputRowSize = (Lng32) CmpCommon::getDefaultNumeric(EXPLAIN_OUTPUT_ROW_SIZE); @@ -1214,9 +1213,9 @@ short ExeUtilGetProcessStatistics::codeGen(Generator * generator) const char * ExeUtilGetUID::getVirtualTableName() { return "EXE_UTIL_GET_UID__"; } -desc_struct *ExeUtilGetUID::createVirtualTableDesc() +TrafDesc *ExeUtilGetUID::createVirtualTableDesc() { - desc_struct * table_desc = + TrafDesc * table_desc = Generator::createVirtualTableDesc(getVirtualTableName(), ComTdbExeUtilGetUID::getVirtTableNumCols(), ComTdbExeUtilGetUID::getVirtTableColumnInfo(), @@ -1292,9 +1291,9 @@ short ExeUtilGetUID::codeGen(Generator * generator) const char * ExeUtilGetQID::getVirtualTableName() { return "EXE_UTIL_GET_QID__"; } -desc_struct *ExeUtilGetQID::createVirtualTableDesc() +TrafDesc *ExeUtilGetQID::createVirtualTableDesc() { - desc_struct * table_desc = + TrafDesc * table_desc = Generator::createVirtualTableDesc(getVirtualTableName(), ComTdbExeUtilGetQID::getVirtTableNumCols(), ComTdbExeUtilGetQID::getVirtTableColumnInfo(), @@ -3369,9 +3368,9 @@ short ExeUtilHiveTruncate::codeGen(Generator * generator) const char * ExeUtilRegionStats::getVirtualTableName() { return ("EXE_UTIL_REGION_STATS__"); } -desc_struct *ExeUtilRegionStats::createVirtualTableDesc() +TrafDesc *ExeUtilRegionStats::createVirtualTableDesc() { - desc_struct * table_desc = NULL; + TrafDesc * table_desc = NULL; if (displayFormat_) table_desc = ExeUtilExpr::createVirtualTableDesc(); else @@ -3486,9 +3485,9 @@ short ExeUtilRegionStats::codeGen(Generator * generator) const char * ExeUtilLobInfo::getVirtualTableName() { return ("EXE_UTIL_LOB_INFO__"); } -desc_struct *ExeUtilLobInfo::createVirtualTableDesc() +TrafDesc *ExeUtilLobInfo::createVirtualTableDesc() { - desc_struct * table_desc = NULL; + TrafDesc * table_desc = NULL; if (tableFormat_) table_desc = Generator::createVirtualTableDesc( getVirtualTableName(), @@ -4288,9 +4287,9 @@ const char * HiveMDaccessFunc::getVirtualTableName() return "HIVEMD__"; } -desc_struct *HiveMDaccessFunc::createVirtualTableDesc() +TrafDesc *HiveMDaccessFunc::createVirtualTableDesc() { - desc_struct * table_desc = + TrafDesc * table_desc = Generator::createVirtualTableDesc( getVirtualTableName(), ComTdbExeUtilHiveMDaccess::getVirtTableNumCols((char*)mdType_.data()), http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/19c96b1e/core/sql/generator/GenRelMisc.cpp ---------------------------------------------------------------------- diff --git a/core/sql/generator/GenRelMisc.cpp b/core/sql/generator/GenRelMisc.cpp index 7f61807..d37a8e6 100644 --- a/core/sql/generator/GenRelMisc.cpp +++ b/core/sql/generator/GenRelMisc.cpp @@ -105,11 +105,13 @@ #include "ComCextdecs.h" +#include "TrafDDLdesc.h" + #include "SqlParserGlobals.h" // Parser Flags // this comes from GenExplain.cpp (sorry, should have a header file) -desc_struct * createVirtExplainTableDesc(); -void deleteVirtExplainTableDesc(desc_struct *); +TrafDesc * createVirtExplainTableDesc(); +void deleteVirtExplainTableDesc(TrafDesc *); ///////////////////////////////////////////////////////////////////// // @@ -364,9 +366,9 @@ short GenericUtilExpr::codeGen(Generator * generator) const char * DDLExpr::getVirtualTableName() { return (producesOutput() ? "DDL_EXPR__" : NULL); } -desc_struct *DDLExpr::createVirtualTableDesc() +TrafDesc *DDLExpr::createVirtualTableDesc() { - desc_struct * table_desc = NULL; + TrafDesc * table_desc = NULL; if (producesOutput()) { table_desc = @@ -1226,12 +1228,12 @@ short RelRoot::codeGen(Generator * generator) } ExplainFunc explainFunc; - desc_struct *explainDescStruct = explainFunc.createVirtualTableDesc(); + TrafDesc *explainDescStruct = explainFunc.createVirtualTableDesc(); Space *explainSpace = generator->getFragmentDir()-> getSpace(generator->getExplainFragDirIndex()); - table_desc_struct *tableDesc = &(explainDescStruct->body.table_desc); + TrafTableDesc *tableDesc = explainDescStruct->tableDesc(); // Determine the length of the Explain Tuple. Lng32 recLength = tableDesc->record_length; @@ -1242,21 +1244,21 @@ short RelRoot::codeGen(Generator * generator) explainDesc = new(explainSpace) ExplainDesc(numCols, recLength, explainSpace); - desc_struct *cols = tableDesc->columns_desc; + TrafDesc *cols = tableDesc->columns_desc; // For each column of the Virtual Explain Table, extract the // relevant info. from the table desc and put it into the ExplainDesc for(Int32 c = 0; c < numCols; c++ /* no pun intended */) { - columns_desc_struct *colsDesc = &(cols->body.columns_desc); + TrafColumnsDesc *colsDesc = (cols->columnsDesc()); explainDesc->setColDescr(c, colsDesc->datatype, colsDesc->length, colsDesc->offset, - colsDesc->null_flag); + colsDesc->isNullable()); - cols = cols->header.next; + cols = cols->next; } explainFunc.deleteVirtualTableDesc(explainDescStruct); @@ -5092,13 +5094,11 @@ short PhyPack::codeGen(Generator* generator) const char * TableValuedFunction::getVirtualTableName() { return "??TableValuedFunction??"; } -desc_struct *TableValuedFunction::createVirtualTableDesc() +TrafDesc *TableValuedFunction::createVirtualTableDesc() { return NULL; } -void TableValuedFunction::deleteVirtualTableDesc(desc_struct *vtd) +void TableValuedFunction::deleteVirtualTableDesc(TrafDesc *vtd) { - ReadTableDef readTableDef; - readTableDef.deleteTree(vtd); } // ----------------------------------------------------------------------- @@ -5108,9 +5108,9 @@ const char * StatisticsFunc::getVirtualTableName() //{ return "STATISTICS__"; } {return getVirtualTableNameStr();} -desc_struct *StatisticsFunc::createVirtualTableDesc() +TrafDesc *StatisticsFunc::createVirtualTableDesc() { - desc_struct * table_desc = + TrafDesc * table_desc = Generator::createVirtualTableDesc(getVirtualTableName(), ComTdbStats::getVirtTableNumCols(), ComTdbStats::getVirtTableColumnInfo(), @@ -5272,29 +5272,22 @@ short StatisticsFunc::codeGen(Generator* generator) // ProxyFunc methods // ----------------------------------------------------------------------- -static const keys_desc_struct proxy_key_descs[] = +static void initProxyKeyDescStruct(TrafKeysDesc *tgt, ComUInt32& src) { - // keys_desc_struct is defined in sqlcat/desc.h: - // indexname keyname keyseqnumber tablecolnumber ordering - { 0, 0, 1, 0, 0 } -}; - -static void initProxyKeyDescStruct(keys_desc_struct *tgt, ComUInt32& src) -{ - tgt->keyseqnumber = proxy_key_descs[src].keyseqnumber; - tgt->tablecolnumber = proxy_key_descs[src].tablecolnumber; - tgt->ordering = proxy_key_descs[src].ordering; + tgt->keyseqnumber = 1; + tgt->tablecolnumber = 0; + tgt->setDescending(FALSE); } static Lng32 createDescStructsForProxy(const ProxyFunc &proxy, char *tableName, - desc_struct *&colDescs, - desc_struct *&keyDescs) + TrafDesc *&colDescs, + TrafDesc *&keyDescs) { colDescs = NULL; keyDescs = NULL; Lng32 reclen = 0; - desc_struct *prev_desc = NULL; + TrafDesc *prev_desc = NULL; ComUInt32 numCols = proxy.getNumColumns(); // Creates and populates column descs @@ -5302,75 +5295,71 @@ static Lng32 createDescStructsForProxy(const ProxyFunc &proxy, // Create key descs prev_desc = NULL; - numCols = sizeof(proxy_key_descs) / sizeof(keys_desc_struct); + numCols = 1; for (ComUInt32 keyNum = 0; keyNum < numCols; keyNum++) { - desc_struct *key_desc = readtabledef_allocate_desc(DESC_KEYS_TYPE); + TrafDesc *key_desc = TrafAllocateDDLdesc(DESC_KEYS_TYPE, NULL); if (prev_desc) - prev_desc->header.next = key_desc; + prev_desc->next = key_desc; else keyDescs = key_desc; prev_desc = key_desc; - initProxyKeyDescStruct(&key_desc->body.keys_desc, keyNum); + initProxyKeyDescStruct(key_desc->keysDesc(), keyNum); } return reclen; } -desc_struct *ProxyFunc::createVirtualTableDesc() +TrafDesc *ProxyFunc::createVirtualTableDesc() { - // readtabledef_allocate_desc() requires that HEAP (STMTHEAP) + // TrafAllocateDDLdesc() requires that HEAP (STMTHEAP) // be used for operator new herein - desc_struct *table_desc = readtabledef_allocate_desc(DESC_TABLE_TYPE); + TrafDesc *table_desc = TrafAllocateDDLdesc(DESC_TABLE_TYPE, NULL); const char *tableName = getVirtualTableName(); - table_desc->body.table_desc.tablename = new HEAP char[strlen(tableName)+1]; - strcpy(table_desc->body.table_desc.tablename, tableName); + table_desc->tableDesc()->tablename = new HEAP char[strlen(tableName)+1]; + strcpy(table_desc->tableDesc()->tablename, tableName); - table_desc->body.table_desc.issystemtablecode = 1; - table_desc->body.table_desc.underlyingFileType = SQLMX; + table_desc->tableDesc()->setSystemTableCode(TRUE); - desc_struct *files_desc = readtabledef_allocate_desc(DESC_FILES_TYPE); - files_desc->body.files_desc.audit = -1; // audited table - files_desc->body.files_desc.fileorganization = KEY_SEQUENCED_FILE; - table_desc->body.table_desc.files_desc = files_desc; + TrafDesc *files_desc = TrafAllocateDDLdesc(DESC_FILES_TYPE, NULL); + files_desc->filesDesc()->setAudited(TRUE); // audited table + table_desc->tableDesc()->files_desc = files_desc; - desc_struct *cols_descs = NULL; - desc_struct *keys_descs = NULL; + TrafDesc *cols_descs = NULL; + TrafDesc *keys_descs = NULL; - table_desc->body.table_desc.colcount = (Int32) getNumColumns(); + table_desc->tableDesc()->colcount = (Int32) getNumColumns(); - table_desc->body.table_desc.record_length = + table_desc->tableDesc()->record_length = createDescStructsForProxy(*this, - table_desc->body.table_desc.tablename, + table_desc->tableDesc()->tablename, cols_descs, keys_descs); - desc_struct *index_desc = readtabledef_allocate_desc(DESC_INDEXES_TYPE); - index_desc->body.indexes_desc.tablename = - table_desc->body.table_desc.tablename; - index_desc->body.indexes_desc.indexname = - table_desc->body.table_desc.tablename; - index_desc->body.indexes_desc.keytag = 0; // primary index - index_desc->body.indexes_desc.record_length = - table_desc->body.table_desc.record_length; - index_desc->body.indexes_desc.colcount = - table_desc->body.table_desc.colcount; - index_desc->body.indexes_desc.isVerticalPartition = 0; - index_desc->body.indexes_desc.blocksize = 4096; // doesn't matter. + TrafDesc *index_desc = TrafAllocateDDLdesc(DESC_INDEXES_TYPE, NULL); + index_desc->indexesDesc()->tablename = + table_desc->tableDesc()->tablename; + index_desc->indexesDesc()->indexname = + table_desc->tableDesc()->tablename; + index_desc->indexesDesc()->keytag = 0; // primary index + index_desc->indexesDesc()->record_length = + table_desc->tableDesc()->record_length; + index_desc->indexesDesc()->colcount = + table_desc->tableDesc()->colcount; + index_desc->indexesDesc()->blocksize = 4096; // doesn't matter. // cannot simply point to same files desc as the table one, // because then ReadTableDef::deleteTree frees same memory twice (error) - desc_struct *i_files_desc = readtabledef_allocate_desc(DESC_FILES_TYPE); - i_files_desc->body.files_desc.audit = -1; // audited table - i_files_desc->body.files_desc.fileorganization = KEY_SEQUENCED_FILE; - index_desc->body.indexes_desc.files_desc = i_files_desc; - - index_desc->body.indexes_desc.keys_desc = keys_descs; - table_desc->body.table_desc.columns_desc = cols_descs; - table_desc->body.table_desc.indexes_desc = index_desc; + TrafDesc *i_files_desc = TrafAllocateDDLdesc(DESC_FILES_TYPE, NULL); + i_files_desc->filesDesc()->setAudited(TRUE); // audited table + index_desc->indexesDesc()->files_desc = i_files_desc; + + index_desc->indexesDesc()->keys_desc = keys_descs; + table_desc->tableDesc()->columns_desc = cols_descs; + table_desc->tableDesc()->indexes_desc = index_desc; return table_desc; } http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/19c96b1e/core/sql/generator/GenRelScan.cpp ---------------------------------------------------------------------- diff --git a/core/sql/generator/GenRelScan.cpp b/core/sql/generator/GenRelScan.cpp index 0b152ff..042ffea 100644 --- a/core/sql/generator/GenRelScan.cpp +++ b/core/sql/generator/GenRelScan.cpp @@ -50,6 +50,7 @@ #include "RelUpdate.h" #include "HDFSHook.h" #include "CmpSeabaseDDL.h" +#include "TrafDDLdesc.h" ///////////////////////////////////////////////////////////////////// @@ -1377,21 +1378,19 @@ NABoolean HbaseAccess::validateVirtualTableDesc(NATable * naTable) return TRUE; } -void populateRangeDescForBeginKey(char* buf, Int32 len, struct desc_struct* target, NAMemory* heap) +void populateRangeDescForBeginKey(char* buf, Int32 len, struct TrafDesc* target, NAMemory* heap) { - target->header.nodetype = DESC_HBASE_RANGE_REGION_TYPE; - target->body.hbase_region_desc.beginKey = buf; - target->body.hbase_region_desc.beginKeyLen = len; - target->body.hbase_region_desc.endKey = NULL; - target->body.hbase_region_desc.endKeyLen = 0; + target->nodetype = DESC_HBASE_RANGE_REGION_TYPE; + target->hbaseRegionDesc()->beginKey = buf; + target->hbaseRegionDesc()->beginKeyLen = len; + target->hbaseRegionDesc()->endKey = NULL; + target->hbaseRegionDesc()->endKeyLen = 0; } -void populateRegionDescAsRANGE(char* buf, Int32 len, struct desc_struct* target, NAMemory*); - -desc_struct *HbaseAccess::createVirtualTableDesc(const char * name, +TrafDesc *HbaseAccess::createVirtualTableDesc(const char * name, NABoolean isRW, NABoolean isCW, NAArray<HbaseStr>* beginKeys) { - desc_struct * table_desc = NULL; + TrafDesc * table_desc = NULL; if (isRW) table_desc = @@ -1411,9 +1410,9 @@ desc_struct *HbaseAccess::createVirtualTableDesc(const char * name, if (table_desc) { - struct desc_struct* head = assembleDescs(beginKeys, populateRangeDescForBeginKey, STMTHEAP); + struct TrafDesc* head = Generator::assembleDescs(beginKeys, NULL, NULL); - ((table_desc_struct*)table_desc)->hbase_regionkey_desc = head; + table_desc->tableDesc()->hbase_regionkey_desc = head; Lng32 v1 = (Lng32) CmpCommon::getDefaultNumeric(HBASE_MAX_COLUMN_NAME_LENGTH); @@ -1422,26 +1421,26 @@ desc_struct *HbaseAccess::createVirtualTableDesc(const char * name, Lng32 v3 = (Lng32) CmpCommon::getDefaultNumeric(HBASE_MAX_COLUMN_INFO_LENGTH); - desc_struct * cols_desc = table_desc->body.table_desc.columns_desc; - for (Lng32 i = 0; i < table_desc->body.table_desc.colcount; i++) + TrafDesc * cols_desc = table_desc->tableDesc()->columns_desc; + for (Lng32 i = 0; i < table_desc->tableDesc()->colcount; i++) { if (isRW) { if (i == HBASE_ROW_ROWID_INDEX) - cols_desc->body.columns_desc.length = v1; + cols_desc->columnsDesc()->length = v1; else if (i == HBASE_COL_DETAILS_INDEX) - cols_desc->body.columns_desc.length = v3; + cols_desc->columnsDesc()->length = v3; } else { if ((i == HBASE_ROW_ID_INDEX) || (i == HBASE_COL_NAME_INDEX) || (i == HBASE_COL_FAMILY_INDEX)) - cols_desc->body.columns_desc.length = v1; + cols_desc->columnsDesc()->length = v1; else if (i == HBASE_COL_VALUE_INDEX) - cols_desc->body.columns_desc.length = v2; + cols_desc->columnsDesc()->length = v2; } - cols_desc = cols_desc->header.next; + cols_desc = cols_desc->next; } // for } @@ -1449,11 +1448,11 @@ desc_struct *HbaseAccess::createVirtualTableDesc(const char * name, return table_desc; } -desc_struct *HbaseAccess::createVirtualTableDesc(const char * name, +TrafDesc *HbaseAccess::createVirtualTableDesc(const char * name, NAList<char*> &colNameList, NAList<char*> &colValList) { - desc_struct * table_desc = NULL; + TrafDesc * table_desc = NULL; Lng32 arrSize = colNameList.entries(); ComTdbVirtTableColumnInfo * colInfoArray = (ComTdbVirtTableColumnInfo*) http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/19c96b1e/core/sql/generator/GenUdr.cpp ---------------------------------------------------------------------- diff --git a/core/sql/generator/GenUdr.cpp b/core/sql/generator/GenUdr.cpp index a19aa47..baffd54 100644 --- a/core/sql/generator/GenUdr.cpp +++ b/core/sql/generator/GenUdr.cpp @@ -1907,7 +1907,7 @@ PhysicalTableMappingUDF::codeGen(Generator *generator) return result; } -desc_struct *TableMappingUDF::createVirtualTableDesc() +TrafDesc *TableMappingUDF::createVirtualTableDesc() { Int32 numOutputCols = getNARoutine()->getOutParamCount(); @@ -1922,7 +1922,7 @@ desc_struct *TableMappingUDF::createVirtualTableDesc() outColsInfo[i].length = outCol->getType()->getNominalSize(); outColsInfo[i].nullable = (Lng32) outCol->getType()->supportsSQLnull(); } - desc_struct * table_desc = + TrafDesc * table_desc = Generator::createVirtualTableDesc(getRoutineName().getQualifiedNameAsString().data(), numOutputCols, outColsInfo,