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: TRAFODION [1879] - Integrate Lib...
Date Tue, 08 Mar 2016 23:53:18 GMT
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/372#discussion_r55450475
  
    --- Diff: core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp ---
    @@ -1425,3 +1426,169 @@ short CmpSeabaseDDL::validateRoutine(ExeCliInterface *cliInterface,
       return -1;
     
     } // CmpSeabaseDDL::validateRoutine
    +
    +short CmpSeabaseDDL::createSeabaseLibmgr(ExeCliInterface * cliInterface)
    +{
    +  Lng32 cliRC = 0;
    +  
    +  if ((CmpCommon::context()->isUninitializedSeabase()) &&
    +      (CmpCommon::context()->uninitializedSeabaseErrNum() == -1393))
    +    {
    +      *CmpCommon::diags() << DgSqlCode(-1393);
    +      return -1;
    +    }
    +
    +  NAString jarLocation(getenv("MY_SQROOT"));
    +  jarLocation += "/export/lib/lib_mgmt.jar";
    +  char queryBuf[strlen(getSystemCatalog()) + strlen(SEABASE_LIBMGR_SCHEMA) +
    +                strlen(SEABASE_LIBMGR_LIBRARY) + strlen(DB__LIBMGRROLE) + 
    +                jarLocation.length() + 100];
    +
    +  // Create the SEABASE_LIBMGR_SCHEMA schema
    +  str_sprintf(queryBuf, "create schema if not exists %s.\"%s\" authorization %s ",
    +              getSystemCatalog(),SEABASE_LIBMGR_SCHEMA, DB__ROOT);
    +
    +  cliRC = cliInterface->executeImmediate(queryBuf);
    +  if (cliRC < 0)
    +    {
    +      cliInterface->retrieveSQLDiagnostics(CmpCommon::diags());
    +      return -1;
    +    }
    +
    +  // Create the SEABASE_LIBMGR_LIBRARY library
    +  str_sprintf(queryBuf, "create library %s.\"%s\".%s file '%s'",
    +                         getSystemCatalog(), SEABASE_LIBMGR_SCHEMA, SEABASE_LIBMGR_LIBRARY,
    +                         jarLocation.data());
    +
    +  cliRC = cliInterface->executeImmediate(queryBuf);
    +  if (cliRC < 0)
    +    {
    +      cliInterface->retrieveSQLDiagnostics(CmpCommon::diags());
    +      return -1;
    +    }
    +
    +  return (createLibmgrProcs(cliInterface));
    +}
    +
    +short CmpSeabaseDDL::createLibmgrProcs(ExeCliInterface * cliInterface)
    +{
    +  Lng32 cliRC = 0;
    +  char queryBuf[2000];
    +
    + // Create the procedures if they don't already exist
    +  for (Int32 i = 0; i < sizeof(allLibmgrRoutineInfo)/sizeof(LibmgrRoutineInfo); i++)
    +    {
    +      // Get the next procedure routine details
    +      const LibmgrRoutineInfo &prd = allLibmgrRoutineInfo[i];
    +
    +      const QString * qs = NULL;
    +      Int32 sizeOfqs = 0;
    +
    +      qs = prd.newDDL;
    +      sizeOfqs = prd.sizeOfnewDDL;
    +
    +      Int32 qryArraySize = sizeOfqs / sizeof(QString);
    +      char * gluedQuery;
    +      Lng32 gluedQuerySize;
    +      glueQueryFragments(qryArraySize,  qs,
    +                         gluedQuery, gluedQuerySize);
    +
    +      param_[0] = getSystemCatalog();
    +      param_[1] = SEABASE_LIBMGR_SCHEMA;
    +      param_[2] = getSystemCatalog();
    +      param_[3] = SEABASE_LIBMGR_SCHEMA;
    +      param_[4] = SEABASE_LIBMGR_LIBRARY;
    +
    +      str_sprintf(queryBuf, gluedQuery, param_[0], param_[1], param_[2], param_[3], param_[4]);
    +      NADELETEBASIC(gluedQuery, STMTHEAP);
    --- End diff --
    
    How do we know that queryBuf is large enough to hold the data str_sprintf writes to 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