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

Reply via email to