trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertamarton <...@git.apache.org>
Subject [GitHub] trafodion pull request #1721: [TRAFODION-3216]UDR libraries need to be store...
Date Sun, 14 Oct 2018 23:52:42 GMT
Github user robertamarton commented on a diff in the pull request:

    https://github.com/apache/trafodion/pull/1721#discussion_r225014987
  
    --- Diff: core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp ---
    @@ -995,180 +1561,293 @@ void CmpSeabaseDDL::createSeabaseRoutine(
       sigBuf[0] = '\0';
     
       if (style == COM_STYLE_JAVA_CALL) 
    -  {
    -     // validate routine for Java call based on signature
    -     Lng32 numJavaParam = 0;
    -     ComFSDataType *paramType = new ComFSDataType[numParams];
    -     ComUInt32     *subType   = new ComUInt32    [numParams];
    -     ComColumnDirection *direction = new ComColumnDirection[numParams];
    -     NAType *genericType;
    +    {
    +      // validate routine for Java call based on signature
    +      Lng32 numJavaParam = 0;
    +      ComFSDataType *paramType = new ComFSDataType[numParams];
    +      ComUInt32     *subType   = new ComUInt32    [numParams];
    +      ComColumnDirection *direction = new ComColumnDirection[numParams];
    +      NAType *genericType;
     
    -     // Gather the param attributes for LM from the paramDefArray previously
    -     // populated and from the routineparamList generated from paramDefArray.
    +      // Gather the param attributes for LM from the paramDefArray previously
    +      // populated and from the routineparamList generated from paramDefArray.
     
    -     for (CollIndex i = 0; (Int32)i < numParams; i++)
    -     {
    -       paramType[i] = (ComFSDataType)routineParamArray[i]->getParamDataType()->getFSDatatype();
    -       subType[i] = 0;  // default
    -       // Set subType for special cases detected by LM
    -       switch ( paramType[i] )
    -       {
    -         case COM_SIGNED_BIN8_FSDT :
    -         case COM_UNSIGNED_BIN8_FSDT :
    -         case COM_SIGNED_BIN16_FSDT :
    -         case COM_SIGNED_BIN32_FSDT :
    -         case COM_SIGNED_BIN64_FSDT :
    -         case COM_UNSIGNED_BIN16_FSDT :
    -         case COM_UNSIGNED_BIN32_FSDT :
    -         case COM_UNSIGNED_BPINT_FSDT :
    -         {
    -           genericType = routineParamArray[i]->getParamDataType() ;
    -           if (genericType->getTypeName() == LiteralNumeric)
    -             subType[i] = genericType->getPrecision();
    -           else
    -             subType[i] = 0 ;
    -
    -           break;
    -         }
    -
    -         case COM_DATETIME_FSDT :
    -         {
    -           genericType = routineParamArray[i]->getParamDataType() ;
    -           DatetimeType & datetimeType = (DatetimeType &) *genericType;
    -            if (datetimeType.getSimpleTypeName() EQU "DATE")
    -              subType[i] = 1 ;
    -            else if (datetimeType.getSimpleTypeName() EQU "TIME")
    -              subType[i] = 2;
    -            else if (datetimeType.getSimpleTypeName() EQU "TIMESTAMP")
    -              subType[i] = 3;
    -         }
    -       } // end switch paramType[i]
    -
    -       direction[i] = (ComColumnDirection) routineParamArray[i]->getParamDirection();
    -     }
    +      for (CollIndex i = 0; (Int32)i < numParams; i++)
    +        {
    +          paramType[i] = (ComFSDataType)routineParamArray[i]->getParamDataType()->getFSDatatype();
    +          subType[i] = 0;  // default
    +          // Set subType for special cases detected by LM
    +          switch ( paramType[i] )
    +            {
    +            case COM_SIGNED_BIN8_FSDT :
    +            case COM_UNSIGNED_BIN8_FSDT :
    +            case COM_SIGNED_BIN16_FSDT :
    +            case COM_SIGNED_BIN32_FSDT :
    +            case COM_SIGNED_BIN64_FSDT :
    +            case COM_UNSIGNED_BIN16_FSDT :
    +            case COM_UNSIGNED_BIN32_FSDT :
    +            case COM_UNSIGNED_BPINT_FSDT :
    +              {
    +                genericType = routineParamArray[i]->getParamDataType() ;
    +                if (genericType->getTypeName() == LiteralNumeric)
    +                  subType[i] = genericType->getPrecision();
    +                else
    +                  subType[i] = 0 ;
    +
    +                break;
    +              }
    +
    +            case COM_DATETIME_FSDT :
    +              {
    +                genericType = routineParamArray[i]->getParamDataType() ;
    +                DatetimeType & datetimeType = (DatetimeType &) *genericType;
    +                if (datetimeType.getSimpleTypeName() EQU "DATE")
    +                  subType[i] = 1 ;
    +                else if (datetimeType.getSimpleTypeName() EQU "TIME")
    +                  subType[i] = 2;
    +                else if (datetimeType.getSimpleTypeName() EQU "TIMESTAMP")
    +                  subType[i] = 3;
    +              }
    +            } // end switch paramType[i]
    +
    +          direction[i] = (ComColumnDirection) routineParamArray[i]->getParamDirection();
    +        }
         
    -     // If the syntax specified a signature, pass that to LanguageManager.
    -     NAString specifiedSig( createRoutineNode->getJavaSignature() );
    -     char* optionalSig;
    -     if ( specifiedSig.length() == 0 )
    -       optionalSig = NULL;
    -     else
    -       optionalSig = (char *)specifiedSig.data();
    +      // If the syntax specified a signature, pass that to LanguageManager.
    +      NAString specifiedSig( createRoutineNode->getJavaSignature() );
    +      char* optionalSig;
    +      if ( specifiedSig.length() == 0 )
    +        optionalSig = NULL;
    +      else
    +        optionalSig = (char *)specifiedSig.data();
          
    -     ComBoolean isJavaMain =
    -       ((str_cmp_ne(createRoutineNode->getJavaMethodName(), "main") == 0) ? TRUE :
FALSE);
    -
    -     LmResult createSigResult;
    -     LmJavaSignature *lmSignature =  new (STMTHEAP) LmJavaSignature(NULL,
    -                                                                    STMTHEAP);
    -     createSigResult = lmSignature->createSig(paramType, subType, direction,
    -                                              numParams, COM_UNKNOWN_FSDT, 0,
    -                                              createRoutineNode->getMaxResults(),
optionalSig, isJavaMain, sigBuf,
    -                                              MAX_SIGNATURE_LENGTH,
    -                                              CmpCommon::diags());
    -     NADELETE(lmSignature, LmJavaSignature, STMTHEAP);
    -     delete [] paramType;
    -     delete [] subType;
    -     delete [] direction;
    -
    -     // Lm returned error. Lm fills diags area, so no need to worry about diags.
    -     if (createSigResult == LM_ERR)
    -     {
    -       *CmpCommon::diags() << DgSqlCode(-1231)
    -			  << DgString0(extRoutineName);
    -       deallocEHI(ehi); 
    -       processReturn();
    -       return;
    -     }
    +      ComBoolean isJavaMain =
    +        ((str_cmp_ne(createRoutineNode->getJavaMethodName(), "main") == 0) ? TRUE
: FALSE);
    +
    +      LmResult createSigResult;
    +      LmJavaSignature *lmSignature =  new (STMTHEAP) LmJavaSignature(NULL,
    +                                                                     STMTHEAP);
    +      createSigResult = lmSignature->createSig(paramType, subType, direction,
    +                                               numParams, COM_UNKNOWN_FSDT, 0,
    +                                               createRoutineNode->getMaxResults(),
optionalSig, isJavaMain, sigBuf,
    +                                               MAX_SIGNATURE_LENGTH,
    +                                               CmpCommon::diags());
    +      NADELETE(lmSignature, LmJavaSignature, STMTHEAP);
    +      delete [] paramType;
    +      delete [] subType;
    +      delete [] direction;
    +
    +      // Lm returned error. Lm fills diags area, so no need to worry about diags.
    +      if (createSigResult == LM_ERR)
    +        {
    +          *CmpCommon::diags() << DgSqlCode(-1231)
    +                              << DgString0(extRoutineName);
    +          deallocEHI(ehi); 
    +          processReturn();
    +          return;
    +        }
     
    -     numJavaParam = (isJavaMain ? 1 : numParams);
    +      numJavaParam = (isJavaMain ? 1 : numParams);
    +
    +      if( libBlobHandle[0] != '\0' )
    +        {
    +          NAString dummyUser;
    +          NAString cachedLibName, cachedLibPath;
    +          
    +          if(ComGenerateUdrCachedLibName(extPath,redefTime,libSchNamePart,dummyUser,
cachedLibName, cachedLibPath))
    +            {
    +              *CmpCommon::diags() << DgSqlCode(-1231)
    +                                  << DgString0(extRoutineName);
    --- End diff --
    
    There is a literal for this: CAT_UNABLE_TO_CREATE_ROUTINE.  This is another error that
could fail for various reasons and it could be improved to return more details.


---

Mime
View raw message