You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by db...@apache.org on 2017/11/15 18:02:58 UTC
[01/11] incubator-trafodion git commit: new COMMENT-ON SQL statement:
init
Repository: incubator-trafodion
Updated Branches:
refs/heads/master 087bb5d0d -> b03aa4fd6
new COMMENT-ON SQL statement: init
1. new SQL syntax: COMMENT ON
2. new component privilege: SQL_OPERATIONS::COMMENT
3. MD table changes: add new column for tables "_MD_".OBJECTS and
"_MD_".COLUMNS
4. SHOWDDL changes: add COMMENT-ON output for each object
5. new build-in views: "_MD_".OBJECT_COMMENT_VIEW and
"_MD_".COLUMN_COMMENT_VIEW
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/078ed10c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/078ed10c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/078ed10c
Branch: refs/heads/master
Commit: 078ed10cc8d5d4024b3a2dd2ff965cac46f38c9f
Parents: 68fe67f
Author: eedy <cq...@gmail.com>
Authored: Thu Nov 2 17:17:31 2017 +0800
Committer: eedy <cq...@gmail.com>
Committed: Thu Nov 2 17:17:31 2017 +0800
----------------------------------------------------------------------
core/sql/comexe/ComTdb.h | 55 ++++++
core/sql/common/OperTypeEnum.h | 1 +
core/sql/nskgmake/sqlcomp/Makefile | 1 +
core/sql/optimizer/RelExeUtil.cpp | 11 +-
core/sql/parser/AllStmtDDLCreate.h | 1 +
core/sql/parser/BindStmtDDL.cpp | 54 ++++++
core/sql/parser/ElemDDLNode.cpp | 8 +
core/sql/parser/ElemDDLNode.h | 3 +
core/sql/parser/StmtDDLCommentOn.h | 148 +++++++++++++++++
core/sql/parser/StmtDDLCreate.cpp | 45 +++++
core/sql/parser/sqlparser.y | 105 +++++++++++-
core/sql/parser/ulexer.cpp | 1 +
core/sql/regress/privs1/EXPECTED133 | Bin 27095 -> 27095 bytes
core/sql/regress/privs1/EXPECTED137 | 14 ++
core/sql/sqlcomp/CmpDescribe.cpp | 159 +++++++++++++++++-
core/sql/sqlcomp/CmpSeabaseDDL.h | 8 +
core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp | 202 +++++++++++++++++++++++
core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp | 18 +-
core/sql/sqlcomp/CmpSeabaseDDLincludes.h | 1 +
core/sql/sqlcomp/CmpSeabaseDDLmd.h | 40 ++++-
core/sql/sqlcomp/CmpSeabaseDDLschema.cpp | 28 +++-
core/sql/sqlcomp/CmpSeabaseDDLtable.cpp | 146 +++++++++++++++-
core/sql/sqlcomp/CmpSeabaseDDLupgrade.h | 23 ++-
core/sql/sqlcomp/CmpSeabaseDDLview.cpp | 19 +++
core/sql/sqlcomp/PrivMgr.cpp | 3 +
core/sql/sqlcomp/PrivMgrDefs.h | 3 +-
26 files changed, 1062 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/comexe/ComTdb.h
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdb.h b/core/sql/comexe/ComTdb.h
index 62b7550..73fa28a 100644
--- a/core/sql/comexe/ComTdb.h
+++ b/core/sql/comexe/ComTdb.h
@@ -1128,6 +1128,61 @@ class ComTdbVirtTableLibraryInfo : public ComTdbVirtTableBase
Int32 schema_owner_id;
};
+
+class ComTdbVirtIndexCommentInfo : public ComTdbVirtTableBase
+{
+ public:
+ ComTdbVirtIndexCommentInfo()
+ : ComTdbVirtTableBase()
+ {
+ init();
+ }
+
+ virtual Int32 size() { return sizeof(ComTdbVirtIndexCommentInfo);}
+
+ const char *indexFullName;
+ const char *indexComment;
+};
+
+
+class ComTdbVirtColumnCommentInfo : public ComTdbVirtTableBase
+{
+ public:
+ ComTdbVirtColumnCommentInfo()
+ : ComTdbVirtTableBase()
+ {
+ init();
+ }
+
+ virtual Int32 size() { return sizeof(ComTdbVirtColumnCommentInfo);}
+
+ const char *columnName;
+ const char *columnComment;
+};
+
+class ComTdbVirtObjCommentInfo : public ComTdbVirtTableBase
+{
+ public:
+ ComTdbVirtObjCommentInfo()
+ : ComTdbVirtTableBase()
+ {
+ init();
+ }
+
+ virtual Int32 size() { return sizeof(ComTdbVirtObjCommentInfo);}
+
+ Int64 objectUid;
+ const char *objectComment;
+
+ Int32 numColumnComment;
+ ComTdbVirtColumnCommentInfo * columnCommentArray;
+
+ Int32 numIndexComment;
+ ComTdbVirtIndexCommentInfo * indexCommentArray;
+};
+
+
+
#endif /* COMTDB_H */
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/common/OperTypeEnum.h
----------------------------------------------------------------------
diff --git a/core/sql/common/OperTypeEnum.h b/core/sql/common/OperTypeEnum.h
index bbf064c..c581fa9 100644
--- a/core/sql/common/OperTypeEnum.h
+++ b/core/sql/common/OperTypeEnum.h
@@ -963,6 +963,7 @@ enum OperatorTypeEnum {
DDL_CLEANUP_OBJECTS,
DDL_LAST_STMT_OP,
DDL_INITIALIZE_SECURITY,
+ DDL_COMMENT_ON,
//
// Elements in DDL statements
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/nskgmake/sqlcomp/Makefile
----------------------------------------------------------------------
diff --git a/core/sql/nskgmake/sqlcomp/Makefile b/core/sql/nskgmake/sqlcomp/Makefile
index ff2dc65..c579ea6 100755
--- a/core/sql/nskgmake/sqlcomp/Makefile
+++ b/core/sql/nskgmake/sqlcomp/Makefile
@@ -33,6 +33,7 @@ CPPSRC := CmpDescribe.cpp \
CmpSeabaseDDLtable.cpp \
CmpSeabaseDDLupgrade.cpp \
CmpSeabaseDDLview.cpp \
+ CmpSeabaseDDLcommentOn.cpp \
PrivMgr.cpp \
PrivMgrCommands.cpp \
PrivMgrDesc.cpp \
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/optimizer/RelExeUtil.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelExeUtil.cpp b/core/sql/optimizer/RelExeUtil.cpp
index 9cf45a9..71c0421 100644
--- a/core/sql/optimizer/RelExeUtil.cpp
+++ b/core/sql/optimizer/RelExeUtil.cpp
@@ -83,6 +83,7 @@
#include "StmtDDLCleanupObjects.h"
#include "StmtDDLAlterLibrary.h"
#include "StmtDDLRegOrUnregHive.h"
+#include "StmtDDLCommentOn.h"
#include <cextdecs/cextdecs.h>
#include "wstr.h"
@@ -4083,6 +4084,7 @@ RelExpr * DDLExpr::bindNode(BindWA *bindWA)
NABoolean externalTable = FALSE;
NABoolean isVolatile = FALSE;
NABoolean isRegister = FALSE;
+ NABoolean isCommentOn = FALSE;
returnStatus_ = FALSE;
@@ -4550,6 +4552,13 @@ RelExpr * DDLExpr::bindNode(BindWA *bindWA)
qualObjName_ = getExprNode()->castToStmtDDLNode()->
castToStmtDDLRegOrUnregObject()->getObjNameAsQualifiedName();
}
+ else if (getExprNode()->castToStmtDDLNode()->castToStmtDDLCommentOn())
+ {
+ isCommentOn = TRUE;
+
+ qualObjName_ = getExprNode()->castToStmtDDLNode()->
+ castToStmtDDLCommentOn()->getObjectNameAsQualifiedName();
+ }
if (isCleanup_)
{
@@ -4557,7 +4566,7 @@ RelExpr * DDLExpr::bindNode(BindWA *bindWA)
hbaseDDLNoUserXn_ = TRUE;
}
- if ((isCreateSchema || isDropSchema || isAlterSchema) || isRegister ||
+ if ((isCreateSchema || isDropSchema || isAlterSchema) || isRegister || isCommentOn ||
((isTable_ || isIndex_ || isView_ || isRoutine_ || isLibrary_ || isSeq) &&
(isCreate_ || isDrop_ || purgedata() ||
(isAlter_ && (alterAddCol || alterDropCol || alterDisableIndex || alterEnableIndex ||
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/parser/AllStmtDDLCreate.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/AllStmtDDLCreate.h b/core/sql/parser/AllStmtDDLCreate.h
index 706ba2a..6a76125 100644
--- a/core/sql/parser/AllStmtDDLCreate.h
+++ b/core/sql/parser/AllStmtDDLCreate.h
@@ -54,6 +54,7 @@
#include "StmtDDLCreateSynonym.h"
#include "StmtDDLCreateExceptionTable.h"
#include "StmtDDLPopulateIndex.h"
+#include "StmtDDLCommentOn.h"
//
// End of File
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/parser/BindStmtDDL.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/BindStmtDDL.cpp b/core/sql/parser/BindStmtDDL.cpp
index d564d41..f0e01e4 100644
--- a/core/sql/parser/BindStmtDDL.cpp
+++ b/core/sql/parser/BindStmtDDL.cpp
@@ -2576,6 +2576,60 @@ StmtDDLAlterUser::bindNode(BindWA * pBindWA)
}
+// -----------------------------------------------------------------------
+// definition of method bindNode() for class StmtDDLCreateLibrary
+// -----------------------------------------------------------------------
+
+ExprNode *
+StmtDDLCommentOn::bindNode(BindWA * pBindWA)
+{
+ ComASSERT(pBindWA);
+
+ objectName_.applyDefaults(pBindWA->getDefaultSchema());
+ if (pBindWA->violateAccessDefaultSchemaOnly(objectName_))
+ return this;
+
+ if (this->type_ == COMMENT_ON_TYPE_COLUMN)
+ {
+ if (NULL == colRef_)
+ {
+ ComASSERT(pBindWA);
+ }
+ else
+ {
+ ActiveSchemaDB()->getNATableDB()->useCache();
+
+ CorrName cn(objectName_, STMTHEAP);
+
+ NATable *naTable = pBindWA->getNATable(cn);
+ if (naTable == NULL || pBindWA->errStatus())
+ {
+ *CmpCommon::diags()
+ << DgSqlCode(-4082)
+ << DgTableName(cn.getExposedNameAsAnsiString());
+
+ return this;
+ }
+
+ const NAColumnArray &nacolArr = naTable->getNAColumnArray();
+ const NAColumn * nacol = nacolArr.getColumn(getColName());
+ if (! nacol)
+ {
+ // column doesnt exist. Error.
+ *CmpCommon::diags() << DgSqlCode(-1009)
+ << DgColumnName(getColName());
+
+ return this;
+ }
+
+ }
+ }
+
+ markAsBound();
+ return this;
+}
+
+
//
// End of File
//
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/parser/ElemDDLNode.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLNode.cpp b/core/sql/parser/ElemDDLNode.cpp
index 5c7b602..78225af 100644
--- a/core/sql/parser/ElemDDLNode.cpp
+++ b/core/sql/parser/ElemDDLNode.cpp
@@ -1543,6 +1543,14 @@ ElemDDLNode::castToStmtDDLCreateLibrary()
return NULL;
}
+StmtDDLCommentOn *
+ElemDDLNode::castToStmtDDLCommentOn()
+{
+ return NULL;
+}
+
+
+
StmtDDLCreateRoutine *
ElemDDLNode::castToStmtDDLCreateRoutine()
{
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/parser/ElemDDLNode.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLNode.h b/core/sql/parser/ElemDDLNode.h
index 1c8b039..fb10591 100644
--- a/core/sql/parser/ElemDDLNode.h
+++ b/core/sql/parser/ElemDDLNode.h
@@ -350,6 +350,7 @@ class StmtDDLRegOrUnregObject;
class StmtDDLCreateRole;
class StmtDDLRoleGrant;
class StmtDDLCleanupObjects;
+class StmtDDLCommentOn;
class QualifiedName;
@@ -690,6 +691,8 @@ public:
virtual StmtDDLCreateRole * castToStmtDDLCreateRole();
virtual StmtDDLRoleGrant * castToStmtDDLRoleGrant();
virtual StmtDDLCleanupObjects * castToStmtDDLCleanupObjects();
+ virtual StmtDDLCommentOn * castToStmtDDLCommentOn();
+
//
// operator
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/parser/StmtDDLCommentOn.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLCommentOn.h b/core/sql/parser/StmtDDLCommentOn.h
new file mode 100644
index 0000000..cec13f6
--- /dev/null
+++ b/core/sql/parser/StmtDDLCommentOn.h
@@ -0,0 +1,148 @@
+/**********************************************************************
+// @@@ 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 STMTDDLCOMMENTON_H
+#define STMTDDLCOMMENTON_H
+/* -*-C++-*-
+ *****************************************************************************
+ *
+ * File: StmtDDLCommentOn.h
+ * Description: class for Comment On Statement (parser node)
+ *
+ *
+ * Created: 8/2/17
+ * Language: C++
+ *
+ *
+ *
+ *
+ *****************************************************************************
+ */
+
+#include "ComSmallDefs.h"
+#include "StmtDDLNode.h"
+
+
+
+// -----------------------------------------------------------------------
+// forward references
+// -----------------------------------------------------------------------
+// None
+
+// -----------------------------------------------------------------------
+// Comment On statement
+// -----------------------------------------------------------------------
+class StmtDDLCommentOn : public StmtDDLNode
+{
+
+public:
+
+ enum COMMENT_ON_TYPES {
+ COMMENT_ON_TYPE_TABLE = 10,
+ COMMENT_ON_TYPE_COLUMN,
+ COMMENT_ON_TYPE_SCHEMA,
+ COMMENT_ON_TYPE_VIEW,
+ COMMENT_ON_TYPE_INDEX,
+ COMMENT_ON_TYPE_LIBRARY,
+ COMMENT_ON_TYPE_PROCEDURE,
+ COMMENT_ON_TYPE_FUNCTION,
+ COMMENT_ON_TYPE_UNKNOWN
+ };
+
+
+ // (default) constructor
+ StmtDDLCommentOn(COMMENT_ON_TYPES objType, const QualifiedName & objName, const NAString & commentStr, CollHeap * heap);
+ StmtDDLCommentOn(COMMENT_ON_TYPES objType, const QualifiedName & objName, const NAString & commentStr, ColReference * colRef, CollHeap * heap);
+
+ // virtual destructor
+ virtual ~StmtDDLCommentOn();
+
+ // cast
+ virtual StmtDDLCommentOn * castToStmtDDLCommentOn();
+
+ // ---------------------------------------------------------------------
+ // accessors
+ // ---------------------------------------------------------------------
+
+ // methods relating to parse tree
+ //virtual Int32 getArity() const;
+ //virtual ExprNode * getChild(Lng32 index);
+
+ // method for binding
+ ExprNode * bindNode(BindWA *bindWAPtr);
+
+
+// accessors
+
+ inline QualifiedName & getObjectNameAsQualifiedName();
+ inline const QualifiedName & getObjectNameAsQualifiedName() const ;
+
+ inline const enum COMMENT_ON_TYPES getObjectType() { return type_; }
+ inline const NAString getObjectName() const;
+ inline const NAString &getComment() const { return comment_; }
+ inline const NAString &getColName() const { return colRef_->getColRefNameObj().getColName(); }
+
+
+ inline Int32 getVersion() {return 1;}
+
+// for tracing
+
+/* virtual const NAString displayLabel1() const;
+ virtual const NAString displayLabel2() const;
+ virtual NATraceList getDetailInfo() const;
+ virtual const NAString getText() const;
+*/
+
+private:
+
+ enum COMMENT_ON_TYPES type_;
+ QualifiedName objectName_;
+ ColReference * colRef_;
+
+ const NAString & comment_;
+
+}; // class StmtDDLCreateTable
+
+
+inline const NAString StmtDDLCommentOn::getObjectName() const
+{
+ NAString objectName = objectName_.getQualifiedNameAsAnsiString();
+
+ return objectName;
+}
+
+inline QualifiedName &
+StmtDDLCommentOn::getObjectNameAsQualifiedName()
+{
+ return objectName_;
+}
+
+inline const QualifiedName &
+StmtDDLCommentOn::getObjectNameAsQualifiedName() const
+{
+ return objectName_;
+}
+
+
+
+#endif // STMTDDLCREATETABLE_H
+
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/parser/StmtDDLCreate.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLCreate.cpp b/core/sql/parser/StmtDDLCreate.cpp
index 9a9c4df..4537f72 100644
--- a/core/sql/parser/StmtDDLCreate.cpp
+++ b/core/sql/parser/StmtDDLCreate.cpp
@@ -78,6 +78,7 @@
#include "StmtDDLCreateSynonym.h"
#include "ElemDDLMVFileAttrClause.h"
#include "StmtDDLCreateExceptionTable.h"
+#include "StmtDDLCommentOn.h"
#include "MVInfo.h"
#include "NumericType.h"
@@ -7161,6 +7162,50 @@ ViewUsages::insertUsedTableName(const QualifiedName &tableName)
*****************************************************/
+
+
+
+// -----------------------------------------------------------------------
+// Methods for class StmtDDLCommentOn
+// -----------------------------------------------------------------------
+
+//
+// Constructor
+//
+
+
+StmtDDLCommentOn::StmtDDLCommentOn(COMMENT_ON_TYPES objType, const QualifiedName & objName, const NAString & commentStr, CollHeap * heap)
+ : StmtDDLNode(DDL_COMMENT_ON),
+ type_(objType),
+ objectName_(objName, heap),
+ comment_(commentStr),
+ colRef_(NULL)
+{
+
+}
+
+
+StmtDDLCommentOn::StmtDDLCommentOn(COMMENT_ON_TYPES objType, const QualifiedName & objName, const NAString & commentStr, ColReference * colRef, CollHeap * heap)
+ : StmtDDLNode(DDL_COMMENT_ON),
+ type_(objType),
+ objectName_(objName, heap),
+ colRef_(colRef),
+ comment_(commentStr)
+{
+
+}
+
+
+StmtDDLCommentOn::~StmtDDLCommentOn()
+{
+
+}
+
+StmtDDLCommentOn * StmtDDLCommentOn::castToStmtDDLCommentOn()
+{
+ return this;
+}
+
//
// End of File
//
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/parser/sqlparser.y
----------------------------------------------------------------------
diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y
index e019918..1b43b02 100755
--- a/core/sql/parser/sqlparser.y
+++ b/core/sql/parser/sqlparser.y
@@ -1676,6 +1676,7 @@ static void enableMakeQuotedStringISO88591Mechanism()
ComMvsAllowed mvsAllowedType;
ComMvAuditType mvAuditType;
MvInitializationType mvInitType;
+ enum StmtDDLCommentOn::COMMENT_ON_TYPES commentOnEnum;
// internal refresh OZ_REFRESH
@@ -2391,6 +2392,8 @@ static void enableMakeQuotedStringISO88591Mechanism()
%type <pElemDDL> with_check_option
%type <levelEnum> optional_levels_clause
%type <levelEnum> levels_clause
+%type <pStmtDDL> comment_on_statement
+%type <commentOnEnum> comment_on_object_types
%type <stringval> optional_component_detail_clause
%type <int64> optional_lob_unit
@@ -14322,6 +14325,9 @@ sql_schema_definition_statement :
| unregister_hbase_statement
{
}
+ | comment_on_statement
+ {
+ }
/* type pStmtDDL */
sql_schema_manipulation_statement :
@@ -33150,7 +33156,7 @@ reset_clause : /* empty */
{ $$ = 0; }
| TOK_RESET
{ $$ = 2; } /* same as RMS_INIT_STATS Positive value because we can't return negative */
-
+
qid_internal_stats_merge_clause : /* empty */
{ $$ = 0; } /* use the session default view type */
@@ -33167,7 +33173,102 @@ stats_merge_clause : /*empty */
{ $$ = SQLCLI_PROGRESS_STATS; }
| TOK_DEFAULT
{ $$ = SQLCLI_SAME_STATS; }
-
+
+
+/* type pStmtDDL */
+comment_on_statement : TOK_COMMENT TOK_ON comment_on_object_types ddl_qualified_name TOK_IS QUOTED_STRING
+ {
+ StmtDDLCommentOn *pNode =
+ new(PARSERHEAP()) StmtDDLCommentOn(
+ $3,
+ *$4,
+ *$6,
+ PARSERHEAP()
+ );
+
+ $$ = pNode;
+ }
+ | TOK_COMMENT TOK_ON TOK_SCHEMA schema_name TOK_IS QUOTED_STRING
+ {
+ // EJF L4J - CQD dynamic are not allowed in Compound Statements
+ if (beginsWith(SQLTEXT(),"BEGIN")) {
+ *SqlParser_Diags << DgSqlCode(-3175);
+ YYERROR;
+ }
+ else { // business as usual
+ NAString tmpSchema($4->getSchemaNameAsAnsiString());
+
+ if (! validateVolatileSchemaName(tmpSchema))
+ {
+ YYERROR;
+ }
+
+ StmtDDLCommentOn *pNode = new(PARSERHEAP()) StmtDDLCommentOn(
+ StmtDDLCommentOn::COMMENT_ON_TYPE_SCHEMA,
+ QualifiedName(SEABASE_SCHEMA_OBJECTNAME, $4->getSchemaName(), $4->getCatalogName(), PARSERHEAP()),
+ *$6,
+ PARSERHEAP());
+
+ $$ = pNode;
+ }
+ }
+ | TOK_COMMENT TOK_ON TOK_COLUMN qualified_name TOK_IS QUOTED_STRING
+ {
+ ShortStringSequence *seq = (ShortStringSequence *) $4;
+ UInt32 numParts = seq->numParts();
+
+ if (numParts < 2)
+ YYABORT;
+
+ NAString strEmpty("", PARSERHEAP());
+
+ NAString *columnName = seq->extract(numParts - 1);
+ NAString *tableName = seq->extract(numParts - 2);
+ NAString *schemaName = numParts > 2 ? seq->extract(numParts - 3) : &strEmpty;
+ NAString *catalogName = numParts > 3 ? seq->extract(numParts - 4) : &strEmpty;
+
+ QualifiedName tblName(*tableName, *schemaName, *catalogName, PARSERHEAP());
+ ColRefName *colRefName = new(PARSERHEAP()) ColRefName(*columnName, CorrName(tblName, PARSERHEAP()));
+ StmtDDLCommentOn *pNode =
+ new(PARSERHEAP()) StmtDDLCommentOn(
+ StmtDDLCommentOn::COMMENT_ON_TYPE_COLUMN,
+ tblName,
+ *$6,
+ new(PARSERHEAP()) ColReference(colRefName),
+ PARSERHEAP()
+ );
+
+ $$ = pNode;
+ }
+
+
+comment_on_object_types : TOK_TABLE
+ {
+ $$ = StmtDDLCommentOn::COMMENT_ON_TYPE_TABLE;
+ }
+ | TOK_INDEX
+ {
+ $$ = StmtDDLCommentOn::COMMENT_ON_TYPE_INDEX;
+ }
+ | TOK_VIEW
+ {
+ $$ = StmtDDLCommentOn::COMMENT_ON_TYPE_VIEW;
+ }
+ | TOK_LIBRARY
+ {
+ $$ = StmtDDLCommentOn::COMMENT_ON_TYPE_LIBRARY;
+ }
+ | TOK_PROCEDURE
+ {
+ $$ = StmtDDLCommentOn::COMMENT_ON_TYPE_PROCEDURE;
+ }
+ | TOK_FUNCTION
+ {
+ $$ = StmtDDLCommentOn::COMMENT_ON_TYPE_FUNCTION;
+ }
+
+
+
/* type tokval */
//
// As many tokens as possible should be ADDED to this list, and REMOVED
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/parser/ulexer.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/ulexer.cpp b/core/sql/parser/ulexer.cpp
index a2d2fab..65bb59c 100644
--- a/core/sql/parser/ulexer.cpp
+++ b/core/sql/parser/ulexer.cpp
@@ -118,6 +118,7 @@ class IntegerList;
#include "SqlParserAux.h"
#include "StmtDDLCreateMV.h"
#include "ElemDDLHbaseOptions.h"
+#include "StmtDDLCommentOn.h"
// Need the definition of the Parsers Union. If this is not defined,
// sqlparser.h will only define the Tokens.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/regress/privs1/EXPECTED133
----------------------------------------------------------------------
diff --git a/core/sql/regress/privs1/EXPECTED133 b/core/sql/regress/privs1/EXPECTED133
index 9be7977..fe6af83 100644
Binary files a/core/sql/regress/privs1/EXPECTED133 and b/core/sql/regress/privs1/EXPECTED133 differ
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/regress/privs1/EXPECTED137
----------------------------------------------------------------------
diff --git a/core/sql/regress/privs1/EXPECTED137 b/core/sql/regress/privs1/EXPECTED137
index 40b421f..c2f3d92 100755
--- a/core/sql/regress/privs1/EXPECTED137
+++ b/core/sql/regress/privs1/EXPECTED137
@@ -1059,6 +1059,13 @@ CREATE COMPONENT PRIVILEGE CREATE_LIBRARY AS 'CL' ON SQL_OPERATIONS SYSTEM
GRANT COMPONENT PRIVILEGE "CREATE_LIBRARY" ON "SQL_OPERATIONS" TO
"DB__ROOTROLE" WITH GRANT OPTION;
+CREATE COMPONENT PRIVILEGE COMMENT AS 'CO' ON SQL_OPERATIONS SYSTEM DETAIL
+ 'Allow grantee to comment on objects and columns';
+
+-- GRANT COMPONENT PRIVILEGE "COMMENT" ON "SQL_OPERATIONS" TO "DB__ROOT" WITH GRANT OPTION;
+GRANT COMPONENT PRIVILEGE "COMMENT" ON "SQL_OPERATIONS" TO "DB__ROOTROLE" WITH
+ GRANT OPTION;
+
CREATE COMPONENT PRIVILEGE CREATE_PROCEDURE AS 'CP' ON SQL_OPERATIONS SYSTEM
DETAIL 'Allow grantee to create procedures';
@@ -1615,6 +1622,13 @@ CREATE COMPONENT PRIVILEGE CREATE_LIBRARY AS 'CL' ON SQL_OPERATIONS SYSTEM
GRANT COMPONENT PRIVILEGE "CREATE_LIBRARY" ON "SQL_OPERATIONS" TO
"DB__ROOTROLE" WITH GRANT OPTION;
+CREATE COMPONENT PRIVILEGE COMMENT AS 'CO' ON SQL_OPERATIONS SYSTEM DETAIL
+ 'Allow grantee to comment on objects and columns';
+
+-- GRANT COMPONENT PRIVILEGE "COMMENT" ON "SQL_OPERATIONS" TO "DB__ROOT" WITH GRANT OPTION;
+GRANT COMPONENT PRIVILEGE "COMMENT" ON "SQL_OPERATIONS" TO "DB__ROOTROLE" WITH
+ GRANT OPTION;
+
CREATE COMPONENT PRIVILEGE CREATE_PROCEDURE AS 'CP' ON SQL_OPERATIONS SYSTEM
DETAIL 'Allow grantee to create procedures';
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/sqlcomp/CmpDescribe.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpDescribe.cpp b/core/sql/sqlcomp/CmpDescribe.cpp
index bec4b58..af9503f 100644
--- a/core/sql/sqlcomp/CmpDescribe.cpp
+++ b/core/sql/sqlcomp/CmpDescribe.cpp
@@ -3049,6 +3049,8 @@ short CmpDescribeSeabaseTable (
return -1;
}
}
+
+ Int64 objectUID = (Int64) naTable->objectUid().get_value();
if ((type == 2) && (isView))
{
@@ -3059,6 +3061,36 @@ short CmpDescribeSeabaseTable (
outputLongLine(*space, viewtext, 0);
+ //display comment for VIEW
+ if (objectUID > 0/* && COMMENT_CQD*/)
+ {
+ if (cmpSBD.switchCompiler())
+ {
+ *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_PRIVS);
+ return -1;
+ }
+
+ ComTdbVirtObjCommentInfo * objCommentInfo = NULL;
+ cmpSBD.getSeabaseObjectComment(objectUID, COM_VIEW_OBJECT, objCommentInfo);
+
+ if (objCommentInfo != NULL)
+ {
+ //new line
+ outputLine(*space, "", 0);
+
+ //display VIEW COMMENT statements
+ if (objCommentInfo->objectComment != NULL)
+ {
+ sprintf(buf, "COMMENT ON VIEW %s IS '%s' ;",
+ tableName.data(),
+ objCommentInfo->objectComment);
+ outputLine(*space, buf, 0);
+ }
+ }
+
+ cmpSBD.switchBackCompiler();
+ }
+
// Display grant statements
if (CmpCommon::context()->isAuthorizationEnabled() && displayPrivilegeGrants)
{
@@ -3746,7 +3778,6 @@ short CmpDescribeSeabaseTable (
} // showddl
}
- Int64 objectUID = (Int64)naTable->objectUid().get_value();
if ((type == 2) &&
(naTable->isHbaseCellTable() || naTable->isHbaseRowTable()) &&
(NOT isView))
@@ -3763,7 +3794,7 @@ short CmpDescribeSeabaseTable (
if (naTable->isRegistered())
{
outputShortLine(*space, " ");
-
+
sprintf(buf, "REGISTER%sHBASE %s %s;",
(naTable->isInternalRegistered() ? " /*INTERNAL*/ " : " "),
"TABLE",
@@ -3777,6 +3808,65 @@ short CmpDescribeSeabaseTable (
}
}
+ //display comments
+ if (type == 2 && objectUID > 0)
+ {
+ enum ComObjectType objType = COM_BASE_TABLE_OBJECT;
+
+ if (isView)
+ {
+ objType = COM_VIEW_OBJECT;
+ }
+
+ if (cmpSBD.switchCompiler())
+ {
+ *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_PRIVS);
+ return -1;
+ }
+
+ ComTdbVirtObjCommentInfo * objCommentInfo = NULL;
+ cmpSBD.getSeabaseObjectComment(objectUID, objType, objCommentInfo);
+
+ if (objCommentInfo != NULL)
+ {
+ //new line
+ outputLine(*space, "", 0);
+
+ //display Table COMMENT statements
+ if (objCommentInfo->objectComment != NULL)
+ {
+ sprintf(buf, "COMMENT ON %s %s IS '%s' ;",
+ objType == COM_BASE_TABLE_OBJECT? "TABLE" : "VIEW",
+ tableName.data(),
+ objCommentInfo->objectComment);
+ outputLine(*space, buf, 0);
+ }
+
+ //display Column COMMENT statements
+ outputLine(*space, "", 0);
+ for (int idx = 0; idx < objCommentInfo->numColumnComment; idx++)
+ {
+ sprintf(buf, "COMMENT ON COLUMN %s.%s IS '%s' ;",
+ tableName.data(),
+ objCommentInfo->columnCommentArray[idx].columnName,
+ objCommentInfo->columnCommentArray[idx].columnComment);
+ outputLine(*space, buf, 0);
+ }
+
+ //display Index COMMENT statements
+ outputLine(*space, "", 0);
+ for (int idx = 0; idx < objCommentInfo->numIndexComment; idx++)
+ {
+ sprintf(buf, "COMMENT ON INDEX %s IS '%s' ;",
+ objCommentInfo->indexCommentArray[idx].indexFullName,
+ objCommentInfo->indexCommentArray[idx].indexComment);
+ outputLine(*space, buf, 0);
+ }
+ }
+
+ cmpSBD.switchBackCompiler();
+ }
+
// If SHOWDDL and authorization is enabled, display GRANTS
if (type == 2)
{
@@ -4129,6 +4219,33 @@ char buf[1000];
((CmpCommon::getDefault(SHOWDDL_DISPLAY_PRIVILEGE_GRANTS) == DF_SYSTEM)
&& getenv("SQLMX_REGRESS"))) ? FALSE : TRUE;
+//display library comment
+ if (libraryUID > 0)
+ {
+ if (cmpSBD.switchCompiler())
+ {
+ *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_PRIVS);
+ return -1;
+ }
+
+ ComTdbVirtObjCommentInfo * objCommentInfo = NULL;
+ cmpSBD.getSeabaseObjectComment(libraryUID, COM_LIBRARY_OBJECT, objCommentInfo);
+
+ if (objCommentInfo != NULL && objCommentInfo->objectComment != NULL)
+ {
+ //new line
+ outputLine(*space, "", 0);
+
+ sprintf(buf, "COMMENT ON LIBRARY %s IS '%s' ;",
+ cn.getQualifiedNameObj().getQualifiedNameAsAnsiString(TRUE).data(),
+ objCommentInfo->objectComment);
+ outputLine(*space, buf, 0);
+
+ }
+
+ cmpSBD.switchBackCompiler();
+ }
+
// If authorization is enabled, display grant statements for library
if (CmpCommon::context()->isAuthorizationEnabled() && displayPrivilegeGrants)
{
@@ -4181,7 +4298,7 @@ short CmpDescribeRoutine (const CorrName & cn,
{
BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
- NARoutine *routine = bindWA.getNARoutine(cn.getQualifiedNameObj());
+ NARoutine *routine = bindWA.getNARoutine(cn.getQualifiedNameObj());
const NAString& rName =
cn.getQualifiedNameObj().getQualifiedNameAsAnsiString(TRUE);
if (routine == NULL || bindWA.errStatus())
@@ -4634,12 +4751,44 @@ short CmpDescribeRoutine (const CorrName & cn,
outputShortLine (*space, " ;");
+ CmpSeabaseDDL cmpSBD((NAHeap*)heap);
+
char * sqlmxRegr = getenv("SQLMX_REGRESS");
NABoolean displayPrivilegeGrants = TRUE;
if (((CmpCommon::getDefault(SHOWDDL_DISPLAY_PRIVILEGE_GRANTS) == DF_SYSTEM) && sqlmxRegr) ||
(CmpCommon::getDefault(SHOWDDL_DISPLAY_PRIVILEGE_GRANTS) == DF_OFF))
displayPrivilegeGrants = FALSE;
+ //display comment of routine
+ Int64 routineUID = routine->getRoutineID();
+ if ( routineUID > 0)
+ {
+ if (cmpSBD.switchCompiler())
+ {
+ *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_PRIVS);
+ return -1;
+ }
+
+ ComTdbVirtObjCommentInfo * objCommentInfo = NULL;
+ cmpSBD.getSeabaseObjectComment(routineUID, COM_USER_DEFINED_ROUTINE_OBJECT, objCommentInfo);
+
+ if (objCommentInfo != NULL && objCommentInfo->objectComment != NULL)
+ {
+ //new line
+ outputLine(*space, "", 0);
+
+ sprintf(buf, "COMMENT ON %s %s IS '%s' ;",
+ routine->getRoutineType() == COM_PROCEDURE_TYPE ? "PROCEDURE" : "FUNCTION",
+ cn.getQualifiedNameObj().getQualifiedNameAsAnsiString(TRUE).data(),
+ objCommentInfo->objectComment);
+ outputLine(*space, buf, 0);
+ }
+
+ cmpSBD.switchBackCompiler();
+
+ }
+
+
// If authorization enabled, display grant statements
if (CmpCommon::context()->isAuthorizationEnabled() && displayPrivilegeGrants)
{
@@ -4661,8 +4810,6 @@ short CmpDescribeRoutine (const CorrName & cn,
(int32_t)routine->getSchemaOwner(),
COM_USER_DEFINED_ROUTINE_OBJECT);
-
- CmpSeabaseDDL cmpSBD((NAHeap*)heap);
if (cmpSBD.switchCompiler())
{
*CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_PRIVS);
@@ -4678,8 +4825,6 @@ short CmpDescribeRoutine (const CorrName & cn,
cmpSBD.switchBackCompiler();
}
-
-
outbuflen = space->getAllocatedSpaceSize();
outbuf = new (heap) char[outbuflen];
space->makeContiguous(outbuf, outbuflen);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/sqlcomp/CmpSeabaseDDL.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDL.h b/core/sql/sqlcomp/CmpSeabaseDDL.h
index 9da0b01..a31ef52 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDL.h
+++ b/core/sql/sqlcomp/CmpSeabaseDDL.h
@@ -253,6 +253,10 @@ class CmpSeabaseDDL
const ComObjectType objType,
NABoolean includeInvalidDefs = FALSE);
+ short getSeabaseObjectComment(Int64 object_uid,
+ enum ComObjectType object_type,
+ ComTdbVirtObjCommentInfo * & comment_info);
+
short getObjectOwner(ExeCliInterface *cliInterface,
const char * catName,
const char * schName,
@@ -1405,6 +1409,10 @@ protected:
void dropSeabaseAuthorization(ExeCliInterface *cliInterface,
NABoolean doCleanup = FALSE);
+ void doSeabaseCommentOn(StmtDDLCommentOn *commentOnNode,
+ NAString &currCatName,
+ NAString &currSchName);
+
NABoolean insertPrivMgrInfo(const Int64 objUID,
const NAString &objName,
const ComObjectType objectType,
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp
new file mode 100644
index 0000000..83fc83f
--- /dev/null
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp
@@ -0,0 +1,202 @@
+/**********************************************************************
+// @@@ 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 @@@
+**********************************************************************/
+
+/* -*-C++-*-
+ *****************************************************************************
+ *
+ * File: CmpSeabaseDDLcommentOn.cpp
+ * Description: Implements ddl operations for Seabase indexes.
+ *
+ *
+ * Created: 8/17/2017
+ * Language: C++
+ *
+ *
+ *****************************************************************************
+ */
+
+#define SQLPARSERGLOBALS_FLAGS // must precede all #include's
+#define SQLPARSERGLOBALS_NADEFAULTS
+
+#include "ComObjectName.h"
+
+#include "CmpDDLCatErrorCodes.h"
+#include "ElemDDLHbaseOptions.h"
+
+#include "SchemaDB.h"
+#include "CmpSeabaseDDL.h"
+#include "CmpDescribe.h"
+
+#include "ExpHbaseInterface.h"
+
+#include "ExExeUtilCli.h"
+#include "Generator.h"
+
+#include "ComCextdecs.h"
+#include "ComUser.h"
+
+#include "NumericType.h"
+
+#include "PrivMgrCommands.h"
+
+#include "StmtDDLCommentOn.h"
+
+#include "PrivMgrComponentPrivileges.h"
+#include "PrivMgrCommands.h"
+#include "ComUser.h"
+
+
+void CmpSeabaseDDL::doSeabaseCommentOn(StmtDDLCommentOn *commentOnNode,
+ NAString &currCatName,
+ NAString &currSchName)
+{
+ Lng32 cliRC;
+ Lng32 retcode;
+
+ enum ComObjectType enMDObjType = COM_UNKNOWN_OBJECT;
+
+ ComObjectName objectName(commentOnNode->getObjectName());
+ ComAnsiNamePart currCatAnsiName(currCatName);
+ ComAnsiNamePart currSchAnsiName(currSchName);
+ objectName.applyDefaults(currCatAnsiName, currSchAnsiName);
+
+ enum StmtDDLCommentOn::COMMENT_ON_TYPES commentObjectType = commentOnNode->getObjectType();
+
+ switch (commentObjectType)
+ {
+ case StmtDDLCommentOn::COMMENT_ON_TYPE_TABLE:
+ enMDObjType = COM_BASE_TABLE_OBJECT;
+ break;
+
+ case StmtDDLCommentOn::COMMENT_ON_TYPE_COLUMN:
+ enMDObjType = COM_BASE_TABLE_OBJECT;
+ break;
+
+ case StmtDDLCommentOn::COMMENT_ON_TYPE_INDEX:
+ enMDObjType = COM_INDEX_OBJECT;
+ break;
+
+ case StmtDDLCommentOn::COMMENT_ON_TYPE_SCHEMA:
+ enMDObjType = COM_PRIVATE_SCHEMA_OBJECT;
+ break;
+
+ case StmtDDLCommentOn::COMMENT_ON_TYPE_VIEW:
+ enMDObjType = COM_VIEW_OBJECT;
+ break;
+
+ case StmtDDLCommentOn::COMMENT_ON_TYPE_LIBRARY:
+ enMDObjType = COM_LIBRARY_OBJECT;
+ break;
+
+ case StmtDDLCommentOn::COMMENT_ON_TYPE_PROCEDURE:
+ case StmtDDLCommentOn::COMMENT_ON_TYPE_FUNCTION:
+ enMDObjType = COM_USER_DEFINED_ROUTINE_OBJECT;
+ break;
+
+ default:
+ break;
+
+ }
+
+ NAString catalogNamePart = objectName.getCatalogNamePartAsAnsiString();
+ NAString schemaNamePart = objectName.getSchemaNamePartAsAnsiString(TRUE);
+ NAString objNamePart = objectName.getObjectNamePartAsAnsiString(TRUE);
+
+ const NAString extObjName = objectName.getExternalName(TRUE);
+
+ ExeCliInterface cliInterface(STMTHEAP, NULL, NULL,
+ CmpCommon::context()->sqlSession()->getParentQid());
+ Int64 objUID = 0;
+ Int32 objectOwnerID = SUPER_USER;
+ Int32 schemaOwnerID = SUPER_USER;
+ Int64 objectFlags = 0;
+
+ // Verify that the requester has COMMENT privilege.
+ if (isAuthorizationEnabled() && !ComUser::isRootUserID())
+ {
+ NAString privMgrMDLoc;
+ CONCAT_CATSCH(privMgrMDLoc, getSystemCatalog(), SEABASE_PRIVMGR_SCHEMA);
+
+ PrivMgrComponentPrivileges componentPrivileges(std::string(privMgrMDLoc.data()), CmpCommon::diags());
+
+ if (!componentPrivileges.hasSQLPriv(ComUser::getCurrentUser(), SQLOperation::COMMENT, true))
+ {
+ *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED);
+ processReturn ();
+ return;
+ }
+ }
+
+ //get UID of object
+ objUID = getObjectInfo(&cliInterface,
+ catalogNamePart.data(), schemaNamePart.data(), objNamePart.data(),
+ enMDObjType,
+ objectOwnerID,
+ schemaOwnerID,
+ objectFlags);
+ if (objUID < 0 || objectOwnerID == 0 || schemaOwnerID == 0)
+ {
+ CmpCommon::diags()->clear();
+ *CmpCommon::diags() << DgSqlCode(-1389)
+ << DgString0(extObjName);
+ processReturn();
+ return;
+ }
+
+ // add, remove, change comment of object/column
+ const NAString & comment = commentOnNode->getComment();
+ char * query = new(STMTHEAP) char[comment.length()+1024];
+
+ if (StmtDDLCommentOn::COMMENT_ON_TYPE_COLUMN == commentObjectType)
+ {
+ str_sprintf(query, "update %s.\"%s\".%s set comment = '%s' where object_uid = %ld and column_name = '%s' ",
+ getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_COLUMNS,
+ comment.data(),
+ objUID,
+ commentOnNode->getColName().data()
+ );
+ cliRC = cliInterface.executeImmediate(query);
+ }
+ else
+ {
+ str_sprintf(query, "update %s.\"%s\".%s set comment = '%s' where catalog_name = '%s' and schema_name = '%s' and object_name = '%s' and object_type = '%s' ",
+ getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
+ comment.data(),
+ catalogNamePart.data(), schemaNamePart.data(), objNamePart.data(),
+ comObjectTypeLit(enMDObjType));
+ cliRC = cliInterface.executeImmediate(query);
+ }
+
+
+ NADELETEBASIC(query, STMTHEAP);
+ if (cliRC < 0)
+ {
+ cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
+ processReturn();
+ return;
+ }
+
+ processReturn();
+ return;
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
index cc1e4a5..c23a180 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
@@ -4563,7 +4563,7 @@ short CmpSeabaseDDL::updateSeabaseMDObjectsTable(
NAString quotedObjName;
ToQuotedString(quotedObjName, NAString(objName), FALSE);
- str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, %ld )",
+ str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, %ld, '')",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
catName, quotedSchName.data(), quotedObjName.data(),
objectTypeLit,
@@ -4754,7 +4754,7 @@ short CmpSeabaseDDL::updateSeabaseMDTable(
ExeCliInterface cqdCliInterface;
cliRC = cqdCliInterface.holdAndSetCQD("ODBC_PROCESS", "ON");
- str_sprintf(buf, "upsert using rowset (max rowset size %d, input rowset size ?, input row max length ?, rowset buffer ?) into %s.\"%s\".%s values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ str_sprintf(buf, "upsert using rowset (max rowset size %d, input rowset size ?, input row max length ?, rowset buffer ?) into %s.\"%s\".%s values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
numCols,
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_COLUMNS);
cliRC = rwrsCliInterface.rwrsPrepare(buf, numCols);
@@ -4887,6 +4887,7 @@ short CmpSeabaseDDL::updateSeabaseMDTable(
AssignColEntry(&rwrsCliInterface, entry++, inputRow, colInfo->paramDirection, firstColOffset);
AssignColEntry(&rwrsCliInterface, entry++, inputRow, (colInfo->isOptional ? COM_YES_LIT : COM_NO_LIT), firstColOffset);
AssignColEntry(&rwrsCliInterface, entry++, inputRow, (char*)&colInfo->colFlags, firstColOffset);
+ AssignColEntry(&rwrsCliInterface, entry++, inputRow, (char*)"", firstColOffset);
cliRC = rwrsCliInterface.rwrsExec(inputRow, inputRowLen, &rowsAffected);
if (cliRC < 0)
@@ -4898,7 +4899,7 @@ short CmpSeabaseDDL::updateSeabaseMDTable(
}
else
{
- str_sprintf(buf, "insert into %s.\"%s\".%s values (%ld, '%s', %d, '%s', %d, '%s', %d, %d, %d, %d, %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', %ld)",
+ str_sprintf(buf, "insert into %s.\"%s\".%s values (%ld, '%s', %d, '%s', %d, '%s', %d, %d, %d, %d, %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', %ld, '')",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_COLUMNS,
objUID,
colInfo->colName,
@@ -5121,7 +5122,7 @@ short CmpSeabaseDDL::updateSeabaseMDSPJ(
NAString quotedLibObjName;
ToQuotedString(quotedLibObjName, NAString(libName), FALSE);
- str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, 0 )",
+ str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, 0, '')",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
catName, quotedSchName.data(), quotedLibObjName.data(),
COM_LIBRARY_OBJECT_LIT,
@@ -7783,7 +7784,7 @@ void CmpSeabaseDDL::createSeabaseSequence(StmtDDLCreateSequence * createSequen
ToQuotedString(quotedSeqObjName, seqNamePart, FALSE);
Int32 objOwner = ComUser::getCurrentUser();
- str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, 0)",
+ str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, 0, '')",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
catalogNamePart.data(), quotedSchName.data(), quotedSeqObjName.data(),
COM_SEQUENCE_GENERATOR_OBJECT_LIT,
@@ -9506,6 +9507,13 @@ short CmpSeabaseDDL::executeSeabaseDDL(DDLExpr * ddlExpr, ExprNode * ddlNode,
cmpSBDC.cleanupObjects(co, currCatName, currSchName, dws);
}
+ else if (ddlNode->getOperatorType() == DDL_COMMENT_ON)
+ {
+ StmtDDLCommentOn * comment =
+ ddlNode->castToStmtDDLNode()->castToStmtDDLCommentOn();
+
+ doSeabaseCommentOn(comment, currCatName, currSchName);
+ }
else
{
// some operator type that this routine doesn't support yet
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/sqlcomp/CmpSeabaseDDLincludes.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLincludes.h b/core/sql/sqlcomp/CmpSeabaseDDLincludes.h
index 3b7b47a..9cbae54 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLincludes.h
+++ b/core/sql/sqlcomp/CmpSeabaseDDLincludes.h
@@ -69,6 +69,7 @@
#include "StmtDDLRegisterComponent.h"
#include "StmtDDLCleanupObjects.h"
#include "StmtDDLRegOrUnregHive.h"
+#include "StmtDDLCommentOn.h"
#include "ElemDDLHbaseOptions.h"
#include "ElemDDLParamDefArray.h"
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/sqlcomp/CmpSeabaseDDLmd.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLmd.h b/core/sql/sqlcomp/CmpSeabaseDDLmd.h
index 76383b6..fdaa99b 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLmd.h
+++ b/core/sql/sqlcomp/CmpSeabaseDDLmd.h
@@ -115,7 +115,8 @@ static const QString seabaseColumnsDDL[] =
{" hbase_col_qualifier varchar(40) character set iso88591 not null not serialized, "},
{" direction char(2) character set iso88591 not null not serialized, "},
{" is_optional char(2) character set iso88591 not null not serialized, "},
- {" flags largeint not null not serialized "},
+ {" flags largeint not null not serialized, "},
+ {" comment VARCHAR(1000) CHARACTER SET UTF8 NOT NULL NOT SERIALIZED "},
{" ) "},
{" primary key (object_uid, column_name) "},
{" attribute hbase format "},
@@ -220,7 +221,8 @@ static const QString seabaseObjectsDDL[] =
{" droppable char(2) character set iso88591 not null not serialized, "},
{" object_owner int not null not serialized, "},
{" schema_owner int not null not serialized, "},
- {" flags largeint not null not serialized "},
+ {" flags largeint not null not serialized, "},
+ {" comment VARCHAR(1000) CHARACTER SET UTF8 NOT NULL NOT SERIALIZED "},
{" ) "},
{" primary key (catalog_name, schema_name, object_name, object_type) "},
{" attribute hbase format "},
@@ -1544,6 +1546,9 @@ static const QString seabaseOldMDv11ViewsDDL[] =
#define TRAF_SEQUENCES_VIEW "SEQUENCES_VIEW"
#define TRAF_TABLES_VIEW "TABLES_VIEW"
#define TRAF_VIEWS_VIEW "VIEWS_VIEW"
+#define TRAF_OBJECT_COMMENT_VIEW "OBJECT_COMMENT_VIEW"
+#define TRAF_COLUMN_COMMENT_VIEW "COLUMN_COMMENT_VIEW"
+
static const QString createTrafColumnsViewQuery[] =
{
@@ -1693,6 +1698,24 @@ static const QString createTrafViewsViewQuery[] =
{" ; "}
};
+static const QString createTrafObjectCommentViewQuery[] =
+{
+ {" create view %s.\"%s\"."TRAF_OBJECT_COMMENT_VIEW" as "},
+ {" select catalog_name, schema_name, object_name, comment "},
+ {" from %s.\"%s\".\"%s\" "},
+ {" where COMMENT <> '' "},
+ {" ; "}
+};
+
+static const QString createTrafColumnCommentViewQuery[] =
+{
+ {" create view %s.\"%s\"."TRAF_COLUMN_COMMENT_VIEW" as "},
+ {" select O.CATALOG_NAME, O.SCHEMA_NAME, O.OBJECT_NAME, C.COLUMN_NAME, C.COMMENT "},
+ {" from %s.\"%s\".\"%s\" as O, %s.\"%s\".\"%s\" as C "},
+ {" where O.OBJECT_UID = C.OBJECT_UID and C.COMMENT <> '' "},
+ {" ; "}
+};
+
struct MDViewInfo
{
const char * viewName;
@@ -1747,7 +1770,18 @@ static const MDViewInfo allMDviewsInfo[] = {
sizeof(createTrafViewsViewQuery),
FALSE
},
-
+ {
+ TRAF_OBJECT_COMMENT_VIEW,
+ createTrafObjectCommentViewQuery,
+ sizeof(createTrafObjectCommentViewQuery),
+ FALSE
+ },
+ {
+ TRAF_COLUMN_COMMENT_VIEW,
+ createTrafColumnCommentViewQuery,
+ sizeof(createTrafColumnCommentViewQuery),
+ FALSE
+ },
};
#endif
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
index a39ad0b..dd35222 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
@@ -187,8 +187,8 @@ char schemaObjectLit[3] = {0};
break;
}
}
-
- str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, 0)",
+
+ str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, 0, '')",
getSystemCatalog(),SEABASE_MD_SCHEMA,SEABASE_OBJECTS,
catalogName.data(), quotedSchName.data(), quotedObjName.data(),
schemaObjectLit,
@@ -445,7 +445,29 @@ Int16 status = ComUser::getAuthNameFromAuthID(objectOwner,username,
output += catalogName.data();
output += "\".\"";
output += schemaName.data();
-
+// Disaply Comment of schema
+ {
+ ComTdbVirtObjCommentInfo * objCommentInfo = NULL;
+ cmpSBD.getSeabaseObjectComment(schemaUID, objectType, objCommentInfo);
+
+ if (objCommentInfo != NULL && objCommentInfo->objectComment != NULL)
+ {
+ outlines.push_back(" ");
+
+ output = "COMMENT ON SCHEMA ";
+ output += catalogName.data();
+ output += ".";
+ output += schemaName.data();
+ output += " IS '";
+ output += objCommentInfo->objectComment;
+ output += "' ;";
+
+ outlines.push_back(output.data());
+
+ }
+
+ }
+
// AUTHORIZATION clause is rarely used, but include it for replay.
output += "\" AUTHORIZATION \"";
output += username;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
index bc33864..4924c14 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
@@ -909,7 +909,7 @@ short CmpSeabaseDDL::updatePKeyInfo(
NAString quotedObjName;
ToQuotedString(quotedObjName, NAString(objectNamePart), FALSE);
- str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, 0 )",
+ str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, 0, '')",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
catalogNamePart.data(), quotedSchName.data(), quotedObjName.data(),
COM_PRIMARY_KEY_CONSTRAINT_OBJECT_LIT,
@@ -1315,7 +1315,7 @@ short CmpSeabaseDDL::updateConstraintMD(
NAString quotedObjName;
ToQuotedString(quotedObjName, NAString(objectNamePart), FALSE);
- str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, 0 )",
+ str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, 0, '')",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
catalogNamePart.data(), quotedSchName.data(), quotedObjName.data(),
((ct == COM_UNIQUE_CONSTRAINT) ? COM_UNIQUE_CONSTRAINT_OBJECT_LIT :
@@ -5646,7 +5646,7 @@ void CmpSeabaseDDL::alterSeabaseTableAddColumn(
}
}
- str_sprintf(query, "insert into %s.\"%s\".%s values (%ld, '%s', %d, '%s', %d, '%s', %d, %d, %d, %d, %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%u', '%s', '%s', %ld )",
+ str_sprintf(query, "insert into %s.\"%s\".%s values (%ld, '%s', %d, '%s', %d, '%s', %d, %d, %d, %d, %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%u', '%s', '%s', %ld, '' )",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_COLUMNS,
objUID,
col_name,
@@ -7171,8 +7171,8 @@ short CmpSeabaseDDL::hbaseFormatTableAlterColumnAttr(
cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
goto label_error1;
}
-
- str_sprintf(buf, "insert into %s.\"%s\".%s select object_uid, '%s', %d, '%s', fs_data_type, sql_data_type, column_size, column_precision, column_scale, datetime_start_field, datetime_end_field, is_upshifted, column_flags, nullable, character_set, default_class, default_value, column_heading, '%s', '%s', direction, is_optional, flags from %s.\"%s\".%s where object_uid = %ld and column_number = (select column_number from %s.\"%s\".%s where object_uid = %ld and column_name = '%s')",
+
+ str_sprintf(buf, "insert into %s.\"%s\".%s select object_uid, '%s', %d, '%s', fs_data_type, sql_data_type, column_size, column_precision, column_scale, datetime_start_field, datetime_end_field, is_upshifted, column_flags, nullable, character_set, default_class, default_value, column_heading, '%s', '%s', direction, is_optional, flags, comment from %s.\"%s\".%s where object_uid = %ld and column_number = (select column_number from %s.\"%s\".%s where object_uid = %ld and column_name = '%s')",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_COLUMNS,
naCol->getColName().data(),
altColNum,
@@ -12940,6 +12940,142 @@ TrafDesc *CmpSeabaseDDL::getSeabaseRoutineDescInternal(const NAString &catName,
}
+short CmpSeabaseDDL::getSeabaseObjectComment(Int64 object_uid,
+ enum ComObjectType object_type,
+ ComTdbVirtObjCommentInfo * & comment_info)
+{
+ Lng32 retcode = 0;
+ Lng32 cliRC = 0;
+
+ char query[4000];
+
+ comment_info = NULL;
+
+
+ ExeCliInterface cliInterface(STMTHEAP,
+ NULL, NULL,
+ CmpCommon::context()->sqlSession()->getParentQid());
+
+ //get object comment
+ str_sprintf(query, "select comment from %s.\"%s\".%s where object_uid = %ld and object_type = '%s' and comment <> '' ;",
+ getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
+ object_uid, comObjectTypeLit(object_type));
+
+ Queue * objQueue = NULL;
+ cliRC = cliInterface.fetchAllRows(objQueue, query, 0, FALSE, FALSE, TRUE);
+ if (cliRC < 0)
+ {
+ cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
+ processReturn();
+ return -1;
+ }
+
+ if (objQueue->numEntries() == 1)
+ {
+ objQueue->position();
+
+ OutputInfo * vi = (OutputInfo*)objQueue->getNext();
+
+ comment_info = new(STMTHEAP) ComTdbVirtObjCommentInfo[1];
+ comment_info->objectUid = object_uid;
+ comment_info->numColumnComment = 0;
+ comment_info->columnCommentArray = NULL;
+ comment_info->numIndexComment = 0;
+ comment_info->indexCommentArray = NULL;
+ comment_info->objectComment = (char*)vi->get(0);
+ }
+ else
+ {
+ return -1;
+ }
+
+ if (COM_BASE_TABLE_OBJECT == object_type)
+ {
+ //get index comment of table
+ str_sprintf(query, "select CATALOG_NAME||'.'||SCHEMA_NAME||'.'||OBJECT_NAME, COMMENT "
+ "from %s.\"%s\".%s as O, %s.\"%s\".%s as I "
+ "where I.BASE_TABLE_UID = %ld and O.OBJECT_UID = I.INDEX_UID and O.comment <> '' ;",
+ getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
+ getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_INDEXES,
+ object_uid);
+
+ Queue * indexQueue = NULL;
+ cliRC = cliInterface.fetchAllRows(indexQueue, query, 0, FALSE, FALSE, TRUE);
+ if (cliRC < 0)
+ {
+ cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
+ processReturn();
+ return -1;
+ }
+
+ if (indexQueue->numEntries() > 0)
+ {
+ if (NULL == comment_info)
+ {
+ comment_info = new(STMTHEAP) ComTdbVirtObjCommentInfo[1];
+ comment_info->objectUid = object_uid;
+ comment_info->objectComment = NULL;
+ comment_info->numColumnComment = 0;
+ comment_info->columnCommentArray = NULL;
+ }
+
+ comment_info->numIndexComment = indexQueue->numEntries();
+ comment_info->indexCommentArray = new(STMTHEAP) ComTdbVirtIndexCommentInfo[comment_info->numIndexComment];
+
+ indexQueue->position();
+ for (Lng32 idx = 0; idx < comment_info->numIndexComment; idx++)
+ {
+ OutputInfo * oi = (OutputInfo*)indexQueue->getNext();
+ ComTdbVirtIndexCommentInfo &indexComment = comment_info->indexCommentArray[idx];
+
+ // get the index full name
+ indexComment.indexFullName = (char*) oi->get(0);
+ indexComment.indexComment = (char*) oi->get(1);
+ }
+ }
+
+ //get column comment of table
+ str_sprintf(query, "select COLUMN_NAME, COMMENT from %s.\"%s\".%s where OBJECT_UID = %ld and comment <> '' order by COLUMN_NUMBER ;",
+ getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_COLUMNS, object_uid);
+
+ Queue * colQueue = NULL;
+ cliRC = cliInterface.fetchAllRows(colQueue, query, 0, FALSE, FALSE, TRUE);
+ if (cliRC < 0)
+ {
+ cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
+ processReturn();
+ return -1;
+ }
+
+ if (colQueue->numEntries() > 0)
+ {
+ if (NULL == comment_info)
+ {
+ comment_info = new(STMTHEAP) ComTdbVirtObjCommentInfo[1];
+ comment_info->objectUid = object_uid;
+ comment_info->objectComment = NULL;
+ comment_info->numIndexComment = 0;
+ comment_info->indexCommentArray = NULL;
+ }
+
+ comment_info->numColumnComment = colQueue->numEntries();
+ comment_info->columnCommentArray = new(STMTHEAP) ComTdbVirtColumnCommentInfo[comment_info->numColumnComment];
+
+ colQueue->position();
+ for (Lng32 idx = 0; idx < comment_info->numColumnComment; idx++)
+ {
+ OutputInfo * oi = (OutputInfo*)colQueue->getNext();
+ ComTdbVirtColumnCommentInfo &colComment = comment_info->columnCommentArray[idx];
+
+ // get the column name
+ colComment.columnName = (char*) oi->get(0);
+ colComment.columnComment = (char*) oi->get(1);
+ }
+ }
+ }
+
+ return 0;
+}
// *****************************************************************************
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/sqlcomp/CmpSeabaseDDLupgrade.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLupgrade.h b/core/sql/sqlcomp/CmpSeabaseDDLupgrade.h
index 549b506..7e963e0 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLupgrade.h
+++ b/core/sql/sqlcomp/CmpSeabaseDDLupgrade.h
@@ -226,7 +226,14 @@ static const MDUpgradeInfo allMDupgradeInfo[] = {
seabaseColumnsDDL, sizeof(seabaseColumnsDDL),
NULL, 0,
NULL, 0,
- FALSE, NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
+ TRUE,
+ "object_uid,column_name,column_number,column_class,fs_data_type,sql_data_type,column_size,column_precision,"
+ "column_scale,datetime_start_field,datetime_end_field,is_upshifted,column_flags,nullable,character_set,"
+ "default_class,default_value,column_heading,hbase_col_family,hbase_col_qualifier,direction,is_optional,flags,comment" ,
+ "object_uid,column_name,column_number,column_class,fs_data_type,sql_data_type,column_size,column_precision,"
+ "column_scale,datetime_start_field,datetime_end_field,is_upshifted,column_flags,nullable,character_set,"
+ "default_class,default_value,column_heading,hbase_col_family,hbase_col_qualifier,direction,is_optional,flags,''" ,
+ NULL, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE},
{SEABASE_DEFAULTS, SEABASE_DEFAULTS_OLD_MD,
seabaseDefaultsDDL, sizeof(seabaseDefaultsDDL),
@@ -279,13 +286,13 @@ static const MDUpgradeInfo allMDupgradeInfo[] = {
"object_name,"
"object_type,object_uid,"
"create_time,redef_time,valid_def,droppable,object_owner,schema_owner,"
- "flags",
+ "flags,comment",
"catalog_name,schema_name,"
"case when schema_name = '_MD_' then object_name || '_OLD_MD' else object_name end,"
"object_type,object_uid,"
"create_time,redef_time,valid_def,droppable,object_owner,schema_owner,"
- "flags",
- NULL, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
+ "flags,''",
+ NULL, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE},
{SEABASE_OBJECTS_UNIQ_IDX, SEABASE_OBJECTS_UNIQ_IDX_OLD_MD,
seabaseObjectsUniqIdxDDL, sizeof(seabaseObjectsUniqIdxDDL),
@@ -403,8 +410,8 @@ static const MDUpgradeInfo allMDv23tov30TablesInfo[] = {
seabaseOldMDv23ColumnsDDL, sizeof(seabaseOldMDv23ColumnsDDL),
NULL, 0,
TRUE,
- "object_uid, column_name, column_number, column_class, fs_data_type, sql_data_type, column_size, column_precision, column_scale, datetime_start_field, datetime_end_field, is_upshifted, column_flags, nullable, character_set, default_class, default_value, column_heading, hbase_col_family, hbase_col_qualifier, direction, is_optional, flags",
- "object_uid, column_name, column_number, column_class, fs_data_type, '', column_size, column_precision, column_scale, datetime_start_field, datetime_end_field, is_upshifted, column_flags, nullable, character_set, default_class, default_value, column_heading, hbase_col_family, hbase_col_qualifier, direction, is_optional, 0",
+ "object_uid, column_name, column_number, column_class, fs_data_type, sql_data_type, column_size, column_precision, column_scale, datetime_start_field, datetime_end_field, is_upshifted, column_flags, nullable, character_set, default_class, default_value, column_heading, hbase_col_family, hbase_col_qualifier, direction, is_optional, flags, comment",
+ "object_uid, column_name, column_number, column_class, fs_data_type, '', column_size, column_precision, column_scale, datetime_start_field, datetime_end_field, is_upshifted, column_flags, nullable, character_set, default_class, default_value, column_heading, hbase_col_family, hbase_col_qualifier, direction, is_optional, 0, '' ",
NULL, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE},
{SEABASE_DEFAULTS, SEABASE_DEFAULTS_OLD_MD,
@@ -448,8 +455,8 @@ static const MDUpgradeInfo allMDv23tov30TablesInfo[] = {
seabaseOldMDv23ObjectsDDL, sizeof(seabaseOldMDv23ObjectsDDL),
NULL, 0,
TRUE,
- "catalog_name, schema_name, object_name, object_type, object_uid, create_time, redef_time, valid_def, droppable, object_owner, schema_owner, flags",
- "catalog_name, schema_name, case when schema_name = '_MD_' then object_name || '_OLD_MD' else object_name end, object_type, object_uid, create_time, redef_time, valid_def, 'N', object_owner, " SUPER_USER_LIT", 0 ",
+ "catalog_name, schema_name, object_name, object_type, object_uid, create_time, redef_time, valid_def, droppable, object_owner, schema_owner, flags, comment",
+ "catalog_name, schema_name, case when schema_name = '_MD_' then object_name || '_OLD_MD' else object_name end, object_type, object_uid, create_time, redef_time, valid_def, 'N', object_owner, " SUPER_USER_LIT", 0, ''",
NULL, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE},
{SEABASE_OBJECTS_UNIQ_IDX, SEABASE_OBJECTS_UNIQ_IDX_OLD_MD,
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLview.cpp b/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
index 0f2592e..587c666 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
@@ -1492,6 +1492,25 @@ short CmpSeabaseDDL::createMetadataViews(ExeCliInterface * cliInterface)
param_[9] = SEABASE_MD_SCHEMA;
param_[10] = COM_VIEW_OBJECT_LIT;
}
+ else if (strcmp(mdi.viewName, TRAF_OBJECT_COMMENT_VIEW) == 0)
+ {
+ param_[0] = getSystemCatalog();
+ param_[1] = SEABASE_MD_SCHEMA;
+ param_[2] = getSystemCatalog();
+ param_[3] = SEABASE_MD_SCHEMA;
+ param_[4] = SEABASE_OBJECTS;
+ }
+ else if (strcmp(mdi.viewName, TRAF_COLUMN_COMMENT_VIEW) == 0)
+ {
+ param_[0] = getSystemCatalog();
+ param_[1] = SEABASE_MD_SCHEMA;
+ param_[2] = getSystemCatalog();
+ param_[3] = SEABASE_MD_SCHEMA;
+ param_[4] = SEABASE_OBJECTS;
+ param_[5] = getSystemCatalog();
+ param_[6] = SEABASE_MD_SCHEMA;
+ param_[7] = SEABASE_COLUMNS;
+ }
else
{
NADELETEBASICARRAY(gluedQuery, STMTHEAP);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/sqlcomp/PrivMgr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/PrivMgr.cpp b/core/sql/sqlcomp/PrivMgr.cpp
index 61e1dad..f9811c0 100644
--- a/core/sql/sqlcomp/PrivMgr.cpp
+++ b/core/sql/sqlcomp/PrivMgr.cpp
@@ -387,6 +387,7 @@ const char * PrivMgr::getSQLOperationName(SQLOperation operation)
case SQLOperation::SHOW: return "SHOW";
case SQLOperation::UNREGISTER_HIVE_OBJECT: return "UNREGISTER_HIVE_OBJECT";
case SQLOperation::USE_ALTERNATE_SCHEMA: return "USE_ALTERNATE_SCHEMA";
+ case SQLOperation::COMMENT: return "COMMENT";
default:
return "UNKNOWN";
}
@@ -482,6 +483,7 @@ const char * PrivMgr::getSQLOperationCode(SQLOperation operation)
case SQLOperation::SHOW: return "SW";
case SQLOperation::UNREGISTER_HIVE_OBJECT: return "UH";
case SQLOperation::USE_ALTERNATE_SCHEMA: return "UA";
+ case SQLOperation::COMMENT: return "CO";
default:
return " ";
}
@@ -580,6 +582,7 @@ const char * PrivMgr::getSQLOperationDescription(SQLOperation operation)
case SQLOperation::SHOW: return "Allow grantee to view metadata information about objects";
case SQLOperation::UNREGISTER_HIVE_OBJECT: return "Allow grantee to unregister hive object from traf metadata";
case SQLOperation::USE_ALTERNATE_SCHEMA: return "Allow grantee to use non-default schemas";
+ case SQLOperation::COMMENT: return "Allow grantee to comment on objects and columns";
default:
return "";
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/078ed10c/core/sql/sqlcomp/PrivMgrDefs.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/PrivMgrDefs.h b/core/sql/sqlcomp/PrivMgrDefs.h
index 0c615c2..5820460 100644
--- a/core/sql/sqlcomp/PrivMgrDefs.h
+++ b/core/sql/sqlcomp/PrivMgrDefs.h
@@ -217,8 +217,9 @@ enum class SQLOperation {
SHOW,
UNREGISTER_HIVE_OBJECT,
USE_ALTERNATE_SCHEMA,
+ COMMENT,
FIRST_OPERATION = ALTER,
- LAST_OPERATION = USE_ALTERNATE_SCHEMA,
+ LAST_OPERATION = COMMENT,
NUMBER_OF_OPERATIONS = LAST_OPERATION - FIRST_OPERATION + 1,
UNKNOWN,
FIRST_DML_PRIV = DML_DELETE,
[02/11] incubator-trafodion git commit: new COMMENT-ON SQL statement:
fix showddl schema error
Posted by db...@apache.org.
new COMMENT-ON SQL statement: fix showddl schema error
1. fix error while showddl schema with comment
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/69c284c6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/69c284c6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/69c284c6
Branch: refs/heads/master
Commit: 69c284c607fe965623ed16342df73f96200d38f5
Parents: 078ed10
Author: eedy <cq...@gmail.com>
Authored: Thu Nov 2 18:02:41 2017 +0800
Committer: eedy <cq...@gmail.com>
Committed: Thu Nov 2 18:02:41 2017 +0800
----------------------------------------------------------------------
core/sql/sqlcomp/CmpSeabaseDDLschema.cpp | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/69c284c6/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
index dd35222..3cc4c93 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
@@ -445,7 +445,15 @@ Int16 status = ComUser::getAuthNameFromAuthID(objectOwner,username,
output += catalogName.data();
output += "\".\"";
output += schemaName.data();
-// Disaply Comment of schema
+
+// AUTHORIZATION clause is rarely used, but include it for replay.
+ output += "\" AUTHORIZATION \"";
+ output += username;
+ output += "\";";
+
+ outlines.push_back(output.data());
+
+ // Disaply Comment of schema
{
ComTdbVirtObjCommentInfo * objCommentInfo = NULL;
cmpSBD.getSeabaseObjectComment(schemaUID, objectType, objCommentInfo);
@@ -468,13 +476,6 @@ Int16 status = ComUser::getAuthNameFromAuthID(objectOwner,username,
}
-// AUTHORIZATION clause is rarely used, but include it for replay.
- output += "\" AUTHORIZATION \"";
- output += username;
- output += "\";";
-
- outlines.push_back(output.data());
-
cmpSBD.switchBackCompiler();
return true;
[06/11] incubator-trafodion git commit: new COMMENT-ON SQL statement:
review change
Posted by db...@apache.org.
new COMMENT-ON SQL statement: review change
1. handle return value of function getSeabaseObjectComment
2. add a new error code : 1033 - CAT_UNABLE_TO_RETRIEVE_COMMENTS
3. add showddl support for sequence comment
4. moved function getSeabaseObjectComment to file
CmpSeabaseDDLcommentOn.cpp
5. changed str_sprintf to sprintf
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/0b7e3a35
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/0b7e3a35
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/0b7e3a35
Branch: refs/heads/master
Commit: 0b7e3a35bf61c1e28192272c1f7a961f95766a92
Parents: 4bdd4b8
Author: eedy <cq...@gmail.com>
Authored: Mon Nov 6 18:08:33 2017 +0800
Committer: eedy <cq...@gmail.com>
Committed: Mon Nov 6 18:08:33 2017 +0800
----------------------------------------------------------------------
core/sql/bin/SqlciErrors.txt | 2 +-
core/sql/sqlcomp/CmpDDLCatErrorCodes.h | 2 +-
core/sql/sqlcomp/CmpDescribe.cpp | 80 +++++++++++----
core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp | 120 ++++++++++++++++++++++-
core/sql/sqlcomp/CmpSeabaseDDLschema.cpp | 6 +-
core/sql/sqlcomp/CmpSeabaseDDLtable.cpp | 116 ----------------------
6 files changed, 185 insertions(+), 141 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/0b7e3a35/core/sql/bin/SqlciErrors.txt
----------------------------------------------------------------------
diff --git a/core/sql/bin/SqlciErrors.txt b/core/sql/bin/SqlciErrors.txt
index 8fdd3dc..85bc129 100644
--- a/core/sql/bin/SqlciErrors.txt
+++ b/core/sql/bin/SqlciErrors.txt
@@ -32,7 +32,7 @@
1030 ZZZZZ 99999 BEGINNER MINOR DBADMIN The HBase name has a length of $0~Int0 which is too long. Maximum length supported is $1~Int1.
1031 ZZZZZ 99999 BEGINNER MINOR DBADMIN Object $0~TableName could not be dropped.
1032 ZZZZZ 99999 BEGINNER MINOR DBADMIN The DISPLAY command completes and the query is not executed.
-1033 ZZZZZ 99999 BEGINNER MINOR DBADMIN --- unused ---
+1033 ZZZZZ 99999 BEGINNER MINOR DBADMIN Unable to obtain comments.
1034 ZZZZZ 99999 BEGINNER MAJOR DIALOUT Unable to obtain privileges.
1035 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Catalog $0~CatalogName already exists.
1036 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Authorization ID $0~String0 cannot grant to authorization ID $1~String1 because it could create a circular dependency.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/0b7e3a35/core/sql/sqlcomp/CmpDDLCatErrorCodes.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpDDLCatErrorCodes.h b/core/sql/sqlcomp/CmpDDLCatErrorCodes.h
index 2a3dab0..52eca31 100644
--- a/core/sql/sqlcomp/CmpDDLCatErrorCodes.h
+++ b/core/sql/sqlcomp/CmpDDLCatErrorCodes.h
@@ -64,7 +64,7 @@ enum CatErrorCode { CAT_FIRST_ERROR = 1000
, CAT_UNABLE_TO_CREATE_OBJECT = 1029
, CAT_HBASE_NAME_TOO_LONG = 1030
, CAT_UNABLE_TO_DROP_OBJECT = 1031
- // unused = 1033
+ , CAT_UNABLE_TO_RETRIEVE_COMMENTS = 1033
, CAT_UNABLE_TO_RETRIEVE_PRIVS = 1034
, CAT_CATALOG_ALREADY_EXISTS = 1035
, CAT_CIRCULAR_PRIVS = 1036
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/0b7e3a35/core/sql/sqlcomp/CmpDescribe.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpDescribe.cpp b/core/sql/sqlcomp/CmpDescribe.cpp
index 2d9c9da..b4b1d4e 100644
--- a/core/sql/sqlcomp/CmpDescribe.cpp
+++ b/core/sql/sqlcomp/CmpDescribe.cpp
@@ -3066,12 +3066,16 @@ short CmpDescribeSeabaseTable (
{
if (cmpSBD.switchCompiler())
{
- *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_PRIVS);
+ *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
return -1;
}
ComTdbVirtObjCommentInfo objCommentInfo;
- cmpSBD.getSeabaseObjectComment(objectUID, COM_VIEW_OBJECT, objCommentInfo, heap);
+ if (cmpSBD.getSeabaseObjectComment(objectUID, COM_VIEW_OBJECT, objCommentInfo, heap))
+ {
+ *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+ return -1;
+ }
//display VIEW COMMENT statements
if (objCommentInfo.objectComment != NULL)
@@ -3100,10 +3104,7 @@ short CmpDescribeSeabaseTable (
}
//do a comment info memory clean
- if (objCommentInfo.columnCommentArray != NULL)
- {
- NADELETEBASIC(objCommentInfo.columnCommentArray, heap);
- }
+ NADELETEARRAY(objCommentInfo.columnCommentArray, objCommentInfo.numColumnComment, ComTdbVirtColumnCommentInfo, heap);
cmpSBD.switchBackCompiler();
}
@@ -3837,12 +3838,16 @@ short CmpDescribeSeabaseTable (
if (cmpSBD.switchCompiler())
{
- *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_PRIVS);
+ *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
return -1;
}
ComTdbVirtObjCommentInfo objCommentInfo;
- cmpSBD.getSeabaseObjectComment(objectUID, objType, objCommentInfo, heap);
+ if (cmpSBD.getSeabaseObjectComment(objectUID, objType, objCommentInfo, heap))
+ {
+ *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+ return -1;
+ }
//display Table COMMENT statements
if (objCommentInfo.objectComment != NULL)
@@ -3885,14 +3890,8 @@ short CmpDescribeSeabaseTable (
}
//do a comment info memory clean
- if (objCommentInfo.columnCommentArray != NULL)
- {
- NADELETEBASIC(objCommentInfo.columnCommentArray, heap);
- }
- if (objCommentInfo.indexCommentArray != NULL)
- {
- NADELETEBASIC(objCommentInfo.indexCommentArray, heap);
- }
+ NADELETEARRAY(objCommentInfo.columnCommentArray, objCommentInfo.numColumnComment, ComTdbVirtColumnCommentInfo, heap);
+ NADELETEARRAY(objCommentInfo.indexCommentArray, objCommentInfo.numIndexComment, ComTdbVirtIndexCommentInfo, heap);
cmpSBD.switchBackCompiler();
}
@@ -4014,11 +4013,44 @@ short CmpDescribeSequence(
(CmpCommon::getDefault(SHOWDDL_DISPLAY_PRIVILEGE_GRANTS) == DF_OFF))
displayPrivilegeGrants = FALSE;
+ int64_t objectUID = (int64_t)naTable->objectUid().get_value();
+ CmpSeabaseDDL cmpSBD((NAHeap*)heap);
+
+ //display comment
+ if (objectUID > 0)
+ {
+ if (cmpSBD.switchCompiler())
+ {
+ *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+ return -1;
+ }
+
+ ComTdbVirtObjCommentInfo objCommentInfo;
+ if (cmpSBD.getSeabaseObjectComment(objectUID, COM_SEQUENCE_GENERATOR_OBJECT, objCommentInfo, heap))
+ {
+ *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+ return -1;
+ }
+
+ if (objCommentInfo.objectComment != NULL)
+ {
+ //new line
+ outputLine(*space, "", 0);
+
+ sprintf(buf, "COMMENT ON SEQUENCE %s IS '%s' ;",
+ cn.getQualifiedNameObj().getQualifiedNameAsAnsiString(TRUE).data(),
+ objCommentInfo.objectComment);
+ outputLine(*space, buf, 0);
+ }
+
+ cmpSBD.switchBackCompiler();
+ }
+
+
// If authorization enabled, display grant statements
if (CmpCommon::context()->isAuthorizationEnabled() && displayPrivilegeGrants)
{
// now get the grant stmts
- int64_t objectUID = (int64_t)naTable->objectUid().get_value();
NAString privMDLoc;
CONCAT_CATSCH(privMDLoc, CmpSeabaseDDL::getSystemCatalogStatic(), SEABASE_MD_SCHEMA);
NAString privMgrMDLoc;
@@ -4029,7 +4061,6 @@ short CmpDescribeSequence(
std::string privilegeText;
PrivMgrObjectInfo objectInfo(naTable);
- CmpSeabaseDDL cmpSBD((NAHeap*)heap);
if (cmpSBD.switchCompiler())
{
*CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_PRIVS);
@@ -4259,7 +4290,11 @@ char buf[1000];
}
ComTdbVirtObjCommentInfo objCommentInfo;
- cmpSBD.getSeabaseObjectComment(libraryUID, COM_LIBRARY_OBJECT, objCommentInfo, heap);
+ if (cmpSBD.getSeabaseObjectComment(libraryUID, COM_LIBRARY_OBJECT, objCommentInfo, heap))
+ {
+ *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+ return -1;
+ }
if (objCommentInfo.objectComment != NULL)
{
@@ -4800,7 +4835,12 @@ short CmpDescribeRoutine (const CorrName & cn,
}
ComTdbVirtObjCommentInfo objCommentInfo;
- cmpSBD.getSeabaseObjectComment(routineUID, COM_USER_DEFINED_ROUTINE_OBJECT, objCommentInfo, heap);
+ if (cmpSBD.getSeabaseObjectComment(routineUID, COM_USER_DEFINED_ROUTINE_OBJECT, objCommentInfo, heap))
+ {
+ *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+ return -1;
+ }
+
if (objCommentInfo.objectComment != NULL)
{
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/0b7e3a35/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp
index 95b589f..1e5e294 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp
@@ -66,6 +66,122 @@
#include "ComUser.h"
+short CmpSeabaseDDL::getSeabaseObjectComment(Int64 object_uid,
+ enum ComObjectType object_type,
+ ComTdbVirtObjCommentInfo & comment_info,
+ CollHeap * heap)
+{
+ Lng32 retcode = 0;
+ Lng32 cliRC = 0;
+
+ char query[4000];
+
+ comment_info.objectUid = object_uid;
+ comment_info.objectComment = NULL;
+ comment_info.numColumnComment = 0;
+ comment_info.columnCommentArray = NULL;
+ comment_info.numIndexComment = 0;
+ comment_info.indexCommentArray = NULL;
+
+ ExeCliInterface cliInterface(STMTHEAP, NULL, NULL,
+ CmpCommon::context()->sqlSession()->getParentQid());
+
+ //get object comment
+ sprintf(query, "select comment from %s.\"%s\".%s where object_uid = %ld and object_type = '%s' and comment <> '' ;",
+ getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
+ object_uid, comObjectTypeLit(object_type));
+
+ Queue * objQueue = NULL;
+ cliRC = cliInterface.fetchAllRows(objQueue, query, 0, FALSE, FALSE, TRUE);
+ if (cliRC < 0)
+ {
+ cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
+ processReturn();
+ return -1;
+ }
+
+ //We should have only 1 comment for object
+ if (objQueue->numEntries() > 0)
+ {
+ objQueue->position();
+ OutputInfo * vi = (OutputInfo*)objQueue->getNext();
+ comment_info.objectComment = (char*)vi->get(0);
+ }
+
+ //get index comments of table
+ if (COM_BASE_TABLE_OBJECT == object_type)
+ {
+ sprintf(query, "select CATALOG_NAME||'.'||SCHEMA_NAME||'.'||OBJECT_NAME, COMMENT "
+ "from %s.\"%s\".%s as O, %s.\"%s\".%s as I "
+ "where I.BASE_TABLE_UID = %ld and O.OBJECT_UID = I.INDEX_UID and O.comment <> '' ;",
+ getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
+ getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_INDEXES,
+ object_uid);
+
+ Queue * indexQueue = NULL;
+ cliRC = cliInterface.fetchAllRows(indexQueue, query, 0, FALSE, FALSE, TRUE);
+ if (cliRC < 0)
+ {
+ cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
+ processReturn();
+ return -1;
+ }
+
+ if (indexQueue->numEntries() > 0)
+ {
+ comment_info.numIndexComment = indexQueue->numEntries();
+ comment_info.indexCommentArray = new(heap) ComTdbVirtIndexCommentInfo[comment_info.numIndexComment];
+
+ indexQueue->position();
+ for (Lng32 idx = 0; idx < comment_info.numIndexComment; idx++)
+ {
+ OutputInfo * oi = (OutputInfo*)indexQueue->getNext();
+ ComTdbVirtIndexCommentInfo &indexComment = comment_info.indexCommentArray[idx];
+
+ // get the index full name
+ indexComment.indexFullName = (char*) oi->get(0);
+ indexComment.indexComment = (char*) oi->get(1);
+ }
+ }
+ }
+
+ //get column comments of table and view
+ if (COM_BASE_TABLE_OBJECT == object_type || COM_VIEW_OBJECT == object_type)
+ {
+ sprintf(query, "select COLUMN_NAME, COMMENT from %s.\"%s\".%s where OBJECT_UID = %ld and comment <> '' order by COLUMN_NUMBER ;",
+ getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_COLUMNS, object_uid);
+
+ Queue * colQueue = NULL;
+ cliRC = cliInterface.fetchAllRows(colQueue, query, 0, FALSE, FALSE, TRUE);
+ if (cliRC < 0)
+ {
+ cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
+ processReturn();
+ return -1;
+ }
+
+ if (colQueue->numEntries() > 0)
+ {
+ comment_info.numColumnComment = colQueue->numEntries();
+ comment_info.columnCommentArray = new(heap) ComTdbVirtColumnCommentInfo[comment_info.numColumnComment];
+
+ colQueue->position();
+ for (Lng32 idx = 0; idx < comment_info.numColumnComment; idx++)
+ {
+ OutputInfo * oi = (OutputInfo*)colQueue->getNext();
+ ComTdbVirtColumnCommentInfo &colComment = comment_info.columnCommentArray[idx];
+
+ // get the column name
+ colComment.columnName = (char*) oi->get(0);
+ colComment.columnComment = (char*) oi->get(1);
+ }
+ }
+ }
+
+ return 0;
+}
+
+
void CmpSeabaseDDL::doSeabaseCommentOn(StmtDDLCommentOn *commentOnNode,
NAString &currCatName,
NAString &currSchName)
@@ -173,7 +289,7 @@ void CmpSeabaseDDL::doSeabaseCommentOn(StmtDDLCommentOn *commentOnNode,
if (StmtDDLCommentOn::COMMENT_ON_TYPE_COLUMN == commentObjectType)
{
- str_sprintf(query, "update %s.\"%s\".%s set comment = '%s' where object_uid = %ld and column_name = '%s' ",
+ sprintf(query, "update %s.\"%s\".%s set comment = '%s' where object_uid = %ld and column_name = '%s' ",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_COLUMNS,
comment.data(),
objUID,
@@ -183,7 +299,7 @@ void CmpSeabaseDDL::doSeabaseCommentOn(StmtDDLCommentOn *commentOnNode,
}
else
{
- str_sprintf(query, "update %s.\"%s\".%s set comment = '%s' where catalog_name = '%s' and schema_name = '%s' and object_name = '%s' and object_type = '%s' ",
+ sprintf(query, "update %s.\"%s\".%s set comment = '%s' where catalog_name = '%s' and schema_name = '%s' and object_name = '%s' and object_type = '%s' ",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
comment.data(),
catalogNamePart.data(), schemaNamePart.data(), objNamePart.data(),
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/0b7e3a35/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
index e44faeb..45736b0 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
@@ -456,7 +456,11 @@ Int16 status = ComUser::getAuthNameFromAuthID(objectOwner,username,
// Display Comment of schema
{
ComTdbVirtObjCommentInfo objCommentInfo;
- cmpSBD.getSeabaseObjectComment(schemaUID, objectType, objCommentInfo, STMTHEAP);
+ if (cmpSBD.getSeabaseObjectComment(schemaUID, objectType, objCommentInfo, STMTHEAP))
+ {
+ *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+ return -1;
+ }
if (objCommentInfo.objectComment != NULL)
{
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/0b7e3a35/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
index 886c42d..83abc38 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
@@ -12940,122 +12940,6 @@ TrafDesc *CmpSeabaseDDL::getSeabaseRoutineDescInternal(const NAString &catName,
}
-short CmpSeabaseDDL::getSeabaseObjectComment(Int64 object_uid,
- enum ComObjectType object_type,
- ComTdbVirtObjCommentInfo & comment_info,
- CollHeap * heap)
-{
- Lng32 retcode = 0;
- Lng32 cliRC = 0;
-
- char query[4000];
-
- comment_info.objectUid = object_uid;
- comment_info.objectComment = NULL;
- comment_info.numColumnComment = 0;
- comment_info.columnCommentArray = NULL;
- comment_info.numIndexComment = 0;
- comment_info.indexCommentArray = NULL;
-
- ExeCliInterface cliInterface(STMTHEAP, NULL, NULL,
- CmpCommon::context()->sqlSession()->getParentQid());
-
- //get object comment
- str_sprintf(query, "select comment from %s.\"%s\".%s where object_uid = %ld and object_type = '%s' and comment <> '' ;",
- getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
- object_uid, comObjectTypeLit(object_type));
-
- Queue * objQueue = NULL;
- cliRC = cliInterface.fetchAllRows(objQueue, query, 0, FALSE, FALSE, TRUE);
- if (cliRC < 0)
- {
- cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
- processReturn();
- return -1;
- }
-
- //We should have only 1 comment for object
- if (objQueue->numEntries() > 0)
- {
- objQueue->position();
- OutputInfo * vi = (OutputInfo*)objQueue->getNext();
- comment_info.objectComment = (char*)vi->get(0);
- }
-
- //get index comments of table
- if (COM_BASE_TABLE_OBJECT == object_type)
- {
- str_sprintf(query, "select CATALOG_NAME||'.'||SCHEMA_NAME||'.'||OBJECT_NAME, COMMENT "
- "from %s.\"%s\".%s as O, %s.\"%s\".%s as I "
- "where I.BASE_TABLE_UID = %ld and O.OBJECT_UID = I.INDEX_UID and O.comment <> '' ;",
- getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
- getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_INDEXES,
- object_uid);
-
- Queue * indexQueue = NULL;
- cliRC = cliInterface.fetchAllRows(indexQueue, query, 0, FALSE, FALSE, TRUE);
- if (cliRC < 0)
- {
- cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
- processReturn();
- return -1;
- }
-
- if (indexQueue->numEntries() > 0)
- {
- comment_info.numIndexComment = indexQueue->numEntries();
- comment_info.indexCommentArray = new(heap) ComTdbVirtIndexCommentInfo[comment_info.numIndexComment];
-
- indexQueue->position();
- for (Lng32 idx = 0; idx < comment_info.numIndexComment; idx++)
- {
- OutputInfo * oi = (OutputInfo*)indexQueue->getNext();
- ComTdbVirtIndexCommentInfo &indexComment = comment_info.indexCommentArray[idx];
-
- // get the index full name
- indexComment.indexFullName = (char*) oi->get(0);
- indexComment.indexComment = (char*) oi->get(1);
- }
- }
- }
-
- //get column comments of table and view
- if (COM_BASE_TABLE_OBJECT == object_type || COM_VIEW_OBJECT == object_type)
- {
- str_sprintf(query, "select COLUMN_NAME, COMMENT from %s.\"%s\".%s where OBJECT_UID = %ld and comment <> '' order by COLUMN_NUMBER ;",
- getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_COLUMNS, object_uid);
-
- Queue * colQueue = NULL;
- cliRC = cliInterface.fetchAllRows(colQueue, query, 0, FALSE, FALSE, TRUE);
- if (cliRC < 0)
- {
- cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
- processReturn();
- return -1;
- }
-
- if (colQueue->numEntries() > 0)
- {
- comment_info.numColumnComment = colQueue->numEntries();
- comment_info.columnCommentArray = new(heap) ComTdbVirtColumnCommentInfo[comment_info.numColumnComment];
-
- colQueue->position();
- for (Lng32 idx = 0; idx < comment_info.numColumnComment; idx++)
- {
- OutputInfo * oi = (OutputInfo*)colQueue->getNext();
- ComTdbVirtColumnCommentInfo &colComment = comment_info.columnCommentArray[idx];
-
- // get the column name
- colComment.columnName = (char*) oi->get(0);
- colComment.columnComment = (char*) oi->get(1);
- }
- }
- }
-
- return 0;
-}
-
-
// *****************************************************************************
// * *
// * Function: checkSpecifiedPrivs *
[03/11] incubator-trafodion git commit: new COMMENT-ON SQL statement:
add COMMENT syntax support for sqlci
Posted by db...@apache.org.
new COMMENT-ON SQL statement: add COMMENT syntax support for sqlci
1. add COMMENT syntax support for sqlci
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/cc8f68f2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/cc8f68f2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/cc8f68f2
Branch: refs/heads/master
Commit: cc8f68f2235c9eb242297829c3536539de85a273
Parents: 69c284c
Author: eedy <cq...@gmail.com>
Authored: Fri Nov 3 11:35:24 2017 +0800
Committer: eedy <cq...@gmail.com>
Committed: Fri Nov 3 11:35:24 2017 +0800
----------------------------------------------------------------------
core/sql/sqlci/sqlci_lex.ll | 1 +
core/sql/sqlci/sqlci_yacc.y | 2 ++
2 files changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/cc8f68f2/core/sql/sqlci/sqlci_lex.ll
----------------------------------------------------------------------
diff --git a/core/sql/sqlci/sqlci_lex.ll b/core/sql/sqlci/sqlci_lex.ll
index 0e22666..40d891a 100755
--- a/core/sql/sqlci/sqlci_lex.ll
+++ b/core/sql/sqlci/sqlci_lex.ll
@@ -161,6 +161,7 @@ B [ \t\n]+
[Cc][Oo][Mm][Mm][Aa][Nn][Dd] return_IDENT_or_TOKEN(COMMANDStoken,0);
[Cc][Oo][Mm][Mm][Aa][Nn][Dd][Ss] return_IDENT_or_TOKEN(COMMANDStoken,0);
[Cc][Oo][Mm][Mm][Ii][Tt] return_IDENT_or_TOKEN(COMMIT, 0);
+[Cc][Oo][Mm][Mm][Ee][Nn][Tt] return_IDENT_or_TOKEN(COMMENTtoken, 0);
[Cc][Oo][Nn][Tt][Rr][Oo][Ll] return_IDENT_or_TOKEN(CONTROL, 0);
[Cc][Oo][Nn][Tt][Rr][Oo][Ll][Ss] return_IDENT_or_TOKEN(CONTROL, 0);
[Cc][Qq][Dd] return_IDENT_or_TOKEN(CONTROL, 0);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/cc8f68f2/core/sql/sqlci/sqlci_yacc.y
----------------------------------------------------------------------
diff --git a/core/sql/sqlci/sqlci_yacc.y b/core/sql/sqlci/sqlci_yacc.y
index 6f89f00..33e926a 100644
--- a/core/sql/sqlci/sqlci_yacc.y
+++ b/core/sql/sqlci/sqlci_yacc.y
@@ -525,6 +525,7 @@ static char * FCString (const char *idString, int isFC)
%token UNLOAD
%token CALLToken
+%token COMMENTtoken
%union {
enum ComRoutineSQLAccess sql_access_mode_type;
@@ -1950,6 +1951,7 @@ dml_type :
| EXPLAIN {$$ = DML_DESCRIBE_TYPE;}
| GETtoken {$$ = DML_DESCRIBE_TYPE;}
| PROCESStoken {$$ = DML_DDL_TYPE;}
+ | COMMENTtoken {$$ = DML_DDL_TYPE;}
;
dml_simple_table_type :
[04/11] incubator-trafodion git commit: new COMMENT-ON SQL statement:
review change - add support for sequence and columns of view
Posted by db...@apache.org.
new COMMENT-ON SQL statement: review change - add support for sequence and columns of view
1. add comment support for sequence generator
2. add comment support for columns of view
3. wrong comments and spellings
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/4127e1c0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/4127e1c0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/4127e1c0
Branch: refs/heads/master
Commit: 4127e1c0e639a3d5eb71010095a82376348b089b
Parents: cc8f68f
Author: eedy <cq...@gmail.com>
Authored: Sun Nov 5 08:26:52 2017 +0800
Committer: eedy <cq...@gmail.com>
Committed: Sun Nov 5 08:26:52 2017 +0800
----------------------------------------------------------------------
core/sql/parser/BindStmtDDL.cpp | 4 +-
core/sql/parser/StmtDDLCommentOn.h | 5 ++-
core/sql/parser/StmtDDLCreate.cpp | 6 ++-
core/sql/parser/sqlparser.y | 4 ++
core/sql/sqlcomp/CmpDescribe.cpp | 13 ++++++-
core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp | 47 +++++++++++++-----------
core/sql/sqlcomp/CmpSeabaseDDLschema.cpp | 2 +-
core/sql/sqlcomp/CmpSeabaseDDLtable.cpp | 10 ++---
core/sql/sqlcomp/PrivMgr.cpp | 2 +-
9 files changed, 59 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4127e1c0/core/sql/parser/BindStmtDDL.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/BindStmtDDL.cpp b/core/sql/parser/BindStmtDDL.cpp
index f0e01e4..2294b45 100644
--- a/core/sql/parser/BindStmtDDL.cpp
+++ b/core/sql/parser/BindStmtDDL.cpp
@@ -2577,7 +2577,7 @@ StmtDDLAlterUser::bindNode(BindWA * pBindWA)
}
// -----------------------------------------------------------------------
-// definition of method bindNode() for class StmtDDLCreateLibrary
+// definition of method bindNode() for class StmtDDLCommentOn
// -----------------------------------------------------------------------
ExprNode *
@@ -2611,6 +2611,8 @@ StmtDDLCommentOn::bindNode(BindWA * pBindWA)
return this;
}
+ isViewCol_ = (naTable->getViewText() ? TRUE : FALSE);
+
const NAColumnArray &nacolArr = naTable->getNAColumnArray();
const NAColumn * nacol = nacolArr.getColumn(getColName());
if (! nacol)
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4127e1c0/core/sql/parser/StmtDDLCommentOn.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLCommentOn.h b/core/sql/parser/StmtDDLCommentOn.h
index cec13f6..57b3542 100644
--- a/core/sql/parser/StmtDDLCommentOn.h
+++ b/core/sql/parser/StmtDDLCommentOn.h
@@ -65,6 +65,7 @@ public:
COMMENT_ON_TYPE_LIBRARY,
COMMENT_ON_TYPE_PROCEDURE,
COMMENT_ON_TYPE_FUNCTION,
+ COMMENT_ON_TYPE_SEQUENCE,
COMMENT_ON_TYPE_UNKNOWN
};
@@ -100,6 +101,7 @@ public:
inline const NAString getObjectName() const;
inline const NAString &getComment() const { return comment_; }
inline const NAString &getColName() const { return colRef_->getColRefNameObj().getColName(); }
+ inline NABoolean getIsViewCol() { return isViewCol_; }
inline Int32 getVersion() {return 1;}
@@ -116,7 +118,8 @@ private:
enum COMMENT_ON_TYPES type_;
QualifiedName objectName_;
- ColReference * colRef_;
+ ColReference * colRef_;
+ NABoolean isViewCol_;
const NAString & comment_;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4127e1c0/core/sql/parser/StmtDDLCreate.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLCreate.cpp b/core/sql/parser/StmtDDLCreate.cpp
index 4537f72..ff39634 100644
--- a/core/sql/parser/StmtDDLCreate.cpp
+++ b/core/sql/parser/StmtDDLCreate.cpp
@@ -7179,7 +7179,8 @@ StmtDDLCommentOn::StmtDDLCommentOn(COMMENT_ON_TYPES objType, const QualifiedName
type_(objType),
objectName_(objName, heap),
comment_(commentStr),
- colRef_(NULL)
+ colRef_(NULL),
+ isViewCol_(FALSE)
{
}
@@ -7190,7 +7191,8 @@ StmtDDLCommentOn::StmtDDLCommentOn(COMMENT_ON_TYPES objType, const QualifiedName
type_(objType),
objectName_(objName, heap),
colRef_(colRef),
- comment_(commentStr)
+ comment_(commentStr),
+ isViewCol_(FALSE)
{
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4127e1c0/core/sql/parser/sqlparser.y
----------------------------------------------------------------------
diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y
index 1b43b02..df4cc2e 100755
--- a/core/sql/parser/sqlparser.y
+++ b/core/sql/parser/sqlparser.y
@@ -33266,6 +33266,10 @@ comment_on_object_types : TOK_TABLE
{
$$ = StmtDDLCommentOn::COMMENT_ON_TYPE_FUNCTION;
}
+ | TOK_SEQUENCE
+ {
+ $$ = StmtDDLCommentOn::COMMENT_ON_TYPE_SEQUENCE;
+ }
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4127e1c0/core/sql/sqlcomp/CmpDescribe.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpDescribe.cpp b/core/sql/sqlcomp/CmpDescribe.cpp
index af9503f..fed0087 100644
--- a/core/sql/sqlcomp/CmpDescribe.cpp
+++ b/core/sql/sqlcomp/CmpDescribe.cpp
@@ -3062,7 +3062,7 @@ short CmpDescribeSeabaseTable (
outputLongLine(*space, viewtext, 0);
//display comment for VIEW
- if (objectUID > 0/* && COMMENT_CQD*/)
+ if (objectUID > 0)
{
if (cmpSBD.switchCompiler())
{
@@ -3086,6 +3086,17 @@ short CmpDescribeSeabaseTable (
objCommentInfo->objectComment);
outputLine(*space, buf, 0);
}
+
+ //display Column COMMENT statements
+ outputLine(*space, "", 0);
+ for (int idx = 0; idx < objCommentInfo->numColumnComment; idx++)
+ {
+ sprintf(buf, "COMMENT ON COLUMN %s.%s IS '%s' ;",
+ tableName.data(),
+ objCommentInfo->columnCommentArray[idx].columnName,
+ objCommentInfo->columnCommentArray[idx].columnComment);
+ outputLine(*space, buf, 0);
+ }
}
cmpSBD.switchBackCompiler();
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4127e1c0/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp
index 83fc83f..95b589f 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp
@@ -74,7 +74,7 @@ void CmpSeabaseDDL::doSeabaseCommentOn(StmtDDLCommentOn *commentOnNode,
Lng32 retcode;
enum ComObjectType enMDObjType = COM_UNKNOWN_OBJECT;
-
+
ComObjectName objectName(commentOnNode->getObjectName());
ComAnsiNamePart currCatAnsiName(currCatName);
ComAnsiNamePart currSchAnsiName(currSchName);
@@ -87,9 +87,16 @@ void CmpSeabaseDDL::doSeabaseCommentOn(StmtDDLCommentOn *commentOnNode,
case StmtDDLCommentOn::COMMENT_ON_TYPE_TABLE:
enMDObjType = COM_BASE_TABLE_OBJECT;
break;
-
+
case StmtDDLCommentOn::COMMENT_ON_TYPE_COLUMN:
- enMDObjType = COM_BASE_TABLE_OBJECT;
+ if (TRUE == commentOnNode->getIsViewCol())
+ {
+ enMDObjType = COM_VIEW_OBJECT;
+ }
+ else
+ {
+ enMDObjType = COM_BASE_TABLE_OBJECT;
+ }
break;
case StmtDDLCommentOn::COMMENT_ON_TYPE_INDEX:
@@ -113,6 +120,9 @@ void CmpSeabaseDDL::doSeabaseCommentOn(StmtDDLCommentOn *commentOnNode,
enMDObjType = COM_USER_DEFINED_ROUTINE_OBJECT;
break;
+ case StmtDDLCommentOn::COMMENT_ON_TYPE_SEQUENCE:
+ enMDObjType = COM_SEQUENCE_GENERATOR_OBJECT;
+
default:
break;
@@ -127,26 +137,10 @@ void CmpSeabaseDDL::doSeabaseCommentOn(StmtDDLCommentOn *commentOnNode,
ExeCliInterface cliInterface(STMTHEAP, NULL, NULL,
CmpCommon::context()->sqlSession()->getParentQid());
Int64 objUID = 0;
- Int32 objectOwnerID = SUPER_USER;
- Int32 schemaOwnerID = SUPER_USER;
+ Int32 objectOwnerID = ROOT_USER_ID;
+ Int32 schemaOwnerID = ROOT_USER_ID;
Int64 objectFlags = 0;
- // Verify that the requester has COMMENT privilege.
- if (isAuthorizationEnabled() && !ComUser::isRootUserID())
- {
- NAString privMgrMDLoc;
- CONCAT_CATSCH(privMgrMDLoc, getSystemCatalog(), SEABASE_PRIVMGR_SCHEMA);
-
- PrivMgrComponentPrivileges componentPrivileges(std::string(privMgrMDLoc.data()), CmpCommon::diags());
-
- if (!componentPrivileges.hasSQLPriv(ComUser::getCurrentUser(), SQLOperation::COMMENT, true))
- {
- *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED);
- processReturn ();
- return;
- }
- }
-
//get UID of object
objUID = getObjectInfo(&cliInterface,
catalogNamePart.data(), schemaNamePart.data(), objNamePart.data(),
@@ -163,6 +157,16 @@ void CmpSeabaseDDL::doSeabaseCommentOn(StmtDDLCommentOn *commentOnNode,
return;
}
+ // Verify that the requester has COMMENT privilege.
+ if (!isDDLOperationAuthorized(SQLOperation::COMMENT, schemaOwnerID, schemaOwnerID))
+ {
+ *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED);
+ processReturn ();
+ return;
+ }
+
+ //check for overflow, but how i can get type size of COMMENT column?
+
// add, remove, change comment of object/column
const NAString & comment = commentOnNode->getComment();
char * query = new(STMTHEAP) char[comment.length()+1024];
@@ -187,7 +191,6 @@ void CmpSeabaseDDL::doSeabaseCommentOn(StmtDDLCommentOn *commentOnNode,
cliRC = cliInterface.executeImmediate(query);
}
-
NADELETEBASIC(query, STMTHEAP);
if (cliRC < 0)
{
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4127e1c0/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
index 3cc4c93..021a605 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
@@ -453,7 +453,7 @@ Int16 status = ComUser::getAuthNameFromAuthID(objectOwner,username,
outlines.push_back(output.data());
- // Disaply Comment of schema
+ // Display Comment of schema
{
ComTdbVirtObjCommentInfo * objCommentInfo = NULL;
cmpSBD.getSeabaseObjectComment(schemaUID, objectType, objCommentInfo);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4127e1c0/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
index 4924c14..5fd5794 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
@@ -12948,12 +12948,9 @@ short CmpSeabaseDDL::getSeabaseObjectComment(Int64 object_uid,
Lng32 cliRC = 0;
char query[4000];
-
comment_info = NULL;
-
- ExeCliInterface cliInterface(STMTHEAP,
- NULL, NULL,
+ ExeCliInterface cliInterface(STMTHEAP, NULL, NULL,
CmpCommon::context()->sqlSession()->getParentQid());
//get object comment
@@ -12973,7 +12970,7 @@ short CmpSeabaseDDL::getSeabaseObjectComment(Int64 object_uid,
if (objQueue->numEntries() == 1)
{
objQueue->position();
-
+
OutputInfo * vi = (OutputInfo*)objQueue->getNext();
comment_info = new(STMTHEAP) ComTdbVirtObjCommentInfo[1];
@@ -13033,7 +13030,10 @@ short CmpSeabaseDDL::getSeabaseObjectComment(Int64 object_uid,
indexComment.indexComment = (char*) oi->get(1);
}
}
+ }
+ if (COM_BASE_TABLE_OBJECT == object_type || COM_VIEW_OBJECT == object_type)
+ {
//get column comment of table
str_sprintf(query, "select COLUMN_NAME, COMMENT from %s.\"%s\".%s where OBJECT_UID = %ld and comment <> '' order by COLUMN_NUMBER ;",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_COLUMNS, object_uid);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4127e1c0/core/sql/sqlcomp/PrivMgr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/PrivMgr.cpp b/core/sql/sqlcomp/PrivMgr.cpp
index f9811c0..c8a1a20 100644
--- a/core/sql/sqlcomp/PrivMgr.cpp
+++ b/core/sql/sqlcomp/PrivMgr.cpp
@@ -483,7 +483,7 @@ const char * PrivMgr::getSQLOperationCode(SQLOperation operation)
case SQLOperation::SHOW: return "SW";
case SQLOperation::UNREGISTER_HIVE_OBJECT: return "UH";
case SQLOperation::USE_ALTERNATE_SCHEMA: return "UA";
- case SQLOperation::COMMENT: return "CO";
+ case SQLOperation::COMMENT: return "CO";
default:
return " ";
}
[05/11] incubator-trafodion git commit: new COMMENT-ON SQL statement:
review change - delete allocated spaces for function
CmpSeabaseDDL::getSeabaseObjectComment
Posted by db...@apache.org.
new COMMENT-ON SQL statement: review change - delete allocated spaces for function CmpSeabaseDDL::getSeabaseObjectComment
1. delete allocated COMMENT spaces after used.
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/4bdd4b84
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/4bdd4b84
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/4bdd4b84
Branch: refs/heads/master
Commit: 4bdd4b84e5c718898c43575fe993051fd4fedaba
Parents: 4127e1c
Author: eedy <cq...@gmail.com>
Authored: Mon Nov 6 13:39:16 2017 +0800
Committer: eedy <cq...@gmail.com>
Committed: Mon Nov 6 13:39:16 2017 +0800
----------------------------------------------------------------------
core/sql/comexe/ComTdb.h | 7 ++
core/sql/sqlcomp/CmpDescribe.cpp | 111 +++++++++++++++-----------
core/sql/sqlcomp/CmpSeabaseDDL.h | 3 +-
core/sql/sqlcomp/CmpSeabaseDDLschema.cpp | 14 ++--
core/sql/sqlcomp/CmpSeabaseDDLtable.cpp | 82 +++++++------------
5 files changed, 110 insertions(+), 107 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4bdd4b84/core/sql/comexe/ComTdb.h
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdb.h b/core/sql/comexe/ComTdb.h
index 73fa28a..1b90b90 100644
--- a/core/sql/comexe/ComTdb.h
+++ b/core/sql/comexe/ComTdb.h
@@ -1167,6 +1167,13 @@ class ComTdbVirtObjCommentInfo : public ComTdbVirtTableBase
: ComTdbVirtTableBase()
{
init();
+
+ objectUid = 0;
+ objectComment = NULL;
+ numColumnComment = 0;
+ columnCommentArray = NULL;
+ numIndexComment = 0;
+ indexCommentArray = NULL;
}
virtual Int32 size() { return sizeof(ComTdbVirtObjCommentInfo);}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4bdd4b84/core/sql/sqlcomp/CmpDescribe.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpDescribe.cpp b/core/sql/sqlcomp/CmpDescribe.cpp
index fed0087..2d9c9da 100644
--- a/core/sql/sqlcomp/CmpDescribe.cpp
+++ b/core/sql/sqlcomp/CmpDescribe.cpp
@@ -3070,35 +3070,41 @@ short CmpDescribeSeabaseTable (
return -1;
}
- ComTdbVirtObjCommentInfo * objCommentInfo = NULL;
- cmpSBD.getSeabaseObjectComment(objectUID, COM_VIEW_OBJECT, objCommentInfo);
+ ComTdbVirtObjCommentInfo objCommentInfo;
+ cmpSBD.getSeabaseObjectComment(objectUID, COM_VIEW_OBJECT, objCommentInfo, heap);
- if (objCommentInfo != NULL)
+ //display VIEW COMMENT statements
+ if (objCommentInfo.objectComment != NULL)
{
//new line
outputLine(*space, "", 0);
- //display VIEW COMMENT statements
- if (objCommentInfo->objectComment != NULL)
- {
- sprintf(buf, "COMMENT ON VIEW %s IS '%s' ;",
- tableName.data(),
- objCommentInfo->objectComment);
- outputLine(*space, buf, 0);
- }
+ sprintf(buf, "COMMENT ON VIEW %s IS '%s' ;",
+ tableName.data(),
+ objCommentInfo.objectComment);
+ outputLine(*space, buf, 0);
+ }
+ if (objCommentInfo.numColumnComment > 0 && objCommentInfo.columnCommentArray != NULL)
+ {
//display Column COMMENT statements
outputLine(*space, "", 0);
- for (int idx = 0; idx < objCommentInfo->numColumnComment; idx++)
+ for (int idx = 0; idx < objCommentInfo.numColumnComment; idx++)
{
sprintf(buf, "COMMENT ON COLUMN %s.%s IS '%s' ;",
tableName.data(),
- objCommentInfo->columnCommentArray[idx].columnName,
- objCommentInfo->columnCommentArray[idx].columnComment);
+ objCommentInfo.columnCommentArray[idx].columnName,
+ objCommentInfo.columnCommentArray[idx].columnComment);
outputLine(*space, buf, 0);
}
}
+ //do a comment info memory clean
+ if (objCommentInfo.columnCommentArray != NULL)
+ {
+ NADELETEBASIC(objCommentInfo.columnCommentArray, heap);
+ }
+
cmpSBD.switchBackCompiler();
}
@@ -3835,46 +3841,59 @@ short CmpDescribeSeabaseTable (
return -1;
}
- ComTdbVirtObjCommentInfo * objCommentInfo = NULL;
- cmpSBD.getSeabaseObjectComment(objectUID, objType, objCommentInfo);
-
- if (objCommentInfo != NULL)
+ ComTdbVirtObjCommentInfo objCommentInfo;
+ cmpSBD.getSeabaseObjectComment(objectUID, objType, objCommentInfo, heap);
+
+ //display Table COMMENT statements
+ if (objCommentInfo.objectComment != NULL)
{
- //new line
- outputLine(*space, "", 0);
+ //new line
+ outputLine(*space, "", 0);
+
+ sprintf(buf, "COMMENT ON %s %s IS '%s' ;",
+ objType == COM_BASE_TABLE_OBJECT? "TABLE" : "VIEW",
+ tableName.data(),
+ objCommentInfo.objectComment);
+ outputLine(*space, buf, 0);
+ }
- //display Table COMMENT statements
- if (objCommentInfo->objectComment != NULL)
- {
- sprintf(buf, "COMMENT ON %s %s IS '%s' ;",
- objType == COM_BASE_TABLE_OBJECT? "TABLE" : "VIEW",
- tableName.data(),
- objCommentInfo->objectComment);
- outputLine(*space, buf, 0);
- }
-
- //display Column COMMENT statements
+ //display Column COMMENT statements
+ if (objCommentInfo.numColumnComment > 0 && objCommentInfo.columnCommentArray != NULL)
+ {
outputLine(*space, "", 0);
- for (int idx = 0; idx < objCommentInfo->numColumnComment; idx++)
+ for (int idx = 0; idx < objCommentInfo.numColumnComment; idx++)
{
sprintf(buf, "COMMENT ON COLUMN %s.%s IS '%s' ;",
tableName.data(),
- objCommentInfo->columnCommentArray[idx].columnName,
- objCommentInfo->columnCommentArray[idx].columnComment);
+ objCommentInfo.columnCommentArray[idx].columnName,
+ objCommentInfo.columnCommentArray[idx].columnComment);
outputLine(*space, buf, 0);
}
+ }
- //display Index COMMENT statements
+ //display Index COMMENT statements
+ if (objCommentInfo.numIndexComment > 0 && objCommentInfo.indexCommentArray != NULL)
+ {
outputLine(*space, "", 0);
- for (int idx = 0; idx < objCommentInfo->numIndexComment; idx++)
+ for (int idx = 0; idx < objCommentInfo.numIndexComment; idx++)
{
sprintf(buf, "COMMENT ON INDEX %s IS '%s' ;",
- objCommentInfo->indexCommentArray[idx].indexFullName,
- objCommentInfo->indexCommentArray[idx].indexComment);
+ objCommentInfo.indexCommentArray[idx].indexFullName,
+ objCommentInfo.indexCommentArray[idx].indexComment);
outputLine(*space, buf, 0);
}
}
+ //do a comment info memory clean
+ if (objCommentInfo.columnCommentArray != NULL)
+ {
+ NADELETEBASIC(objCommentInfo.columnCommentArray, heap);
+ }
+ if (objCommentInfo.indexCommentArray != NULL)
+ {
+ NADELETEBASIC(objCommentInfo.indexCommentArray, heap);
+ }
+
cmpSBD.switchBackCompiler();
}
@@ -4239,17 +4258,17 @@ char buf[1000];
return -1;
}
- ComTdbVirtObjCommentInfo * objCommentInfo = NULL;
- cmpSBD.getSeabaseObjectComment(libraryUID, COM_LIBRARY_OBJECT, objCommentInfo);
+ ComTdbVirtObjCommentInfo objCommentInfo;
+ cmpSBD.getSeabaseObjectComment(libraryUID, COM_LIBRARY_OBJECT, objCommentInfo, heap);
- if (objCommentInfo != NULL && objCommentInfo->objectComment != NULL)
+ if (objCommentInfo.objectComment != NULL)
{
//new line
outputLine(*space, "", 0);
sprintf(buf, "COMMENT ON LIBRARY %s IS '%s' ;",
cn.getQualifiedNameObj().getQualifiedNameAsAnsiString(TRUE).data(),
- objCommentInfo->objectComment);
+ objCommentInfo.objectComment);
outputLine(*space, buf, 0);
}
@@ -4780,10 +4799,10 @@ short CmpDescribeRoutine (const CorrName & cn,
return -1;
}
- ComTdbVirtObjCommentInfo * objCommentInfo = NULL;
- cmpSBD.getSeabaseObjectComment(routineUID, COM_USER_DEFINED_ROUTINE_OBJECT, objCommentInfo);
+ ComTdbVirtObjCommentInfo objCommentInfo;
+ cmpSBD.getSeabaseObjectComment(routineUID, COM_USER_DEFINED_ROUTINE_OBJECT, objCommentInfo, heap);
- if (objCommentInfo != NULL && objCommentInfo->objectComment != NULL)
+ if (objCommentInfo.objectComment != NULL)
{
//new line
outputLine(*space, "", 0);
@@ -4791,7 +4810,7 @@ short CmpDescribeRoutine (const CorrName & cn,
sprintf(buf, "COMMENT ON %s %s IS '%s' ;",
routine->getRoutineType() == COM_PROCEDURE_TYPE ? "PROCEDURE" : "FUNCTION",
cn.getQualifiedNameObj().getQualifiedNameAsAnsiString(TRUE).data(),
- objCommentInfo->objectComment);
+ objCommentInfo.objectComment);
outputLine(*space, buf, 0);
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4bdd4b84/core/sql/sqlcomp/CmpSeabaseDDL.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDL.h b/core/sql/sqlcomp/CmpSeabaseDDL.h
index a31ef52..a0e4e34 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDL.h
+++ b/core/sql/sqlcomp/CmpSeabaseDDL.h
@@ -255,7 +255,8 @@ class CmpSeabaseDDL
short getSeabaseObjectComment(Int64 object_uid,
enum ComObjectType object_type,
- ComTdbVirtObjCommentInfo * & comment_info);
+ ComTdbVirtObjCommentInfo & comment_info,
+ CollHeap * heap);
short getObjectOwner(ExeCliInterface *cliInterface,
const char * catName,
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4bdd4b84/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
index 021a605..e44faeb 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
@@ -452,13 +452,13 @@ Int16 status = ComUser::getAuthNameFromAuthID(objectOwner,username,
output += "\";";
outlines.push_back(output.data());
-
+
// Display Comment of schema
{
- ComTdbVirtObjCommentInfo * objCommentInfo = NULL;
- cmpSBD.getSeabaseObjectComment(schemaUID, objectType, objCommentInfo);
+ ComTdbVirtObjCommentInfo objCommentInfo;
+ cmpSBD.getSeabaseObjectComment(schemaUID, objectType, objCommentInfo, STMTHEAP);
- if (objCommentInfo != NULL && objCommentInfo->objectComment != NULL)
+ if (objCommentInfo.objectComment != NULL)
{
outlines.push_back(" ");
@@ -467,13 +467,11 @@ Int16 status = ComUser::getAuthNameFromAuthID(objectOwner,username,
output += ".";
output += schemaName.data();
output += " IS '";
- output += objCommentInfo->objectComment;
+ output += objCommentInfo.objectComment;
output += "' ;";
-
- outlines.push_back(output.data());
+ outlines.push_back(output.data());
}
-
}
cmpSBD.switchBackCompiler();
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4bdd4b84/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
index 5fd5794..886c42d 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
@@ -12942,13 +12942,20 @@ TrafDesc *CmpSeabaseDDL::getSeabaseRoutineDescInternal(const NAString &catName,
short CmpSeabaseDDL::getSeabaseObjectComment(Int64 object_uid,
enum ComObjectType object_type,
- ComTdbVirtObjCommentInfo * & comment_info)
+ ComTdbVirtObjCommentInfo & comment_info,
+ CollHeap * heap)
{
Lng32 retcode = 0;
Lng32 cliRC = 0;
char query[4000];
- comment_info = NULL;
+
+ comment_info.objectUid = object_uid;
+ comment_info.objectComment = NULL;
+ comment_info.numColumnComment = 0;
+ comment_info.columnCommentArray = NULL;
+ comment_info.numIndexComment = 0;
+ comment_info.indexCommentArray = NULL;
ExeCliInterface cliInterface(STMTHEAP, NULL, NULL,
CmpCommon::context()->sqlSession()->getParentQid());
@@ -12967,30 +12974,19 @@ short CmpSeabaseDDL::getSeabaseObjectComment(Int64 object_uid,
return -1;
}
- if (objQueue->numEntries() == 1)
+ //We should have only 1 comment for object
+ if (objQueue->numEntries() > 0)
{
objQueue->position();
-
- OutputInfo * vi = (OutputInfo*)objQueue->getNext();
-
- comment_info = new(STMTHEAP) ComTdbVirtObjCommentInfo[1];
- comment_info->objectUid = object_uid;
- comment_info->numColumnComment = 0;
- comment_info->columnCommentArray = NULL;
- comment_info->numIndexComment = 0;
- comment_info->indexCommentArray = NULL;
- comment_info->objectComment = (char*)vi->get(0);
- }
- else
- {
- return -1;
+ OutputInfo * vi = (OutputInfo*)objQueue->getNext();
+ comment_info.objectComment = (char*)vi->get(0);
}
+ //get index comments of table
if (COM_BASE_TABLE_OBJECT == object_type)
{
- //get index comment of table
str_sprintf(query, "select CATALOG_NAME||'.'||SCHEMA_NAME||'.'||OBJECT_NAME, COMMENT "
- "from %s.\"%s\".%s as O, %s.\"%s\".%s as I "
+ "from %s.\"%s\".%s as O, %s.\"%s\".%s as I "
"where I.BASE_TABLE_UID = %ld and O.OBJECT_UID = I.INDEX_UID and O.comment <> '' ;",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_INDEXES,
@@ -13007,23 +13003,14 @@ short CmpSeabaseDDL::getSeabaseObjectComment(Int64 object_uid,
if (indexQueue->numEntries() > 0)
{
- if (NULL == comment_info)
- {
- comment_info = new(STMTHEAP) ComTdbVirtObjCommentInfo[1];
- comment_info->objectUid = object_uid;
- comment_info->objectComment = NULL;
- comment_info->numColumnComment = 0;
- comment_info->columnCommentArray = NULL;
- }
-
- comment_info->numIndexComment = indexQueue->numEntries();
- comment_info->indexCommentArray = new(STMTHEAP) ComTdbVirtIndexCommentInfo[comment_info->numIndexComment];
+ comment_info.numIndexComment = indexQueue->numEntries();
+ comment_info.indexCommentArray = new(heap) ComTdbVirtIndexCommentInfo[comment_info.numIndexComment];
indexQueue->position();
- for (Lng32 idx = 0; idx < comment_info->numIndexComment; idx++)
+ for (Lng32 idx = 0; idx < comment_info.numIndexComment; idx++)
{
OutputInfo * oi = (OutputInfo*)indexQueue->getNext();
- ComTdbVirtIndexCommentInfo &indexComment = comment_info->indexCommentArray[idx];
+ ComTdbVirtIndexCommentInfo &indexComment = comment_info.indexCommentArray[idx];
// get the index full name
indexComment.indexFullName = (char*) oi->get(0);
@@ -13032,9 +13019,9 @@ short CmpSeabaseDDL::getSeabaseObjectComment(Int64 object_uid,
}
}
+ //get column comments of table and view
if (COM_BASE_TABLE_OBJECT == object_type || COM_VIEW_OBJECT == object_type)
{
- //get column comment of table
str_sprintf(query, "select COLUMN_NAME, COMMENT from %s.\"%s\".%s where OBJECT_UID = %ld and comment <> '' order by COLUMN_NUMBER ;",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_COLUMNS, object_uid);
@@ -13049,28 +13036,19 @@ short CmpSeabaseDDL::getSeabaseObjectComment(Int64 object_uid,
if (colQueue->numEntries() > 0)
{
- if (NULL == comment_info)
- {
- comment_info = new(STMTHEAP) ComTdbVirtObjCommentInfo[1];
- comment_info->objectUid = object_uid;
- comment_info->objectComment = NULL;
- comment_info->numIndexComment = 0;
- comment_info->indexCommentArray = NULL;
- }
-
- comment_info->numColumnComment = colQueue->numEntries();
- comment_info->columnCommentArray = new(STMTHEAP) ComTdbVirtColumnCommentInfo[comment_info->numColumnComment];
+ comment_info.numColumnComment = colQueue->numEntries();
+ comment_info.columnCommentArray = new(heap) ComTdbVirtColumnCommentInfo[comment_info.numColumnComment];
colQueue->position();
- for (Lng32 idx = 0; idx < comment_info->numColumnComment; idx++)
- {
- OutputInfo * oi = (OutputInfo*)colQueue->getNext();
- ComTdbVirtColumnCommentInfo &colComment = comment_info->columnCommentArray[idx];
+ for (Lng32 idx = 0; idx < comment_info.numColumnComment; idx++)
+ {
+ OutputInfo * oi = (OutputInfo*)colQueue->getNext();
+ ComTdbVirtColumnCommentInfo &colComment = comment_info.columnCommentArray[idx];
- // get the column name
- colComment.columnName = (char*) oi->get(0);
- colComment.columnComment = (char*) oi->get(1);
- }
+ // get the column name
+ colComment.columnName = (char*) oi->get(0);
+ colComment.columnComment = (char*) oi->get(1);
+ }
}
}
[11/11] incubator-trafodion git commit: Merge [TRAFODION-2803] PR
1288 Add COMMENT ON feature
Posted by db...@apache.org.
Merge [TRAFODION-2803] PR 1288 Add COMMENT ON feature
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/b03aa4fd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/b03aa4fd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/b03aa4fd
Branch: refs/heads/master
Commit: b03aa4fd6ce66f64ef982c6cd633079a8046e19f
Parents: 087bb5d 171b9fb
Author: Dave Birdsall <db...@apache.org>
Authored: Wed Nov 15 18:00:52 2017 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Wed Nov 15 18:00:52 2017 +0000
----------------------------------------------------------------------
core/sql/bin/SqlciErrors.txt | 2 +-
core/sql/comexe/ComTdb.h | 62 ++++
core/sql/common/ComSmallDefs.h | 6 +-
core/sql/common/OperTypeEnum.h | 1 +
core/sql/nskgmake/sqlcomp/Makefile | 1 +
core/sql/optimizer/RelExeUtil.cpp | 13 +-
core/sql/parser/AllStmtDDLCreate.h | 1 +
core/sql/parser/BindStmtDDL.cpp | 56 ++++
core/sql/parser/ElemDDLNode.cpp | 8 +
core/sql/parser/ElemDDLNode.h | 3 +
core/sql/parser/StmtDDLCommentOn.h | 153 ++++++++++
core/sql/parser/StmtDDLCreate.cpp | 49 ++++
core/sql/parser/sqlparser.y | 102 ++++++-
core/sql/parser/ulexer.cpp | 1 +
core/sql/regress/privs1/EXPECTED133 | Bin 27095 -> 27095 bytes
core/sql/regress/privs1/EXPECTED137 | 14 +
core/sql/sqlci/sqlci_lex.ll | 1 +
core/sql/sqlci/sqlci_yacc.y | 2 +
core/sql/sqlcomp/CmpDDLCatErrorCodes.h | 2 +-
core/sql/sqlcomp/CmpDescribe.cpp | 238 +++++++++++++++-
core/sql/sqlcomp/CmpSeabaseDDL.h | 9 +
core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp | 349 +++++++++++++++++++++++
core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp | 20 ++
core/sql/sqlcomp/CmpSeabaseDDLincludes.h | 1 +
core/sql/sqlcomp/CmpSeabaseDDLmd.h | 38 ++-
core/sql/sqlcomp/CmpSeabaseDDLschema.cpp | 43 ++-
core/sql/sqlcomp/CmpSeabaseDDLtable.cpp | 26 +-
core/sql/sqlcomp/CmpSeabaseDDLupgrade.h | 2 +-
core/sql/sqlcomp/CmpSeabaseDDLview.cpp | 27 ++
core/sql/sqlcomp/PrivMgr.cpp | 3 +
core/sql/sqlcomp/PrivMgrDefs.h | 3 +-
31 files changed, 1207 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
[08/11] incubator-trafodion git commit: new COMMENT-ON SQL statement:
review change - undo all MD changes
Posted by db...@apache.org.
new COMMENT-ON SQL statement: review change - undo all MD changes
1. undo all MD changes since we have changed to use TEXT table to store
comments
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/96570c43
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/96570c43
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/96570c43
Branch: refs/heads/master
Commit: 96570c43847c8677a103c526e9b5523193cfbd2c
Parents: a448e8f
Author: eedy <cq...@gmail.com>
Authored: Thu Nov 9 14:46:33 2017 +0800
Committer: eedy <cq...@gmail.com>
Committed: Thu Nov 9 14:46:33 2017 +0800
----------------------------------------------------------------------
core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp | 11 +++++------
core/sql/sqlcomp/CmpSeabaseDDLmd.h | 6 ++----
core/sql/sqlcomp/CmpSeabaseDDLschema.cpp | 2 +-
core/sql/sqlcomp/CmpSeabaseDDLtable.cpp | 8 ++++----
core/sql/sqlcomp/CmpSeabaseDDLupgrade.h | 23 ++++++++---------------
5 files changed, 20 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/96570c43/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
index 299b6c2..70ae917 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
@@ -4563,7 +4563,7 @@ short CmpSeabaseDDL::updateSeabaseMDObjectsTable(
NAString quotedObjName;
ToQuotedString(quotedObjName, NAString(objName), FALSE);
- str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, %ld, '')",
+ str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, %ld )",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
catName, quotedSchName.data(), quotedObjName.data(),
objectTypeLit,
@@ -4754,7 +4754,7 @@ short CmpSeabaseDDL::updateSeabaseMDTable(
ExeCliInterface cqdCliInterface;
cliRC = cqdCliInterface.holdAndSetCQD("ODBC_PROCESS", "ON");
- str_sprintf(buf, "upsert using rowset (max rowset size %d, input rowset size ?, input row max length ?, rowset buffer ?) into %s.\"%s\".%s values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ str_sprintf(buf, "upsert using rowset (max rowset size %d, input rowset size ?, input row max length ?, rowset buffer ?) into %s.\"%s\".%s values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
numCols,
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_COLUMNS);
cliRC = rwrsCliInterface.rwrsPrepare(buf, numCols);
@@ -4887,7 +4887,6 @@ short CmpSeabaseDDL::updateSeabaseMDTable(
AssignColEntry(&rwrsCliInterface, entry++, inputRow, colInfo->paramDirection, firstColOffset);
AssignColEntry(&rwrsCliInterface, entry++, inputRow, (colInfo->isOptional ? COM_YES_LIT : COM_NO_LIT), firstColOffset);
AssignColEntry(&rwrsCliInterface, entry++, inputRow, (char*)&colInfo->colFlags, firstColOffset);
- AssignColEntry(&rwrsCliInterface, entry++, inputRow, (char*)"", firstColOffset);
cliRC = rwrsCliInterface.rwrsExec(inputRow, inputRowLen, &rowsAffected);
if (cliRC < 0)
@@ -4899,7 +4898,7 @@ short CmpSeabaseDDL::updateSeabaseMDTable(
}
else
{
- str_sprintf(buf, "insert into %s.\"%s\".%s values (%ld, '%s', %d, '%s', %d, '%s', %d, %d, %d, %d, %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', %ld, '')",
+ str_sprintf(buf, "insert into %s.\"%s\".%s values (%ld, '%s', %d, '%s', %d, '%s', %d, %d, %d, %d, %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', %ld)",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_COLUMNS,
objUID,
colInfo->colName,
@@ -5122,7 +5121,7 @@ short CmpSeabaseDDL::updateSeabaseMDSPJ(
NAString quotedLibObjName;
ToQuotedString(quotedLibObjName, NAString(libName), FALSE);
- str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, 0, '')",
+ str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, 0 )",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
catName, quotedSchName.data(), quotedLibObjName.data(),
COM_LIBRARY_OBJECT_LIT,
@@ -7797,7 +7796,7 @@ void CmpSeabaseDDL::createSeabaseSequence(StmtDDLCreateSequence * createSequen
ToQuotedString(quotedSeqObjName, seqNamePart, FALSE);
Int32 objOwner = ComUser::getCurrentUser();
- str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, 0, '')",
+ str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, 0)",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
catalogNamePart.data(), quotedSchName.data(), quotedSeqObjName.data(),
COM_SEQUENCE_GENERATOR_OBJECT_LIT,
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/96570c43/core/sql/sqlcomp/CmpSeabaseDDLmd.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLmd.h b/core/sql/sqlcomp/CmpSeabaseDDLmd.h
index 49a5246..9a1e91d 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLmd.h
+++ b/core/sql/sqlcomp/CmpSeabaseDDLmd.h
@@ -115,8 +115,7 @@ static const QString seabaseColumnsDDL[] =
{" hbase_col_qualifier varchar(40) character set iso88591 not null not serialized, "},
{" direction char(2) character set iso88591 not null not serialized, "},
{" is_optional char(2) character set iso88591 not null not serialized, "},
- {" flags largeint not null not serialized, "},
- {" comment VARCHAR(1000) CHARACTER SET UTF8 NOT NULL NOT SERIALIZED "},
+ {" flags largeint not null not serialized "},
{" ) "},
{" primary key (object_uid, column_name) "},
{" attribute hbase format "},
@@ -221,8 +220,7 @@ static const QString seabaseObjectsDDL[] =
{" droppable char(2) character set iso88591 not null not serialized, "},
{" object_owner int not null not serialized, "},
{" schema_owner int not null not serialized, "},
- {" flags largeint not null not serialized, "},
- {" comment VARCHAR(1000) CHARACTER SET UTF8 NOT NULL NOT SERIALIZED "},
+ {" flags largeint not null not serialized "},
{" ) "},
{" primary key (catalog_name, schema_name, object_name, object_type) "},
{" attribute hbase format "},
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/96570c43/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
index 27d2840..4ff11d0 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
@@ -188,7 +188,7 @@ char schemaObjectLit[3] = {0};
}
}
- str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, 0, '')",
+ str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, 0)",
getSystemCatalog(),SEABASE_MD_SCHEMA,SEABASE_OBJECTS,
catalogName.data(), quotedSchName.data(), quotedObjName.data(),
schemaObjectLit,
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/96570c43/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
index ee20ae2..fcc8df1 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
@@ -909,7 +909,7 @@ short CmpSeabaseDDL::updatePKeyInfo(
NAString quotedObjName;
ToQuotedString(quotedObjName, NAString(objectNamePart), FALSE);
- str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, 0, '')",
+ str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, 0)",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
catalogNamePart.data(), quotedSchName.data(), quotedObjName.data(),
COM_PRIMARY_KEY_CONSTRAINT_OBJECT_LIT,
@@ -1315,7 +1315,7 @@ short CmpSeabaseDDL::updateConstraintMD(
NAString quotedObjName;
ToQuotedString(quotedObjName, NAString(objectNamePart), FALSE);
- str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, 0, '')",
+ str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %ld, %ld, %ld, '%s', '%s', %d, %d, 0)",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
catalogNamePart.data(), quotedSchName.data(), quotedObjName.data(),
((ct == COM_UNIQUE_CONSTRAINT) ? COM_UNIQUE_CONSTRAINT_OBJECT_LIT :
@@ -5646,7 +5646,7 @@ void CmpSeabaseDDL::alterSeabaseTableAddColumn(
}
}
- str_sprintf(query, "insert into %s.\"%s\".%s values (%ld, '%s', %d, '%s', %d, '%s', %d, %d, %d, %d, %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%u', '%s', '%s', %ld, '' )",
+ str_sprintf(query, "insert into %s.\"%s\".%s values (%ld, '%s', %d, '%s', %d, '%s', %d, %d, %d, %d, %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%u', '%s', '%s', %ld )",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_COLUMNS,
objUID,
col_name,
@@ -7186,7 +7186,7 @@ short CmpSeabaseDDL::hbaseFormatTableAlterColumnAttr(
goto label_error1;
}
- str_sprintf(buf, "insert into %s.\"%s\".%s select object_uid, '%s', %d, '%s', fs_data_type, sql_data_type, column_size, column_precision, column_scale, datetime_start_field, datetime_end_field, is_upshifted, column_flags, nullable, character_set, default_class, default_value, column_heading, '%s', '%s', direction, is_optional, flags, comment from %s.\"%s\".%s where object_uid = %ld and column_number = (select column_number from %s.\"%s\".%s where object_uid = %ld and column_name = '%s')",
+ str_sprintf(buf, "insert into %s.\"%s\".%s select object_uid, '%s', %d, '%s', fs_data_type, sql_data_type, column_size, column_precision, column_scale, datetime_start_field, datetime_end_field, is_upshifted, column_flags, nullable, character_set, default_class, default_value, column_heading, '%s', '%s', direction, is_optional, flags from %s.\"%s\".%s where object_uid = %ld and column_number = (select column_number from %s.\"%s\".%s where object_uid = %ld and column_name = '%s')",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_COLUMNS,
naCol->getColName().data(),
altColNum,
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/96570c43/core/sql/sqlcomp/CmpSeabaseDDLupgrade.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLupgrade.h b/core/sql/sqlcomp/CmpSeabaseDDLupgrade.h
index 7e963e0..1c3b2ee 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLupgrade.h
+++ b/core/sql/sqlcomp/CmpSeabaseDDLupgrade.h
@@ -226,14 +226,7 @@ static const MDUpgradeInfo allMDupgradeInfo[] = {
seabaseColumnsDDL, sizeof(seabaseColumnsDDL),
NULL, 0,
NULL, 0,
- TRUE,
- "object_uid,column_name,column_number,column_class,fs_data_type,sql_data_type,column_size,column_precision,"
- "column_scale,datetime_start_field,datetime_end_field,is_upshifted,column_flags,nullable,character_set,"
- "default_class,default_value,column_heading,hbase_col_family,hbase_col_qualifier,direction,is_optional,flags,comment" ,
- "object_uid,column_name,column_number,column_class,fs_data_type,sql_data_type,column_size,column_precision,"
- "column_scale,datetime_start_field,datetime_end_field,is_upshifted,column_flags,nullable,character_set,"
- "default_class,default_value,column_heading,hbase_col_family,hbase_col_qualifier,direction,is_optional,flags,''" ,
- NULL, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE},
+ FALSE, NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
{SEABASE_DEFAULTS, SEABASE_DEFAULTS_OLD_MD,
seabaseDefaultsDDL, sizeof(seabaseDefaultsDDL),
@@ -286,13 +279,13 @@ static const MDUpgradeInfo allMDupgradeInfo[] = {
"object_name,"
"object_type,object_uid,"
"create_time,redef_time,valid_def,droppable,object_owner,schema_owner,"
- "flags,comment",
+ "flags",
"catalog_name,schema_name,"
"case when schema_name = '_MD_' then object_name || '_OLD_MD' else object_name end,"
"object_type,object_uid,"
"create_time,redef_time,valid_def,droppable,object_owner,schema_owner,"
- "flags,''",
- NULL, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE},
+ "flags",
+ NULL, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
{SEABASE_OBJECTS_UNIQ_IDX, SEABASE_OBJECTS_UNIQ_IDX_OLD_MD,
seabaseObjectsUniqIdxDDL, sizeof(seabaseObjectsUniqIdxDDL),
@@ -410,8 +403,8 @@ static const MDUpgradeInfo allMDv23tov30TablesInfo[] = {
seabaseOldMDv23ColumnsDDL, sizeof(seabaseOldMDv23ColumnsDDL),
NULL, 0,
TRUE,
- "object_uid, column_name, column_number, column_class, fs_data_type, sql_data_type, column_size, column_precision, column_scale, datetime_start_field, datetime_end_field, is_upshifted, column_flags, nullable, character_set, default_class, default_value, column_heading, hbase_col_family, hbase_col_qualifier, direction, is_optional, flags, comment",
- "object_uid, column_name, column_number, column_class, fs_data_type, '', column_size, column_precision, column_scale, datetime_start_field, datetime_end_field, is_upshifted, column_flags, nullable, character_set, default_class, default_value, column_heading, hbase_col_family, hbase_col_qualifier, direction, is_optional, 0, '' ",
+ "object_uid, column_name, column_number, column_class, fs_data_type, sql_data_type, column_size, column_precision, column_scale, datetime_start_field, datetime_end_field, is_upshifted, column_flags, nullable, character_set, default_class, default_value, column_heading, hbase_col_family, hbase_col_qualifier, direction, is_optional, flags",
+ "object_uid, column_name, column_number, column_class, fs_data_type, '', column_size, column_precision, column_scale, datetime_start_field, datetime_end_field, is_upshifted, column_flags, nullable, character_set, default_class, default_value, column_heading, hbase_col_family, hbase_col_qualifier, direction, is_optional, 0",
NULL, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE},
{SEABASE_DEFAULTS, SEABASE_DEFAULTS_OLD_MD,
@@ -455,8 +448,8 @@ static const MDUpgradeInfo allMDv23tov30TablesInfo[] = {
seabaseOldMDv23ObjectsDDL, sizeof(seabaseOldMDv23ObjectsDDL),
NULL, 0,
TRUE,
- "catalog_name, schema_name, object_name, object_type, object_uid, create_time, redef_time, valid_def, droppable, object_owner, schema_owner, flags, comment",
- "catalog_name, schema_name, case when schema_name = '_MD_' then object_name || '_OLD_MD' else object_name end, object_type, object_uid, create_time, redef_time, valid_def, 'N', object_owner, " SUPER_USER_LIT", 0, ''",
+ "catalog_name, schema_name, object_name, object_type, object_uid, create_time, redef_time, valid_def, droppable, object_owner, schema_owner, flags",
+ "catalog_name, schema_name, case when schema_name = '_MD_' then object_name || '_OLD_MD' else object_name end, object_type, object_uid, create_time, redef_time, valid_def, 'N', object_owner, " SUPER_USER_LIT", 0",
NULL, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE},
{SEABASE_OBJECTS_UNIQ_IDX, SEABASE_OBJECTS_UNIQ_IDX_OLD_MD,
[09/11] incubator-trafodion git commit: new COMMENT-ON SQL statement:
review change - fix a error in new build-in view
Posted by db...@apache.org.
new COMMENT-ON SQL statement: review change - fix a error in new build-in view
1. fix a error in new build-in view
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/6af42567
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/6af42567
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/6af42567
Branch: refs/heads/master
Commit: 6af42567b9c6d53937fa735f162da4833dee8896
Parents: 96570c4
Author: eedy <cq...@gmail.com>
Authored: Fri Nov 10 09:51:00 2017 +0800
Committer: eedy <cq...@gmail.com>
Committed: Fri Nov 10 09:51:00 2017 +0800
----------------------------------------------------------------------
core/sql/sqlcomp/CmpSeabaseDDLmd.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6af42567/core/sql/sqlcomp/CmpSeabaseDDLmd.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLmd.h b/core/sql/sqlcomp/CmpSeabaseDDLmd.h
index 9a1e91d..3ca7e78 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLmd.h
+++ b/core/sql/sqlcomp/CmpSeabaseDDLmd.h
@@ -1712,7 +1712,7 @@ static const QString createTrafColumnCommentViewQuery[] =
{" create view %s.\"%s\"."TRAF_COLUMN_COMMENT_VIEW" as "},
{" select O.CATALOG_NAME, O.SCHEMA_NAME, O.OBJECT_NAME, C.COLUMN_NAME, T.TEXT as COMMENT "},
{" from %s.\"%s\".\"%s\" as O, %s.\"%s\".\"%s\" as C, %s.\"%s\".\"%s\" as T "},
- {" where O.OBJECT_UID = C.OBJECT_UID and T.TEXT_UID = O.OBJECT_UID and T.TEXT_TYPE = %s "},
+ {" where O.OBJECT_UID = C.OBJECT_UID and T.TEXT_UID = O.OBJECT_UID and T.TEXT_TYPE = %s and T.SUB_ID = C.COLUMN_NUMBER "},
{" order by O.OBJECT_UID, C.COLUMN_NUMBER "},
{" ; "}
};
[10/11] incubator-trafodion git commit: new COMMENT-ON SQL statement:
review change - error path
Posted by db...@apache.org.
new COMMENT-ON SQL statement: review change - error path
1. switch compile context in comment-on error path
2. correct spellings and others
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/171b9fb2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/171b9fb2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/171b9fb2
Branch: refs/heads/master
Commit: 171b9fb2a6c94d3fbc09d54927d443768b63dfb9
Parents: 6af4256
Author: eedy <cq...@gmail.com>
Authored: Tue Nov 14 14:41:41 2017 +0800
Committer: eedy <cq...@gmail.com>
Committed: Tue Nov 14 14:41:41 2017 +0800
----------------------------------------------------------------------
core/sql/common/ComSmallDefs.h | 2 +-
core/sql/parser/StmtDDLCommentOn.h | 2 +-
core/sql/parser/sqlparser.y | 7 -------
core/sql/sqlcomp/CmpDescribe.cpp | 5 +++++
core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp | 6 +++---
core/sql/sqlcomp/CmpSeabaseDDLschema.cpp | 1 +
core/sql/sqlcomp/CmpSeabaseDDLview.cpp | 2 +-
7 files changed, 12 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/171b9fb2/core/sql/common/ComSmallDefs.h
----------------------------------------------------------------------
diff --git a/core/sql/common/ComSmallDefs.h b/core/sql/common/ComSmallDefs.h
index 1d5a15f..3e25a79 100644
--- a/core/sql/common/ComSmallDefs.h
+++ b/core/sql/common/ComSmallDefs.h
@@ -663,7 +663,7 @@ enum ComTextType {COM_VIEW_TEXT = 0,
COM_HBASE_SPLIT_TEXT = 6,
COM_STORED_DESC_TEXT = 7,
COM_VIEW_REF_COLS_TEXT = 8,
- COM_OBJET_COMMENT_TEXT = COM_TABLE_COMMENT_TEXT,
+ COM_OBJECT_COMMENT_TEXT = COM_TABLE_COMMENT_TEXT,
COM_COLUMN_COMMENT_TEXT = 9
};
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/171b9fb2/core/sql/parser/StmtDDLCommentOn.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLCommentOn.h b/core/sql/parser/StmtDDLCommentOn.h
index 9b31b26..adf64bb 100644
--- a/core/sql/parser/StmtDDLCommentOn.h
+++ b/core/sql/parser/StmtDDLCommentOn.h
@@ -57,7 +57,7 @@ class StmtDDLCommentOn : public StmtDDLNode
public:
enum COMMENT_ON_TYPES {
- COMMENT_ON_TYPE_TABLE = 10,
+ COMMENT_ON_TYPE_TABLE,
COMMENT_ON_TYPE_COLUMN,
COMMENT_ON_TYPE_SCHEMA,
COMMENT_ON_TYPE_VIEW,
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/171b9fb2/core/sql/parser/sqlparser.y
----------------------------------------------------------------------
diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y
index df4cc2e..9e16c20 100755
--- a/core/sql/parser/sqlparser.y
+++ b/core/sql/parser/sqlparser.y
@@ -33190,12 +33190,6 @@ comment_on_statement : TOK_COMMENT TOK_ON comment_on_object_types ddl_qualified_
}
| TOK_COMMENT TOK_ON TOK_SCHEMA schema_name TOK_IS QUOTED_STRING
{
- // EJF L4J - CQD dynamic are not allowed in Compound Statements
- if (beginsWith(SQLTEXT(),"BEGIN")) {
- *SqlParser_Diags << DgSqlCode(-3175);
- YYERROR;
- }
- else { // business as usual
NAString tmpSchema($4->getSchemaNameAsAnsiString());
if (! validateVolatileSchemaName(tmpSchema))
@@ -33210,7 +33204,6 @@ comment_on_statement : TOK_COMMENT TOK_ON comment_on_object_types ddl_qualified_
PARSERHEAP());
$$ = pNode;
- }
}
| TOK_COMMENT TOK_ON TOK_COLUMN qualified_name TOK_IS QUOTED_STRING
{
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/171b9fb2/core/sql/sqlcomp/CmpDescribe.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpDescribe.cpp b/core/sql/sqlcomp/CmpDescribe.cpp
index b4b1d4e..28590f4 100644
--- a/core/sql/sqlcomp/CmpDescribe.cpp
+++ b/core/sql/sqlcomp/CmpDescribe.cpp
@@ -3074,6 +3074,7 @@ short CmpDescribeSeabaseTable (
if (cmpSBD.getSeabaseObjectComment(objectUID, COM_VIEW_OBJECT, objCommentInfo, heap))
{
*CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+ cmpSBD.switchBackCompiler();
return -1;
}
@@ -3846,6 +3847,7 @@ short CmpDescribeSeabaseTable (
if (cmpSBD.getSeabaseObjectComment(objectUID, objType, objCommentInfo, heap))
{
*CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+ cmpSBD.switchBackCompiler();
return -1;
}
@@ -4029,6 +4031,7 @@ short CmpDescribeSequence(
if (cmpSBD.getSeabaseObjectComment(objectUID, COM_SEQUENCE_GENERATOR_OBJECT, objCommentInfo, heap))
{
*CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+ cmpSBD.switchBackCompiler();
return -1;
}
@@ -4293,6 +4296,7 @@ char buf[1000];
if (cmpSBD.getSeabaseObjectComment(libraryUID, COM_LIBRARY_OBJECT, objCommentInfo, heap))
{
*CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+ cmpSBD.switchBackCompiler();
return -1;
}
@@ -4838,6 +4842,7 @@ short CmpDescribeRoutine (const CorrName & cn,
if (cmpSBD.getSeabaseObjectComment(routineUID, COM_USER_DEFINED_ROUTINE_OBJECT, objCommentInfo, heap))
{
*CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+ cmpSBD.switchBackCompiler();
return -1;
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/171b9fb2/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp
index f9197e3..7622bd8 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp
@@ -89,7 +89,7 @@ short CmpSeabaseDDL::getSeabaseObjectComment(Int64 object_uid,
//get object comment
sprintf(query, "select TEXT from %s.\"%s\".%s where TEXT_UID = %ld and TEXT_TYPE = %d and SUB_ID = %d ; ",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_TEXT,
- object_uid, COM_OBJET_COMMENT_TEXT, 0);
+ object_uid, COM_OBJECT_COMMENT_TEXT, 0);
Queue * objQueue = NULL;
cliRC = cliInterface.fetchAllRows(objQueue, query, 0, FALSE, FALSE, TRUE);
@@ -119,7 +119,7 @@ short CmpSeabaseDDL::getSeabaseObjectComment(Int64 object_uid,
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_TEXT,
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_INDEXES,
- object_uid, COM_OBJET_COMMENT_TEXT, 0);
+ object_uid, COM_OBJECT_COMMENT_TEXT, 0);
Queue * indexQueue = NULL;
cliRC = cliInterface.fetchAllRows(indexQueue, query, 0, FALSE, FALSE, TRUE);
@@ -299,7 +299,7 @@ void CmpSeabaseDDL::doSeabaseCommentOn(StmtDDLCommentOn *commentOnNode,
}
// add, remove, change comment of object/column
- enum ComTextType textType = COM_OBJET_COMMENT_TEXT;
+ enum ComTextType textType = COM_OBJECT_COMMENT_TEXT;
Lng32 subID = 0;
if (StmtDDLCommentOn::COMMENT_ON_TYPE_COLUMN == commentObjectType)
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/171b9fb2/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
index 4ff11d0..d2f0c89 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
@@ -459,6 +459,7 @@ Int16 status = ComUser::getAuthNameFromAuthID(objectOwner,username,
if (cmpSBD.getSeabaseObjectComment(schemaUID, objectType, objCommentInfo, STMTHEAP))
{
*CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+ cmpSBD.switchBackCompiler();
return -1;
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/171b9fb2/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLview.cpp b/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
index a9f353c..7178fd1 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
@@ -1502,7 +1502,7 @@ short CmpSeabaseDDL::createMetadataViews(ExeCliInterface * cliInterface)
param_[5] = getSystemCatalog();
param_[6] = SEABASE_MD_SCHEMA;
param_[7] = SEABASE_TEXT;
- param_[8] = "3";//COM_OBJET_COMMENT_TEXT
+ param_[8] = "3";//COM_OBJECT_COMMENT_TEXT
}
else if (strcmp(mdi.viewName, TRAF_COLUMN_COMMENT_VIEW) == 0)
{
[07/11] incubator-trafodion git commit: new COMMENT-ON SQL statement:
review change - TEXT table modification
Posted by db...@apache.org.
new COMMENT-ON SQL statement: review change - TEXT table modification
1. mv storage of COMMENTs in TEXT table
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/a448e8f8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/a448e8f8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/a448e8f8
Branch: refs/heads/master
Commit: a448e8f831f2dd84daf1758c332d074e71075486
Parents: 0b7e3a3
Author: eedy <cq...@gmail.com>
Authored: Thu Nov 9 12:00:29 2017 +0800
Committer: eedy <cq...@gmail.com>
Committed: Thu Nov 9 12:00:29 2017 +0800
----------------------------------------------------------------------
core/sql/common/ComSmallDefs.h | 6 +-
core/sql/optimizer/RelExeUtil.cpp | 2 +-
core/sql/parser/BindStmtDDL.cpp | 4 +-
core/sql/parser/StmtDDLCommentOn.h | 2 +
core/sql/parser/StmtDDLCreate.cpp | 6 +-
core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp | 90 ++++++++++++++++--------
core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp | 13 ++++
core/sql/sqlcomp/CmpSeabaseDDLmd.h | 16 +++--
core/sql/sqlcomp/CmpSeabaseDDLschema.cpp | 13 +++-
core/sql/sqlcomp/CmpSeabaseDDLtable.cpp | 18 ++++-
core/sql/sqlcomp/CmpSeabaseDDLview.cpp | 8 +++
11 files changed, 132 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a448e8f8/core/sql/common/ComSmallDefs.h
----------------------------------------------------------------------
diff --git a/core/sql/common/ComSmallDefs.h b/core/sql/common/ComSmallDefs.h
index 77914e9..1d5a15f 100644
--- a/core/sql/common/ComSmallDefs.h
+++ b/core/sql/common/ComSmallDefs.h
@@ -591,6 +591,8 @@ enum ComClusteringScheme { COM_UNKNOWN_CLUSTERING
#define COM_MAXIMUM_NUMBER_OF_COLUMNS 20000
#define COM_DIV_EXPR_BASE_TEXT_SUBID 20000
+#define COM_MAXIMUM_LENGTH_OF_COMMENT 1000
+
enum ComColumnClass { COM_UNKNOWN_CLASS
, COM_SYSTEM_COLUMN
, COM_USER_COLUMN
@@ -660,7 +662,9 @@ enum ComTextType {COM_VIEW_TEXT = 0,
COM_HBASE_COL_FAMILY_TEXT = 5,
COM_HBASE_SPLIT_TEXT = 6,
COM_STORED_DESC_TEXT = 7,
- COM_VIEW_REF_COLS_TEXT = 8
+ COM_VIEW_REF_COLS_TEXT = 8,
+ COM_OBJET_COMMENT_TEXT = COM_TABLE_COMMENT_TEXT,
+ COM_COLUMN_COMMENT_TEXT = 9
};
enum ComColumnDirection { COM_UNKNOWN_DIRECTION
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a448e8f8/core/sql/optimizer/RelExeUtil.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelExeUtil.cpp b/core/sql/optimizer/RelExeUtil.cpp
index 71c0421..5d143a2 100644
--- a/core/sql/optimizer/RelExeUtil.cpp
+++ b/core/sql/optimizer/RelExeUtil.cpp
@@ -4599,7 +4599,7 @@ RelExpr * DDLExpr::bindNode(BindWA *bindWA)
return NULL;
}
- if (isRegister)
+ if (isRegister || isCommentOn)
{
isHbase_ = TRUE;
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a448e8f8/core/sql/parser/BindStmtDDL.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/BindStmtDDL.cpp b/core/sql/parser/BindStmtDDL.cpp
index 2294b45..a58dcd7 100644
--- a/core/sql/parser/BindStmtDDL.cpp
+++ b/core/sql/parser/BindStmtDDL.cpp
@@ -2611,8 +2611,6 @@ StmtDDLCommentOn::bindNode(BindWA * pBindWA)
return this;
}
- isViewCol_ = (naTable->getViewText() ? TRUE : FALSE);
-
const NAColumnArray &nacolArr = naTable->getNAColumnArray();
const NAColumn * nacol = nacolArr.getColumn(getColName());
if (! nacol)
@@ -2624,6 +2622,8 @@ StmtDDLCommentOn::bindNode(BindWA * pBindWA)
return this;
}
+ isViewCol_ = (naTable->getViewText() ? TRUE : FALSE);
+ colNum_ = nacol->getPosition();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a448e8f8/core/sql/parser/StmtDDLCommentOn.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLCommentOn.h b/core/sql/parser/StmtDDLCommentOn.h
index 57b3542..9b31b26 100644
--- a/core/sql/parser/StmtDDLCommentOn.h
+++ b/core/sql/parser/StmtDDLCommentOn.h
@@ -102,6 +102,7 @@ public:
inline const NAString &getComment() const { return comment_; }
inline const NAString &getColName() const { return colRef_->getColRefNameObj().getColName(); }
inline NABoolean getIsViewCol() { return isViewCol_; }
+ inline Lng32 getColNum() { return colNum_; }
inline Int32 getVersion() {return 1;}
@@ -120,6 +121,7 @@ private:
QualifiedName objectName_;
ColReference * colRef_;
NABoolean isViewCol_;
+ Lng32 colNum_;
const NAString & comment_;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a448e8f8/core/sql/parser/StmtDDLCreate.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLCreate.cpp b/core/sql/parser/StmtDDLCreate.cpp
index ff39634..72d014e 100644
--- a/core/sql/parser/StmtDDLCreate.cpp
+++ b/core/sql/parser/StmtDDLCreate.cpp
@@ -7180,7 +7180,8 @@ StmtDDLCommentOn::StmtDDLCommentOn(COMMENT_ON_TYPES objType, const QualifiedName
objectName_(objName, heap),
comment_(commentStr),
colRef_(NULL),
- isViewCol_(FALSE)
+ isViewCol_(FALSE),
+ colNum_(0)
{
}
@@ -7192,7 +7193,8 @@ StmtDDLCommentOn::StmtDDLCommentOn(COMMENT_ON_TYPES objType, const QualifiedName
objectName_(objName, heap),
colRef_(colRef),
comment_(commentStr),
- isViewCol_(FALSE)
+ isViewCol_(FALSE),
+ colNum_(0)
{
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a448e8f8/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp
index 1e5e294..f9197e3 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp
@@ -87,9 +87,9 @@ short CmpSeabaseDDL::getSeabaseObjectComment(Int64 object_uid,
CmpCommon::context()->sqlSession()->getParentQid());
//get object comment
- sprintf(query, "select comment from %s.\"%s\".%s where object_uid = %ld and object_type = '%s' and comment <> '' ;",
- getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
- object_uid, comObjectTypeLit(object_type));
+ sprintf(query, "select TEXT from %s.\"%s\".%s where TEXT_UID = %ld and TEXT_TYPE = %d and SUB_ID = %d ; ",
+ getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_TEXT,
+ object_uid, COM_OBJET_COMMENT_TEXT, 0);
Queue * objQueue = NULL;
cliRC = cliInterface.fetchAllRows(objQueue, query, 0, FALSE, FALSE, TRUE);
@@ -111,12 +111,15 @@ short CmpSeabaseDDL::getSeabaseObjectComment(Int64 object_uid,
//get index comments of table
if (COM_BASE_TABLE_OBJECT == object_type)
{
- sprintf(query, "select CATALOG_NAME||'.'||SCHEMA_NAME||'.'||OBJECT_NAME, COMMENT "
- "from %s.\"%s\".%s as O, %s.\"%s\".%s as I "
- "where I.BASE_TABLE_UID = %ld and O.OBJECT_UID = I.INDEX_UID and O.comment <> '' ;",
- getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
- getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_INDEXES,
- object_uid);
+ sprintf(query, "select O.CATALOG_NAME||'.'||O.SCHEMA_NAME||'.'||O.OBJECT_NAME as INDEX_QUAL, T.TEXT "
+ "from %s.\"%s\".%s as O, %s.\"%s\".%s as T, %s.\"%s\".%s as I "
+ "where I.BASE_TABLE_UID = %ld and O.OBJECT_UID = I.INDEX_UID and T.TEXT_UID = O.OBJECT_UID "
+ " and T.TEXT_TYPE = %d and SUB_ID = %d "
+ "order by INDEX_QUAL ; ",
+ getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
+ getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_TEXT,
+ getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_INDEXES,
+ object_uid, COM_OBJET_COMMENT_TEXT, 0);
Queue * indexQueue = NULL;
cliRC = cliInterface.fetchAllRows(indexQueue, query, 0, FALSE, FALSE, TRUE);
@@ -148,8 +151,12 @@ short CmpSeabaseDDL::getSeabaseObjectComment(Int64 object_uid,
//get column comments of table and view
if (COM_BASE_TABLE_OBJECT == object_type || COM_VIEW_OBJECT == object_type)
{
- sprintf(query, "select COLUMN_NAME, COMMENT from %s.\"%s\".%s where OBJECT_UID = %ld and comment <> '' order by COLUMN_NUMBER ;",
- getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_COLUMNS, object_uid);
+ sprintf(query, "select C.COLUMN_NAME, T.TEXT from %s.\"%s\".%s as C, %s.\"%s\".%s as T "
+ "where C.OBJECT_UID = %ld and T.TEXT_UID = C.OBJECT_UID and T.TEXT_TYPE = %d and C.COLUMN_NUMBER = T.SUB_ID "
+ "order by C.COLUMN_NUMBER ; ",
+ getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_COLUMNS,
+ getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_TEXT,
+ object_uid, COM_COLUMN_COMMENT_TEXT);
Queue * colQueue = NULL;
cliRC = cliInterface.fetchAllRows(colQueue, query, 0, FALSE, FALSE, TRUE);
@@ -281,33 +288,32 @@ void CmpSeabaseDDL::doSeabaseCommentOn(StmtDDLCommentOn *commentOnNode,
return;
}
- //check for overflow, but how i can get type size of COMMENT column?
+
+ //check for overflow
+ NAString & comment = (NAString &) commentOnNode->getComment();
+ if (comment.length() > COM_MAXIMUM_LENGTH_OF_COMMENT)
+ {
+ *CmpCommon::diags() << DgSqlCode(-8402);
+ processReturn ();
+ return;
+ }
// add, remove, change comment of object/column
- const NAString & comment = commentOnNode->getComment();
- char * query = new(STMTHEAP) char[comment.length()+1024];
+ enum ComTextType textType = COM_OBJET_COMMENT_TEXT;
+ Lng32 subID = 0;
if (StmtDDLCommentOn::COMMENT_ON_TYPE_COLUMN == commentObjectType)
{
- sprintf(query, "update %s.\"%s\".%s set comment = '%s' where object_uid = %ld and column_name = '%s' ",
- getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_COLUMNS,
- comment.data(),
- objUID,
- commentOnNode->getColName().data()
- );
- cliRC = cliInterface.executeImmediate(query);
- }
- else
- {
- sprintf(query, "update %s.\"%s\".%s set comment = '%s' where catalog_name = '%s' and schema_name = '%s' and object_name = '%s' and object_type = '%s' ",
- getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
- comment.data(),
- catalogNamePart.data(), schemaNamePart.data(), objNamePart.data(),
- comObjectTypeLit(enMDObjType));
- cliRC = cliInterface.executeImmediate(query);
+ textType = COM_COLUMN_COMMENT_TEXT;
+ subID = commentOnNode->getColNum();
}
- NADELETEBASIC(query, STMTHEAP);
+ /* Not using function updateTextTable(), because can not insert Chinese properly by function updateTextTable().
+ * For storing COMMENT in TEXT table is a temp solution, so updating TEXT table directly here.
+ * Will change this implementation until next upgrade of MD.
+ */
+ //like function updateTextTable(), delete entry first
+ cliRC = deleteFromTextTable(&cliInterface, objUID, textType, subID);
if (cliRC < 0)
{
cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
@@ -315,6 +321,28 @@ void CmpSeabaseDDL::doSeabaseCommentOn(StmtDDLCommentOn *commentOnNode,
return;
}
+ if (comment.length() > 0)
+ {
+ //add or modify comment
+ char query[2048];
+
+ str_sprintf(query, "insert into %s.\"%s\".%s values (%ld, %d, %d, %d, 0, '%s') ; ",
+ getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_TEXT,
+ objUID,
+ textType,
+ subID,
+ 0,
+ comment.data());
+ cliRC = cliInterface.executeImmediate(query);
+
+ if (cliRC < 0)
+ {
+ cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
+ processReturn();
+ return;
+ }
+ }
+
processReturn();
return;
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a448e8f8/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
index c23a180..299b6c2 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
@@ -5277,6 +5277,19 @@ short CmpSeabaseDDL::deleteFromSeabaseMDTable(
cliInterface->retrieveSQLDiagnostics(CmpCommon::diags());
return -1;
}
+
+ // delete comment from TEXT table for library
+ str_sprintf(buf, "delete from %s.\"%s\".%s where text_uid = %ld",
+ getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_TEXT,
+ objUID);
+ cliRC = cliInterface->executeImmediate(buf);
+ if (cliRC < 0)
+ {
+ cliInterface->retrieveSQLDiagnostics(CmpCommon::diags());
+
+ return -1;
+ }
+
return 0; // nothing else to do for libraries
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a448e8f8/core/sql/sqlcomp/CmpSeabaseDDLmd.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLmd.h b/core/sql/sqlcomp/CmpSeabaseDDLmd.h
index fdaa99b..49a5246 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLmd.h
+++ b/core/sql/sqlcomp/CmpSeabaseDDLmd.h
@@ -1698,24 +1698,28 @@ static const QString createTrafViewsViewQuery[] =
{" ; "}
};
+
static const QString createTrafObjectCommentViewQuery[] =
{
{" create view %s.\"%s\"."TRAF_OBJECT_COMMENT_VIEW" as "},
- {" select catalog_name, schema_name, object_name, comment "},
- {" from %s.\"%s\".\"%s\" "},
- {" where COMMENT <> '' "},
+ {" select O.catalog_name, O.schema_name, O.object_name, T.text as comment "},
+ {" from %s.\"%s\".\"%s\" as O, %s.\"%s\".\"%s\" as T "},
+ {" where O.object_uid = T.text_uid and T.text_type = %s "},
+ {" order by O.OBJECT_UID "},
{" ; "}
};
static const QString createTrafColumnCommentViewQuery[] =
{
{" create view %s.\"%s\"."TRAF_COLUMN_COMMENT_VIEW" as "},
- {" select O.CATALOG_NAME, O.SCHEMA_NAME, O.OBJECT_NAME, C.COLUMN_NAME, C.COMMENT "},
- {" from %s.\"%s\".\"%s\" as O, %s.\"%s\".\"%s\" as C "},
- {" where O.OBJECT_UID = C.OBJECT_UID and C.COMMENT <> '' "},
+ {" select O.CATALOG_NAME, O.SCHEMA_NAME, O.OBJECT_NAME, C.COLUMN_NAME, T.TEXT as COMMENT "},
+ {" from %s.\"%s\".\"%s\" as O, %s.\"%s\".\"%s\" as C, %s.\"%s\".\"%s\" as T "},
+ {" where O.OBJECT_UID = C.OBJECT_UID and T.TEXT_UID = O.OBJECT_UID and T.TEXT_TYPE = %s "},
+ {" order by O.OBJECT_UID, C.COLUMN_NUMBER "},
{" ; "}
};
+
struct MDViewInfo
{
const char * viewName;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a448e8f8/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
index 45736b0..27d2840 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
@@ -1015,7 +1015,18 @@ void CmpSeabaseDDL::dropSeabaseSchema(StmtDDLDropSchema * dropSchemaNode)
<< DgString0(reason);
goto label_error;
}
-
+
+ //Drop comment in TEXT table for schema
+ str_sprintf(buf, "delete from %s.\"%s\".%s where text_uid = %ld",
+ getSystemCatalog(),SEABASE_MD_SCHEMA,SEABASE_TEXT,
+ schemaUID);
+ cliRC = cliInterface.executeImmediate(buf);
+ if (cliRC < 0)
+ {
+ cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
+ goto label_error;
+ }
+
// Everything succeeded, return
return;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a448e8f8/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
index 83abc38..ee20ae2 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
@@ -5840,11 +5840,25 @@ short CmpSeabaseDDL::updateMDforDropCol(ExeCliInterface &cliInterface,
cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
return -1;
}
-
- str_sprintf(buf, "update %s.\"%s\".%s set sub_id = sub_id - 1 where text_uid = %ld and text_type = %d and sub_id > %d",
+
+ //delete comment in TEXT table for column
+ str_sprintf(buf, "delete from %s.\"%s\".%s where text_uid = %ld and text_type = %d and sub_id = %d ",
+ getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_TEXT,
+ objUID,
+ COM_COLUMN_COMMENT_TEXT,
+ dropColNum);
+ cliRC = cliInterface.executeImmediate(buf);
+ if (cliRC < 0)
+ {
+ cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
+ return -1;
+ }
+
+ str_sprintf(buf, "update %s.\"%s\".%s set sub_id = sub_id - 1 where text_uid = %ld and ( text_type = %d or text_type = %d ) and sub_id > %d",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_TEXT,
objUID,
COM_COMPUTED_COL_TEXT,
+ COM_COLUMN_COMMENT_TEXT,
dropColNum);
cliRC = cliInterface.executeImmediate(buf);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a448e8f8/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLview.cpp b/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
index 587c666..a9f353c 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
@@ -1499,6 +1499,10 @@ short CmpSeabaseDDL::createMetadataViews(ExeCliInterface * cliInterface)
param_[2] = getSystemCatalog();
param_[3] = SEABASE_MD_SCHEMA;
param_[4] = SEABASE_OBJECTS;
+ param_[5] = getSystemCatalog();
+ param_[6] = SEABASE_MD_SCHEMA;
+ param_[7] = SEABASE_TEXT;
+ param_[8] = "3";//COM_OBJET_COMMENT_TEXT
}
else if (strcmp(mdi.viewName, TRAF_COLUMN_COMMENT_VIEW) == 0)
{
@@ -1510,6 +1514,10 @@ short CmpSeabaseDDL::createMetadataViews(ExeCliInterface * cliInterface)
param_[5] = getSystemCatalog();
param_[6] = SEABASE_MD_SCHEMA;
param_[7] = SEABASE_COLUMNS;
+ param_[8] = getSystemCatalog();
+ param_[9] = SEABASE_MD_SCHEMA;
+ param_[10] = SEABASE_TEXT;
+ param_[11] = "9";//COM_COLUMN_COMMENT_TEXT
}
else
{