[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-15 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/incubator-trafodion/pull/1288


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-13 Thread EEDY
Github user EEDY commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r150739956
  
--- Diff: core/sql/sqlcomp/CmpDescribe.cpp ---
@@ -3059,6 +3061,54 @@ short CmpDescribeSeabaseTable (
 
   outputLongLine(*space, viewtext, 0);
 
+  //display comment for VIEW
+  if (objectUID > 0)
+{
+  if (cmpSBD.switchCompiler())
+{
+  *CmpCommon::diags() << 
DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+  return -1;
+}
+
+  ComTdbVirtObjCommentInfo objCommentInfo;
+  if (cmpSBD.getSeabaseObjectComment(objectUID, COM_VIEW_OBJECT, 
objCommentInfo, heap))
+{
+  *CmpCommon::diags() << 
DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+  return -1;
--- End diff --

Yes, we should.
I will add compiler switch-back for all these error paths.


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-13 Thread EEDY
Github user EEDY commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r150739473
  
--- Diff: core/sql/parser/sqlparser.y ---
@@ -33167,7 +33173,106 @@ 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
--- End diff --

No, i do not want to disallow COMMENT ON within a compound statement.
I will remove this comment and if branch.


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-13 Thread EEDY
Github user EEDY commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r150739440
  
--- Diff: core/sql/common/ComSmallDefs.h ---
@@ -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,
--- End diff --

Yes, it should be COM_OBJECT_COMMENT_TEXT.


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-13 Thread DaveBirdsall
Github user DaveBirdsall commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r150693464
  
--- Diff: core/sql/sqlcomp/CmpDescribe.cpp ---
@@ -4129,6 +4280,37 @@ 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;
+ if (cmpSBD.getSeabaseObjectComment(libraryUID, COM_LIBRARY_OBJECT, 
objCommentInfo, heap))
+   {
+ *CmpCommon::diags() << 
DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+ return -1;
--- End diff --

Switch back compiler here?


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-13 Thread DaveBirdsall
Github user DaveBirdsall commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r150690560
  
--- Diff: core/sql/common/ComSmallDefs.h ---
@@ -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,
--- End diff --

Did you mean, COM_OBJECT_COMMENT_TEXT?


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-13 Thread DaveBirdsall
Github user DaveBirdsall commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r150693110
  
--- Diff: core/sql/sqlcomp/CmpDescribe.cpp ---
@@ -3059,6 +3061,54 @@ short CmpDescribeSeabaseTable (
 
   outputLongLine(*space, viewtext, 0);
 
+  //display comment for VIEW
+  if (objectUID > 0)
+{
+  if (cmpSBD.switchCompiler())
+{
+  *CmpCommon::diags() << 
DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+  return -1;
+}
+
+  ComTdbVirtObjCommentInfo objCommentInfo;
+  if (cmpSBD.getSeabaseObjectComment(objectUID, COM_VIEW_OBJECT, 
objCommentInfo, heap))
+{
+  *CmpCommon::diags() << 
DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+  return -1;
--- End diff --

Should we switch the compiler back when going through this error path?


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-13 Thread DaveBirdsall
Github user DaveBirdsall commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r150694388
  
--- Diff: core/sql/sqlcomp/CmpSeabaseDDLschema.cpp ---
@@ -445,14 +445,39 @@ Int16 status = 
ComUser::getAuthNameFromAuthID(objectOwner,username,
output += catalogName.data();
output += "\".\"";
output += schemaName.data();
-   
+
 // AUTHORIZATION clause is rarely used, but include it for replay.
output += "\" AUTHORIZATION \"";
output += username;
output += "\";";

outlines.push_back(output.data());
 
+   // Display Comment of schema
+{
+  ComTdbVirtObjCommentInfo objCommentInfo;
+  if (cmpSBD.getSeabaseObjectComment(schemaUID, objectType, 
objCommentInfo, STMTHEAP))
+{
+  *CmpCommon::diags() << 
DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+  return -1;
--- End diff --

Switch back compiler here?


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-13 Thread DaveBirdsall
Github user DaveBirdsall commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r150693531
  
--- Diff: core/sql/sqlcomp/CmpDescribe.cpp ---
@@ -4634,12 +4816,49 @@ 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;
+  if (cmpSBD.getSeabaseObjectComment(routineUID, 
COM_USER_DEFINED_ROUTINE_OBJECT, objCommentInfo, heap))
+{
+  *CmpCommon::diags() << 
DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+  return -1;
--- End diff --

Switch back compiler here?


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-13 Thread DaveBirdsall
Github user DaveBirdsall commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r150693272
  
--- Diff: core/sql/sqlcomp/CmpDescribe.cpp ---
@@ -3777,6 +3826,76 @@ 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_COMMENTS);
+  return -1;
+}
+ 
+  ComTdbVirtObjCommentInfo objCommentInfo;
+  if (cmpSBD.getSeabaseObjectComment(objectUID, objType, 
objCommentInfo, heap))
+{
+  *CmpCommon::diags() << 
DgSqlCode(-CAT_UNABLE_TO_RETRIEVE_COMMENTS);
+  return -1;
--- End diff --

Should we switch back compiler if we go through this error path?


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-13 Thread DaveBirdsall
Github user DaveBirdsall commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r150693830
  
--- Diff: core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp ---
@@ -0,0 +1,349 @@
+/**
+// @@@ 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"
+
+
+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 TEXT from %s.\"%s\".%s where TEXT_UID = %ld and 
TEXT_TYPE = %d and SUB_ID = %d ; ",
--- End diff --

Ah, you decided to keep the comment text in the TEXT table. That's a good 
idea; you don't need to add columns to OBJECTS or COLUMNS that way, reducing 
the work for metadata upgrade.


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-13 Thread DaveBirdsall
Github user DaveBirdsall commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r150691328
  
--- Diff: core/sql/parser/StmtDDLCommentOn.h ---
@@ -0,0 +1,153 @@
+/**
+// @@@ 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,
--- End diff --

I am curious: why do we start at 10? Is there another enum that this one 
has to co-exist with? If so, would be good to mention that in a comment here 
(in case the other enum expands some day).


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-13 Thread DaveBirdsall
Github user DaveBirdsall commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r150692372
  
--- Diff: core/sql/parser/sqlparser.y ---
@@ -33167,7 +33173,106 @@ 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
--- End diff --

The comment is incorrect. But was it your intent to disallow COMMENT ON 
within a compound statement? If so, you may want to disallow it in the first 
TOK_COMMENT production as well.


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-06 Thread EEDY
Github user EEDY commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r149039000
  
--- Diff: 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 
"},
--- End diff --

Need more time to do this TEXT table modification.


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-06 Thread EEDY
Github user EEDY commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r149038713
  
--- Diff: core/sql/sqlcomp/CmpDescribe.cpp ---
@@ -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;
--- End diff --

I add a new error code CAT_UNABLE_TO_RETRIEVE_COMMENTS=1033, is this a good 
way? 


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-06 Thread EEDY
Github user EEDY commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r149038134
  
--- Diff: 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 , 
+NAString )
+{
+  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;
+
+  

[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-06 Thread EEDY
Github user EEDY commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r149039165
  
--- Diff: core/sql/parser/sqlparser.y ---
@@ -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) : 
+ NAString *catalogName = numParts > 3 ? 
seq->extract(numParts - 4) : 
+
+ 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;
+   }
+   
--- End diff --

Done


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-06 Thread EEDY
Github user EEDY commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r149039183
  
--- Diff: core/sql/sqlcomp/CmpDescribe.cpp ---
@@ -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);
--- End diff --

Done


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-02 Thread robertamarton
Github user robertamarton commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r148654665
  
--- Diff: core/sql/sqlcomp/CmpSeabaseDDLtable.cpp ---
@@ -12940,6 +12940,142 @@ TrafDesc 
*CmpSeabaseDDL::getSeabaseRoutineDescInternal(const NAString ,
 }
 
 
+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;
--- End diff --

Should there be an error placed in ComDiags area?   It looks like all the 
consumers just ignore the error and base their decision on the comment_info 
variable.  Earlier, after the select request, an error is placed in ComDiags.


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-02 Thread robertamarton
Github user robertamarton commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r148654612
  
--- Diff: core/sql/sqlcomp/CmpSeabaseDDLtable.cpp ---
@@ -12940,6 +12940,142 @@ TrafDesc 
*CmpSeabaseDDL::getSeabaseRoutineDescInternal(const NAString ,
 }
 
 
+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 <> '' ;",
--- End diff --

Recently all str_sprintf's were changed to sprintf's.  You might want to 
change this code also.


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-02 Thread robertamarton
Github user robertamarton commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r148654557
  
--- Diff: core/sql/sqlcomp/CmpSeabaseDDLtable.cpp ---
@@ -12940,6 +12940,142 @@ TrafDesc 
*CmpSeabaseDDL::getSeabaseRoutineDescInternal(const NAString ,
 }
 
 
+short CmpSeabaseDDL::getSeabaseObjectComment(Int64 object_uid, 
--- End diff --

Should this be part of CmpSeabaseDDLcommentOn.cpp?  This keeps all comment 
related code in the same file.


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-02 Thread robertamarton
Github user robertamarton commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r148654517
  
--- Diff: core/sql/sqlcomp/CmpSeabaseDDLschema.cpp ---
@@ -445,13 +445,36 @@ Int16 status = 
ComUser::getAuthNameFromAuthID(objectOwner,username,
output += catalogName.data();
output += "\".\"";
output += schemaName.data();
-   
+
 // AUTHORIZATION clause is rarely used, but include it for replay.
output += "\" AUTHORIZATION \"";
output += username;
output += "\";";

outlines.push_back(output.data());
+   
+   // Disaply Comment of schema
--- End diff --

Spelling


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-02 Thread robertamarton
Github user robertamarton commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r148654478
  
--- Diff: 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 
"},
--- End diff --

Instead of requiring a metadata change, you may want to add a new text_type 
to the text table and store comments there.  We do this for other features.  
When we decide to do an upgrade, we will remove the text entries from TEXT 
table and load them into the new metadata column COMMENT.


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-02 Thread robertamarton
Github user robertamarton commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r148654412
  
--- Diff: 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 , 
+NAString )
+{
+  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;

[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-02 Thread robertamarton
Github user robertamarton commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r148654381
  
--- Diff: 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 , 
+NAString )
+{
+  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;
--- End diff --

I 

[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-02 Thread robertamarton
Github user robertamarton commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r148654441
  
--- Diff: 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 , 
+NAString )
+{
+  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;

[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-02 Thread robertamarton
Github user robertamarton commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r148654287
  
--- Diff: core/sql/sqlcomp/CmpDescribe.cpp ---
@@ -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);
--- End diff --

getSeabaseObjectComment does return an error.  Also, it looks like 
objCommentInfo is null if unable to retrieve comment.  However, did you want to 
report the issue or just not display comments.  At a minimum you could say "-- 
comment details are not available" and/or log the failure as an INFO message.  
In getSeabaseObjectComment, some errors are placed in ComDiags and some are 
not.  Will the error be returned as part of showddl output if ComDiags is setup?


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-02 Thread robertamarton
Github user robertamarton commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r148654201
  
--- Diff: core/sql/sqlcomp/CmpDescribe.cpp ---
@@ -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);
--- End diff --

again, correct sql code?


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-02 Thread robertamarton
Github user robertamarton commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r148654147
  
--- Diff: core/sql/sqlcomp/CmpDescribe.cpp ---
@@ -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;
--- End diff --

Is this the correct SQL code?  Is COMMENT_CQD valid?


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-02 Thread robertamarton
Github user robertamarton commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r148654170
  
--- Diff: core/sql/sqlcomp/CmpDescribe.cpp ---
@@ -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);
--- End diff --

Can you have comments on view columns?


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-02 Thread robertamarton
Github user robertamarton commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r148654096
  
--- Diff: core/sql/parser/sqlparser.y ---
@@ -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) : 
+ NAString *catalogName = numParts > 3 ? 
seq->extract(numParts - 4) : 
+
+ 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;
+   }
+   
--- End diff --

Can you add comments on sequence generators?


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-02 Thread robertamarton
Github user robertamarton commented on a diff in the pull request:


https://github.com/apache/incubator-trafodion/pull/1288#discussion_r148654006
  
--- Diff: core/sql/parser/BindStmtDDL.cpp ---
@@ -2576,6 +2576,60 @@ StmtDDLAlterUser::bindNode(BindWA * pBindWA)
 
 }
 
+// ---
+// definition of method bindNode() for class StmtDDLCreateLibrary
+// ---
--- End diff --

Incorrect comment


---


[GitHub] incubator-trafodion pull request #1288: New COMMENT-ON SQL statement

2017-11-02 Thread EEDY
GitHub user EEDY opened a pull request:

https://github.com/apache/incubator-trafodion/pull/1288

New COMMENT-ON SQL statement


[SQL_COMMENT_feature_design.171025.docx](https://github.com/apache/incubator-trafodion/files/1437382/SQL_COMMENT_feature_design.171025.docx)

1. new SQL syntax: COMMENT ON
2. new component privilege: SQL_OPERATIONS::COMMENT
3. MD table changes: add new column named "COMMENT" 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

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/EEDY/incubator-trafodion master

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-trafodion/pull/1288.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1288


commit 078ed10cc8d5d4024b3a2dd2ff965cac46f38c9f
Author: eedy 
Date:   2017-11-02T09:17:31Z

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

commit 69c284c607fe965623ed16342df73f96200d38f5
Author: eedy 
Date:   2017-11-02T10:02:41Z

new COMMENT-ON SQL statement: fix showddl schema error

1. fix error while showddl schema with comment




---