You are viewing a plain text version of this content. The canonical link for it is here.
Posted to codereview@trafodion.apache.org by zellerh <gi...@git.apache.org> on 2015/07/18 20:23:03 UTC

[GitHub] incubator-trafodion pull request: Bug/udf1

GitHub user zellerh opened a pull request:

    https://github.com/apache/incubator-trafodion/pull/31

    Bug/udf1

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/zellerh/incubator-trafodion bug/udf1

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-trafodion/pull/31.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #31
    
----
commit ee5a6fffc079113d8b6399ba8e50b930fa95cb94
Author: Hans Zeller <ze...@build01.trafodion.org>
Date:   2015-07-18T17:54:12Z

    TRAFODION-38 First working TMUDFs in Java
    
    Also addresses:
    
    TRAFODION-7 Have a .project file to be able to import source code into Eclipse
    TRAFODION-35 Add a method that allows UDR writers to debug their UDRs on a release build
    
    Summary of changes:
    
    TRAFODION-7:
    
    Eclipse project files can now be generated with the following make target in the core directory:
    
    cd core
    make eclipse
    
    This will print out instructions on how to import the generated projects into Eclipse.
    
    TRAFODION-35:
    
    Java UDRs are debugged with the following CQDs:
    
    cqd UDR_JAVA_DEBUG_PORT
    cqd UDR_JAVA_DEBUG_TIMEOUT
    
    The best way to do this is with the sqlci tool. Set UDR_JAVA_DEBUG_PORT before executing any Java UDR. Then, after executing the
    first one, attach a remote Java debugger like jdb or Eclipse. To debug the very first invocation, set UDR_JAVA_DEBUG_TIMEOUT to
    a time in milliseconds and attach the debugger within that time.
    
    This debugs only the runtime part of the UDR. To debug the compiler interface, set this environment variable before starting
    sqlci:
    
    export JVM_DEBUG_PORT=12345
    
    For both cases, here are two more things to know: First, this only works if you are connected as the DB__ROOT user (running
    sqlci without special options runs as DB__ROOT). Second, if you want to debug parallel instances of UDRs, choose a multiple of
    1000 for the port number. Trafdion with then add <process id> mod 1000 to the port and put all the parallel instances into Java
    debugging mode on these different ports.
    
    TRAFODION-38:
    
    Integrating Java code written by Suresh and Pavani with the engine code for Java TMUDFs.
    Addressing a few Java issues flagged by Eclipse.
    Adding Java TMUDF tests to core/sql/regress/udr/TEST001.

commit 44d5278c3dcd9dc7e795eee4b88607fd4459e667
Author: Hans Zeller <ze...@build01.trafodion.org>
Date:   2015-07-18T18:02:31Z

    Merge branch 'master' of github.com:apache/incubator-trafodion into bug/udf1
    
    Conflicts:
    	core/sql/sqlcomp/DefaultConstants.h

----


---
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.
---

[GitHub] incubator-trafodion pull request: TRAFODION-38 First working TMUDF...

Posted by sureshsubbiah <gi...@git.apache.org>.
Github user sureshsubbiah commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/31#discussion_r35128642
  
    --- Diff: core/sql/regress/udr/EXPECTED001 ---
    @@ -195,6 +244,33 @@ CREATE TABLE_MAPPING FUNCTION TRAFODION.SCH.SESSIONIZE_DYNAMIC
     
     --- SQL operation complete.
     >>
    +>>get table_mapping functions for library TEST001_Java ;
    --- End diff --
    
    I found that difficult to do in our parser without increasing conflicts. This is not to say that we should not try again.


---
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.
---

[GitHub] incubator-trafodion pull request: TRAFODION-38 First working TMUDF...

