Github user robertamarton commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1721#discussion_r225014997
--- 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);
+ deallocEHI(ehi);
+ processReturn();
+ return;
+ }
+
+ NAString cachedFullName = cachedLibPath+"/"+cachedLibName;
+
+ if (extractLibrary(&cliInterface,libBlobHandle, (char
*)cachedFullName.data()))
+ {
+ *CmpCommon::diags() << DgSqlCode(-1231)
+ << DgString0(extRoutineName);
+ deallocEHI(ehi);
+ processReturn();
+ return;
+ }
+
+ if (validateRoutine(&cliInterface,
+ createRoutineNode->getJavaClassName(),
+ createRoutineNode->getJavaMethodName(),
+ cachedFullName,
+ sigBuf,
+ numJavaParam,
+ createRoutineNode->getMaxResults(),
+ optionalSig))
+ {
+ *CmpCommon::diags() << DgSqlCode(-1231)
+ << DgString0(extRoutineName);
+ deallocEHI(ehi);
+ processReturn();
+ return;
+ }
+ }
+
+ else
+ {
+ if (validateRoutine(&cliInterface,
+ createRoutineNode->getJavaClassName(),
+ createRoutineNode->getJavaMethodName(),
+ externalPath,
+ sigBuf,
+ numJavaParam,
+ createRoutineNode->getMaxResults(),
+ optionalSig))
+
+ {
+ *CmpCommon::diags() << DgSqlCode(-1231)
+ << DgString0(extRoutineName);
+ deallocEHI(ehi);
+ processReturn();
+ return;
+ }
+ }
+ }
+
- if (validateRoutine(&cliInterface,
- createRoutineNode->getJavaClassName(),
- createRoutineNode->getJavaMethodName(),
- externalPath,
- sigBuf,
- numJavaParam,
- createRoutineNode->getMaxResults(),
- optionalSig))
- {
- *CmpCommon::diags() << DgSqlCode(-1231)
- << DgString0(extRoutineName);
- deallocEHI(ehi);
- processReturn();
- return;
- }
- }
else if (style == COM_STYLE_JAVA_OBJ ||
style == COM_STYLE_CPP_OBJ)
- {
- // validate existence of the C++ or Java class in the library
- Int32 routineHandle = NullCliRoutineHandle;
- NAString externalPrefix(externalPath);
- NAString externalNameForValidation(externalName);
- NAString containerName;
+ {
+ // validate existence of the C++ or Java class in the library
+ Int32 routineHandle = NullCliRoutineHandle;
+ NAString externalPrefix(externalPath);
+ NAString externalNameForValidation(externalName);
+ NAString containerName;
- if (language == COM_LANGUAGE_C || language == COM_LANGUAGE_CPP)
- {
- // separate the actual DLL name from the prefix
- char separator = '/';
- size_t separatorPos = externalPrefix.last(separator);
+ if (language == COM_LANGUAGE_C || language == COM_LANGUAGE_CPP)
+ {
+ if( libBlobHandle[0] != '\0' )
+ {
+ NAString dummyUser;
+ NAString cachedLibName, cachedLibPath;
+
+ if
(ComGenerateUdrCachedLibName(externalPrefix,redefTime,libSchNamePart,dummyUser,
cachedLibName, cachedLibPath))
+ {
+ *CmpCommon::diags() << DgSqlCode(-1231)
+ << DgString0(extRoutineName);
+ deallocEHI(ehi);
+ processReturn();
+ return;
+ }
+
+ NAString cachedFullName = cachedLibPath+"/"+cachedLibName;
+
+ if (extractLibrary(&cliInterface,libBlobHandle, (char
*)cachedFullName.data()))
+ {
+ *CmpCommon::diags() << DgSqlCode(-1231)
+ << DgString0(extRoutineName);
+ deallocEHI(ehi);
+ processReturn();
+ return;
+ }
+ externalPrefix = cachedLibPath;
+ containerName = cachedLibName;
+
+ }
+ else
+ {
+ // separate the actual DLL name from the prefix
+ char separator = '/';
+ size_t separatorPos = externalPrefix.last(separator);
+
+ if (separatorPos != NA_NPOS)
+ {
+ containerName = externalPrefix(separatorPos+1,
+
externalPrefix.length()-separatorPos-1);
+ externalPrefix.remove(separatorPos,
+
externalPrefix.length()-separatorPos);
+ }
+ else
+ {
+ // assume the entire string is a local name
+ containerName = externalPrefix;
+ externalPrefix = ".";
--- End diff --
This adds a period to the externalPrefix, however, if a slash exists, the
period is not included. Is this intentional?
---