From 9ae9c5999cd87544e96410c6082caccc9ebd4650 Mon Sep 17 00:00:00 2001 From: Andy Yang Date: Thu, 22 Mar 2018 09:08:59 +0800 Subject: [PATCH 1/3] [TRAFODION-3007] update statistics report error on volatile table --- core/sql/optimizer/BindRelExpr.cpp | 5 ++++- core/sql/optimizer/ObjectNames.cpp | 7 +++++++ core/sql/optimizer/ObjectNames.h | 1 + core/sql/regress/executor/EXPECTED013.SB | 4 +--- core/sql/sqlcomp/CmpSeabaseDDLschema.cpp | 7 +++++-- core/sql/ustat/hs_parser.cpp | 7 ------- 6 files changed, 18 insertions(+), 13 deletions(-) diff --git a/core/sql/optimizer/BindRelExpr.cpp b/core/sql/optimizer/BindRelExpr.cpp index 0faae6ff7d..e6c3eb3a87 100644 --- a/core/sql/optimizer/BindRelExpr.cpp +++ b/core/sql/optimizer/BindRelExpr.cpp @@ -1521,7 +1521,10 @@ NATable *BindWA::getNATable(CorrName& corrName, ((bindWA->inViewDefinition()) || (bindWA->inMVDefinition()))) { - if (! CmpCommon::context()->sqlSession()->validateVolatileQualifiedSchemaName + // for Histogram, support to use VOLATILE SCHEMA + // or else, don't support + if (!corrName.getQualifiedNameObj().isHistogramTable() && + !CmpCommon::context()->sqlSession()->validateVolatileQualifiedSchemaName (corrName.getQualifiedNameObj())) { bindWA->setErrStatus(); diff --git a/core/sql/optimizer/ObjectNames.cpp b/core/sql/optimizer/ObjectNames.cpp index fb4f9b1c8f..1101c2d4ef 100644 --- a/core/sql/optimizer/ObjectNames.cpp +++ b/core/sql/optimizer/ObjectNames.cpp @@ -1441,6 +1441,13 @@ NABoolean QualifiedName::isHistogramIntervals() const return (getObjectName() == HBASE_HISTINT_NAME); } +NABoolean QualifiedName::isHistogramTable() const +{ + const NAString objName = getObjectName(); + return (objName == HBASE_HIST_NAME || + objName == HBASE_HISTINT_NAME || + objName == HBASE_PERS_SAMP_NAME ); +} void ExtendedQualName::print(FILE* ofd, const char* indent, const char* title) const { diff --git a/core/sql/optimizer/ObjectNames.h b/core/sql/optimizer/ObjectNames.h index 5ed7450625..afa95fcc90 100644 --- a/core/sql/optimizer/ObjectNames.h +++ b/core/sql/optimizer/ObjectNames.h @@ -332,6 +332,7 @@ class QualifiedName : public SchemaName NABoolean isHistograms() const; NABoolean isHistogramIntervals() const; + NABoolean isHistogramTable() const; NABoolean isLOBDesc() const; void setObjectName(const NAString &objName) { objectName_ = objName; } void setObjectNameSpace(ComAnsiNameSpace objNameSpace) { objectNameSpace_ = objNameSpace; } diff --git a/core/sql/regress/executor/EXPECTED013.SB b/core/sql/regress/executor/EXPECTED013.SB index db077602c1..bb94d7572c 100644 --- a/core/sql/regress/executor/EXPECTED013.SB +++ b/core/sql/regress/executor/EXPECTED013.SB @@ -93,9 +93,7 @@ A B >> >>update statistics for table t013t1 on every column; -*** ERROR[9247] UPDATE STATISTICS is not supported on volatile tables presently. - ---- SQL operation failed with errors. +--- SQL operation complete. >> >>select * from t013_sch.t013t1; diff --git a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp index d2f0c8997a..dcc7971e67 100644 --- a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp +++ b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp @@ -302,7 +302,7 @@ void CmpSeabaseDDL::createSeabaseSchema( // not reserved NAString tableNotCreated; - if (!createSchemaNode->isVolatile() && !ComIsTrafodionReservedSchemaName(schName)) + if (!ComIsTrafodionReservedSchemaName(schName)) { if (createHistogramTables(&cliInterface, schemaName.getExternalName(), FALSE, tableNotCreated)) @@ -1742,7 +1742,10 @@ Lng32 cliRC = 0; - if (isVolatile) + if (isVolatile && + strcmp(objectName, HBASE_HIST_NAME) != 0 && + strcmp(objectName, HBASE_HISTINT_NAME) != 0 && + strcmp(objectName, HBASE_PERS_SAMP_NAME) != 0) strcpy(volatileString,"VOLATILE"); if (ifExists) diff --git a/core/sql/ustat/hs_parser.cpp b/core/sql/ustat/hs_parser.cpp index c01a6d967d..2b0fff25e7 100644 --- a/core/sql/ustat/hs_parser.cpp +++ b/core/sql/ustat/hs_parser.cpp @@ -243,13 +243,6 @@ Lng32 AddTableName( const hs_table_type type } else { - // This is for UPDATE STATISTICS; the volatile schema name exists. - // For now, UPDATE STATISTICS is not supported. (See also JIRA Trafodion-2004.) - - HSFuncMergeDiags(-UERR_VOLATILE_TABLES_NOT_SUPPORTED); - retcode = -1; - HSHandleError(retcode); // causes a return from this function - // The code below is old code that will be needed once we turn on // support for UPDATE STATISTICS on volatile tables. We leave it here // until the code changes described in JIRA Trafodion-2004 are complete. From b682d75e7784d6296d5d234aebafd9e49e11274d Mon Sep 17 00:00:00 2001 From: Andy Yang Date: Thu, 22 Mar 2018 15:03:05 +0800 Subject: [PATCH 2/3] [TRAFODION-3007] update statistics report error on volatile table - update test case --- core/sql/regress/seabase/EXPECTED010 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/sql/regress/seabase/EXPECTED010 b/core/sql/regress/seabase/EXPECTED010 index ab7f2f3770..1b83dd0344 100644 --- a/core/sql/regress/seabase/EXPECTED010 +++ b/core/sql/regress/seabase/EXPECTED010 @@ -11244,7 +11244,10 @@ Schema(Active ): VOLATILE_SCHEMA_MXID110000244152123793487270871880000000002 Schema(Active ): VOLATILE_SCHEMA_MXID110000244152123793487270871880000000002 Table: VTAB1 + Table: SB_HISTOGRAM_INTERVALS + Table: SB_HISTOGRAMS Table: VTAB2 + Table: SB_PERSISTENT_SAMPLES --- SQL operation complete. >>drop schema minotaur cascade; From 8913b31fe771b3212da860d03e9c2a0d36bf87cc Mon Sep 17 00:00:00 2001 From: Andy Yang Date: Fri, 23 Mar 2018 09:50:13 +0800 Subject: [PATCH 3/3] [TRAFODION-3007] update statistics report error on volatile table - remove useless comments --- core/sql/ustat/hs_parser.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/core/sql/ustat/hs_parser.cpp b/core/sql/ustat/hs_parser.cpp index 2b0fff25e7..497419b941 100644 --- a/core/sql/ustat/hs_parser.cpp +++ b/core/sql/ustat/hs_parser.cpp @@ -243,12 +243,6 @@ Lng32 AddTableName( const hs_table_type type } else { - // The code below is old code that will be needed once we turn on - // support for UPDATE STATISTICS on volatile tables. We leave it here - // until the code changes described in JIRA Trafodion-2004 are complete. - // The code below is never reached because of the HSHandleError call - // above. - // if schema name was specified, validate that it is the // current username. if (schema)