trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DaveBirdsall <...@git.apache.org>
Subject [GitHub] incubator-trafodion pull request #644: Trafodion 1788
Date Mon, 08 Aug 2016 20:59:44 GMT
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/644#discussion_r73953448
  
    --- Diff: core/sql/sqlcomp/PrivMgrMD.cpp ---
    @@ -630,6 +630,138 @@ bool PrivMgrMDAdmin::isAuthorized (void)
     }
     
     // ****************************************************************************
    +// method:  getColumnReferences
    +//
    +//  This method stores the list of columns for the object in the 
    +//  ObjectReference. 
    +// **************************************************************************** 
    +PrivStatus PrivMgrMDAdmin::getColumnReferences (ObjectReference *objectRef)
    +{
    +  std::string objectMDTable = trafMetadataLocation_ + ".OBJECTS o";
    +  std::string colMDTable = trafMetadataLocation_ + ".COLUMNS c";
    +
    +  // Select column details for object 
    +  std::string selectStmt = "select c.column_number from ";
    +  selectStmt += objectMDTable;
    +  selectStmt += ", ";
    +  selectStmt += colMDTable;
    +  selectStmt += " where o.object_uid = ";
    +  selectStmt += UIDToString(objectRef->objectUID);
    +  selectStmt += " and o.object_uid = c.object_uid";
    +  selectStmt += " order by column_number";
    +
    +  ExeCliInterface cliInterface(STMTHEAP, NULL, NULL,
    +  CmpCommon::context()->sqlSession()->getParentQid());
    +  Queue * objectsQueue = NULL;
    +
    +  int32_t cliRC =  cliInterface.fetchAllRows(objectsQueue, (char *)selectStmt.c_str(),
0, FALSE, FALSE, TRUE);
    +  if (cliRC < 0)
    +  {
    +    cliInterface.retrieveSQLDiagnostics(pDiags_);
    +    return STATUS_ERROR;
    +  }
    +
    +  if (cliRC == 100) // did not find the row
    +  {
    +    std::string message ("No columns found for referenced object");
    +    PRIVMGR_INTERNAL_ERROR(message.c_str());
    +    return STATUS_ERROR;
    +  }
    +
    +  char * ptr = NULL;
    +  Int32 len = 0;
    +
    +  objectRef->columnReferences = new std::vector<ColumnReference *>;
    +
    +  // For each row, create a ColumnReference and add it to the objectRef
    +  objectsQueue->position();
    +  for (int idx = 0; idx < objectsQueue->numEntries(); idx++)
    +  {
    +    OutputInfo * pCliRow = (OutputInfo*)objectsQueue->getNext();
    +    ColumnReference *columnReference = new ColumnReference;
    +
    +    // column 0:  columnNumber
    +    pCliRow->get(0,ptr,len);
    +    columnReference->columnOrdinal = *(reinterpret_cast<int32_t*>(ptr));
    +
    +    objectRef->columnReferences->push_back(columnReference);
    +  }
    +  return STATUS_GOOD;
    +}
    +
    +// ****************************************************************************
    +// method:  getViewColUsages
    +//
    +//  This method reads the TEXT table to obtain the view-col <=> referenced-col
    +//  relationship.
    +//
    +//  This relationship is stored in one or more text records with the text_type
    +//  COM_VIEW_REF_COLS_TEXT (7) see ComSmallDefs.h 
    +//
    +//  The text rows are concatenated together and saved in the ViewUsage.
    +// **************************************************************************** 
    +PrivStatus PrivMgrMDAdmin::getViewColUsages (ViewUsage &viewUsage)
    +{
    +  std::string objectMDTable = trafMetadataLocation_ + ".OBJECTS o";
    +  std::string textMDTable = trafMetadataLocation_ + ".TEXT t";
    +
    +  // Select text rows describing view <=> object column relationships
    +  std::string selectStmt = "select text from ";
    +  selectStmt += objectMDTable;
    +  selectStmt += ", ";
    +  selectStmt += textMDTable;
    +  selectStmt += " where o.object_uid = ";
    +  selectStmt += UIDToString(viewUsage.viewUID);
    +  selectStmt += "and o.object_uid = t.text_uid and t.text_type = 8";
    +  selectStmt += " order by seq_num";
    --- End diff --
    
    Again, why are you joining to the OBJECTS table? Doesn't look like you're getting any
information from it.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message