Github user zellerh commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/31#discussion_r35039489
  
    --- Diff: core/sql/langman/LmJavaExceptionReporter.cpp ---
    @@ -792,3 +792,89 @@ 
LmJavaExceptionReporter::reportInternalSPJException(LmHandle jt,
     
     }
     // LCOV_EXCL_STOP
    +
    +//
    +// reportJavaObjException(): populates the diags for
    +// a return status returned in an LmUDRObjMethodInvoke.ReturnInfo
    +// object used in the Java object interface
    +void
    +LmJavaExceptionReporter::processJavaObjException(
    +     LmHandle returnInfoObj,
    +     int returnStatus,
    +     int callPhase,
    +     const char *errText,
    +     const char *udrName,
    +     ComDiagsArea *da)
    +{
    +  if (da)
    +    {
    +      JNIEnv *jni = (JNIEnv*)jniEnv_;
    +      const char *sqlState = NULL;
    +      const char *message = NULL;
    +      jobject jniResult = (jobject) returnInfoObj;
    +      jstring returnedSQLState =
    +        static_cast<jstring>(jni->GetObjectField(
    +           jniResult, 
    +           (jfieldID) langMan_->getReturnInfoSQLStateField()));
    +      jstring returnedMessage =
    +        static_cast<jstring>(jni->GetObjectField(
    +           jniResult, 
    +           (jfieldID) langMan_->getReturnInfoMessageField()));
    +
    +      if (returnedSQLState != NULL)
    +        sqlState = jni->GetStringUTFChars(returnedSQLState, NULL);
    +      if (returnedMessage != NULL)
    +        message = jni->GetStringUTFChars(returnedMessage, NULL);
    +
    +      if (sqlState || message)
    +        {
    +          const char *diagsMessage =
    +            (message ? message : "no message provided");
    +          const char *diagsSQLState =
    +            (sqlState ? sqlState : "no SQLSTATE provided");
    +
    +          // Check the returned SQLSTATE value and raise appropriate
    +          // SQL code. Valid SQLSTATE values begin with "38" except "38000"
    +          if (sqlState &&
    +              (strncmp(diagsSQLState, "38", 2) == 0) &&
    +              (strncmp(diagsSQLState, "38000", 5) != 0))
    +            {
    +              *da << DgSqlCode(-LME_CUSTOM_ERROR)
    +                  << DgString0(diagsMessage)
    +                  << DgString1(diagsSQLState);
    +              *da << DgCustomSQLState(diagsSQLState);
    +            }
    +          else
    +            {
    +              *da << DgSqlCode(-LME_UDF_ERROR)
    +                  << DgString0(udrName)
    +                  << DgString1(diagsSQLState)
    +                  << DgString2(diagsMessage);
    +            }
    +        }
    +      else
    +        {
    +          // Report the return status as an internal error, since
    +          // we didn't get a UDRException. This should be rare, since
    +          // Java exceptions are caught above.
    +          char buf1[4];
    +          snprintf(buf1, sizeof(buf1), "%d", callPhase);
    +          char buf2[80];
    +          snprintf(buf2, sizeof(buf2), "Return status %d from JNI call", 
returnStatus);
    --- End diff --
    
    Yes, sorry, there is some English text here, but I think this particular 
error message goes through significant trouble to allow translation into other 
languages. The message text is this: Internal error in communicating with UDR 
$0~String0 through the object interface in the $1~String1 phase ($2~String2). 
Details: $3~String3.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to