Posted by zellerh <gi...@git.apache.org>.
Github user zellerh commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/31#discussion_r35012778
  
    --- Diff: core/Makefile ---
    @@ -135,3 +135,28 @@ find-absolute-dlls:
     
     check-copyrights:
     	python ./updateCopyrightCheck.py
    +
    +eclipse: rest/.project sql/.project sqf/src/seatrans/hbase-trx/.project .project
    +	@echo
    +	@echo
    +	@echo "  Now you can import 5 projects in Eclipse:"
    --- End diff --
    
    The HBase-trx make step actually creates two projects, hbase-trx and hbase-protocol.


---
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.
---

[GitHub] incubator-trafodion pull request: TRAFODION-38 First working TMUDF...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-trafodion/pull/31


---
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.
---

[GitHub] incubator-trafodion pull request: TRAFODION-38 First working TMUDF...

Posted by zellerh <gi...@git.apache.org>.
Github user zellerh commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/31#discussion_r35013188
  
    --- Diff: core/sql/executor/JavaObjectInterface.cpp ---
    @@ -147,19 +147,29 @@ int JavaObjectInterface::createJVM()
         }
       }
     
    -#ifdef _DEBUG
       int debugPort = 0;
       const char *debugPortStr = getenv("JVM_DEBUG_PORT");
       if (debugPortStr != NULL)
          debugPort = atoi(debugPortStr);
    -  const char *debugTimeoutStr = getenv("JVM_DEBUG_TIMEOUT");
    -  if (debugTimeoutStr != NULL)
    -     debugTimeout_ = atoi(debugTimeoutStr);
    -  const char *suspendOnDebug = getenv("JVM_SUSPEND_ON_DEBUG");
    -  char debugOptions[300];
    -  if (debugPort > 0)
    +  if (debugPort > 0
    +#ifdef NDEBUG
    +      // in a release build, only DB__ROOT can debug a process
    +      && ComUser::isRootUserID()
    +#endif
    +     )
       {
    -     debugPort_ = debugPort + (GetCliGlobals()->myPin() % 1000);
    +     const char *debugTimeoutStr = getenv("JVM_DEBUG_TIMEOUT");
    +     if (debugTimeoutStr != NULL)
    +       debugTimeout_ = atoi(debugTimeoutStr);
    +     const char *suspendOnDebug = getenv("JVM_SUSPEND_ON_DEBUG");
    +     char debugOptions[300];
    +
    +     debugPort_ = debugPort;
    +     // to allow debugging multiple processes at the same time,
    +     // specify a port that is a multiple of 1000 and the code will
    +     // add pid mod 1000 to the port number to use
    +     if (debugPort_ % 1000 == 0)
    +       debugPort_ += (GetCliGlobals()->myPin() % 1000);
    --- End diff --
    
    Yes, this is not perfect. If the user makes sure they have 1000 unused ports then we can guarantee that there are no port conflicts. One error I got from the debugger was "connection refused", which I think might have been caused by a port conflict.


---
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.
---

[GitHub] incubator-trafodion pull request: TRAFODION-38 First working TMUDF...

Posted by DaveBirdsall <gi...@git.apache.org>.
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/31#discussion_r35014440
  
    --- 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 --
    
    I've noticed that in the last year or so we are putting more message text in our code (to avoid multiplying error messages in SqlciErrors.txt probably). If there is ever a desire to translate our error messages into another language, this will prove to be an obstacle.


---
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.
---

[GitHub] incubator-trafodion pull request: TRAFODION-38 First working TMUDF...

Posted by DaveBirdsall <gi...@git.apache.org>.
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/31#discussion_r35011468
  
    --- Diff: core/Makefile ---
    @@ -135,3 +135,28 @@ find-absolute-dlls:
     
     check-copyrights:
     	python ./updateCopyrightCheck.py
    +
    +eclipse: rest/.project sql/.project sqf/src/seatrans/hbase-trx/.project .project
    +	@echo
    +	@echo
    +	@echo "  Now you can import 5 projects in Eclipse:"
    --- End diff --
    
    The echo says 5 projects, but I only see make file steps for 4?


---
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.
---

[GitHub] incubator-trafodion pull request: TRAFODION-38 First working TMUDF...

Posted by DaveBirdsall <gi...@git.apache.org>.
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/31#discussion_r35015035
  
    --- Diff: core/sql/langman/LmLangManagerJava.cpp ---
    @@ -694,6 +712,52 @@ void LmLanguageManagerJava::initialize(LmResult &result,
         return;
       }
     
    +  jc = (jclass) jni->FindClass("org/trafodion/sql/udr/UDR");
    +  if (jc)
    +  {
    +    udrClass_ = (jclass) jni->NewGlobalRef(jc);
    +    jni->DeleteLocalRef(jc);
    +  }
    +  else
    +  {
    +    exceptionReporter_->insertDiags(diagsArea_,
    +                                    -LME_JVM_SYS_CLASS_ERROR,
    +                                    "org.trafodion.sql.udr.UDR");
    +    result = LM_ERR;
    +    return;
    +  }
    +
    +  // this class is used in JNI calls from Java UDRs to C++ code that
    +  // gets and emits rows
    +  jc = (jclass) jni->FindClass("org/trafodion/sql/udr/UDR$QueueStateInfo");
    +  if (jc)
    +  {
    +    udrQueueStateField_ = jni->GetFieldID(
    +         jc,
    +         "queueState_",
    +         "I");
    +
    +    if (jni->ExceptionOccurred() ||
    +        udrQueueStateField_ == NULL)
    +      {
    +        exceptionReporter_->insertDiags(diagsArea_,
    +                                        -LME_JVM_SYS_CLASS_ERROR,
    +                                        "org/trafodion/sql/udr/UDR$QueueStateInfo");
    +        result = LM_ERR;
    +        return;
    --- End diff --
    
    Just curious: Why no deletelocalref in this code path?


---
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.
---

[GitHub] incubator-trafodion pull request: TRAFODION-38 First working TMUDF...

Posted by zellerh <gi...@git.apache.org>.
Github user zellerh commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/31#discussion_r35041142
  
    --- Diff: core/sql/src/main/java/org/trafodion/sql/udr/TupleInfo.java ---
    @@ -1309,100 +1277,27 @@ public void setString(int colNum, String val) throws UDRException {
             }
     
             TypeInfo.SQLTypeCode sqlType = t.getSQLType();
    -        boolean isApproxNumeric = false;
    -        int stringLen = val.length();
             ByteBuffer bb;
    -        
    -        // a string overflow will raise an exception
    -        if (stringLen > t.getByteLength())
    -            throw new UDRException(38900,
    -                                   "setString() with a string of length %d on a column with length %d",
    -                                   stringLen,
    -                                   t.getByteLength());
    -        
    +
             switch (sqlType)
             {
             case DATE:
             case TIME:
             case TIMESTAMP:
    -        case BLOB:
    -            if ((stringLen != t.getByteLength()) && (sqlType != TypeInfo.SQLTypeCode.BLOB))
    +            val = val.trim();
    +            if ((val.length() != t.getByteLength()))
                     throw new UDRException(38900,
    -                                       "setString() with a string of length %d on a column with length %d",
    -                                       stringLen,
    +                                       "setString() with a string of length %d on a datetime column with length %d",
    +                                       val.length(),
                                            t.getByteLength());
    -            bb = isoCharset.encode(val);
    -            row_.position(t.getDataOffset());
    -            row_.put(bb);
    -            if (sqlType == TypeInfo.SQLTypeCode.BLOB)
    -            {
    -                // set the varchar length indicator
    -                if (t.getVcLenIndOffset() < 0)
    -                    throw new UDRException(38900,
    -                                           "Internal error, BLOB without length indicator");
    -                
    -                if ((t.getFlags() & TypeInfo.TYPE_FLAG_4_BYTE_VC_LEN) == 1)
    -                    row_.putInt(t.getVcLenIndOffset(),stringLen);
    -                else
    -                    row_.putShort(t.getVcLenIndOffset(),(short)stringLen);
    -            }
    -            break ;
    +            // fall through to next case
    +
             case CHAR:
             case VARCHAR:
    +        case BLOB:
    --- End diff --
    
    Would we blank-pad a BLOB? As far as I can tell, the putEncodedStringIntoBuffer() method only blank-pads fixed-length fields, and a BLOB should be variable length. We probably should add a setBytes() or setBinary() method for BLOBs. BLOB and CLOB support for TMUDFs is not fully designed and supported yet, I've been talking to Sandhya about the best ways to do this.


---
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.
---

[GitHub] incubator-trafodion pull request: TRAFODION-38 First working TMUDF...

Posted by zellerh <gi...@git.apache.org>.
Github user zellerh commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/31#discussion_r35039577
  
    --- Diff: core/sql/langman/LmLangManagerJava.cpp ---
    @@ -694,6 +712,52 @@ void LmLanguageManagerJava::initialize(LmResult &result,
         return;
       }
     
    +  jc = (jclass) jni->FindClass("org/trafodion/sql/udr/UDR");
    +  if (jc)
    +  {
    +    udrClass_ = (jclass) jni->NewGlobalRef(jc);
    +    jni->DeleteLocalRef(jc);
    +  }
    +  else
    +  {
    +    exceptionReporter_->insertDiags(diagsArea_,
    +                                    -LME_JVM_SYS_CLASS_ERROR,
    +                                    "org.trafodion.sql.udr.UDR");
    +    result = LM_ERR;
    +    return;
    +  }
    +
    +  // this class is used in JNI calls from Java UDRs to C++ code that
    +  // gets and emits rows
    +  jc = (jclass) jni->FindClass("org/trafodion/sql/udr/UDR$QueueStateInfo");
    +  if (jc)
    +  {
    +    udrQueueStateField_ = jni->GetFieldID(
    +         jc,
    +         "queueState_",
    +         "I");
    +
    +    if (jni->ExceptionOccurred() ||
    +        udrQueueStateField_ == NULL)
    +      {
    +        exceptionReporter_->insertDiags(diagsArea_,
    +                                        -LME_JVM_SYS_CLASS_ERROR,
    +                                        "org/trafodion/sql/udr/UDR$QueueStateInfo");
    +        result = LM_ERR;
    +        return;
    --- End diff --
    
    Thanks, I'll fix that.


---
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.
---

[GitHub] incubator-trafodion pull request: TRAFODION-38 First working TMUDF...

Posted by DaveBirdsall <gi...@git.apache.org>.
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/31#discussion_r35012380
  
    --- Diff: core/sql/executor/JavaObjectInterface.cpp ---
    @@ -147,19 +147,29 @@ int JavaObjectInterface::createJVM()
         }
       }
     
    -#ifdef _DEBUG
       int debugPort = 0;
       const char *debugPortStr = getenv("JVM_DEBUG_PORT");
       if (debugPortStr != NULL)
          debugPort = atoi(debugPortStr);
    -  const char *debugTimeoutStr = getenv("JVM_DEBUG_TIMEOUT");
    -  if (debugTimeoutStr != NULL)
    -     debugTimeout_ = atoi(debugTimeoutStr);
    -  const char *suspendOnDebug = getenv("JVM_SUSPEND_ON_DEBUG");
    -  char debugOptions[300];
    -  if (debugPort > 0)
    +  if (debugPort > 0
    +#ifdef NDEBUG
    +      // in a release build, only DB__ROOT can debug a process
    +      && ComUser::isRootUserID()
    +#endif
    +     )
       {
    -     debugPort_ = debugPort + (GetCliGlobals()->myPin() % 1000);
    +     const char *debugTimeoutStr = getenv("JVM_DEBUG_TIMEOUT");
    +     if (debugTimeoutStr != NULL)
    +       debugTimeout_ = atoi(debugTimeoutStr);
    +     const char *suspendOnDebug = getenv("JVM_SUSPEND_ON_DEBUG");
    +     char debugOptions[300];
    +
    +     debugPort_ = debugPort;
    +     // to allow debugging multiple processes at the same time,
    +     // specify a port that is a multiple of 1000 and the code will
    +     // add pid mod 1000 to the port number to use
    +     if (debugPort_ % 1000 == 0)
    +       debugPort_ += (GetCliGlobals()->myPin() % 1000);
    --- End diff --
    
    What's the probability of port collisions? How does one identify them? I suppose a way to work around port collisions is to stop and restart the affected processes?


---
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.
---

[GitHub] incubator-trafodion pull request: TRAFODION-38 First working TMUDF...

Posted by zellerh <gi...@git.apache.org>.
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-trafodion pull request: TRAFODION-38 First working TMUDF...

Posted by DaveBirdsall <gi...@git.apache.org>.
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/31#discussion_r35017864
  
    --- Diff: core/sql/regress/udr/EXPECTED001 ---
    @@ -195,6 +244,33 @@ CREATE TABLE_MAPPING FUNCTION TRAFODION.SCH.SESSIONIZE_DYNAMIC
     
     --- SQL operation complete.
     >>
    +>>get table_mapping functions for library TEST001_Java ;
    --- End diff --
    
    "table mapping" without the underscore would seem to be more natural.


---
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.
---

[GitHub] incubator-trafodion pull request: TRAFODION-38 First working TMUDF...

Posted by DaveBirdsall <gi...@git.apache.org>.
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/31#discussion_r35019592
  
    --- Diff: core/sql/src/main/java/org/trafodion/sql/udr/TupleInfo.java ---
    @@ -1309,100 +1277,27 @@ public void setString(int colNum, String val) throws UDRException {
             }
     
             TypeInfo.SQLTypeCode sqlType = t.getSQLType();
    -        boolean isApproxNumeric = false;
    -        int stringLen = val.length();
             ByteBuffer bb;
    -        
    -        // a string overflow will raise an exception
    -        if (stringLen > t.getByteLength())
    -            throw new UDRException(38900,
    -                                   "setString() with a string of length %d on a column with length %d",
    -                                   stringLen,
    -                                   t.getByteLength());
    -        
    +
             switch (sqlType)
             {
             case DATE:
             case TIME:
             case TIMESTAMP:
    -        case BLOB:
    -            if ((stringLen != t.getByteLength()) && (sqlType != TypeInfo.SQLTypeCode.BLOB))
    +            val = val.trim();
    +            if ((val.length() != t.getByteLength()))
                     throw new UDRException(38900,
    -                                       "setString() with a string of length %d on a column with length %d",
    -                                       stringLen,
    +                                       "setString() with a string of length %d on a datetime column with length %d",
    +                                       val.length(),
                                            t.getByteLength());
    -            bb = isoCharset.encode(val);
    -            row_.position(t.getDataOffset());
    -            row_.put(bb);
    -            if (sqlType == TypeInfo.SQLTypeCode.BLOB)
    -            {
    -                // set the varchar length indicator
    -                if (t.getVcLenIndOffset() < 0)
    -                    throw new UDRException(38900,
    -                                           "Internal error, BLOB without length indicator");
    -                
    -                if ((t.getFlags() & TypeInfo.TYPE_FLAG_4_BYTE_VC_LEN) == 1)
    -                    row_.putInt(t.getVcLenIndOffset(),stringLen);
    -                else
    -                    row_.putShort(t.getVcLenIndOffset(),(short)stringLen);
    -            }
    -            break ;
    +            // fall through to next case
    +
             case CHAR:
             case VARCHAR:
    +        case BLOB:
    --- End diff --
    
    A question: Is it appropriate to blank-pad a BLOB? (It might be binary data, for example.)


---
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.
---