[ 
https://issues.apache.org/jira/browse/DERBY-5236?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13058611#comment-13058611
 ] 

Knut Anders Hatlen commented on DERBY-5236:
-------------------------------------------

I think we could do that. I'll refresh the patch, as I think in its current 
form it might have made some existing bad behaviour slightly worse. That is, if 
we get an overflow in the length field, the string will be truncated even more 
than it was before. Perhaps we should raise an exception in case of an 
overflow? Sounds better than silently returning the wrong result, IMO.

By the way, I did a quick check of the DRDA spec back when I looked into this 
issue, and I found some indications that this length field was supposed to 
contain the number of characters, not the number of bytes. If that turns out to 
be the case, the two-byte field should be sufficient for all VARCHARs with the 
current ~32K limit. Whether we can change the meaning of the length field 
without breaking client/server compatibility is another question...

> Client driver silently truncates strings that exceed 32KB
> ---------------------------------------------------------
>
>                 Key: DERBY-5236
>                 URL: https://issues.apache.org/jira/browse/DERBY-5236
>             Project: Derby
>          Issue Type: Bug
>          Components: Network Client
>    Affects Versions: 10.8.1.2
>            Reporter: Knut Anders Hatlen
>         Attachments: repro.diff, write-full-string.diff
>
>
> Can be seen with this JUnit test case that retrieves a VARCHAR value with 
> 20000 characters. With the client driver, the string is truncated to 10900 
> characters (32700 bytes when encoded in UTF-8).
>     public void testLongColumn() throws SQLException {
>         PreparedStatement ps = prepareStatement(
>                 "values cast(? as varchar(20000))");
>         char[] chars = new char[20000];
>         Arrays.fill(chars, '\u4e10');
>         String str = new String(chars);
>         ps.setString(1, str);
>         JDBC.assertSingleValueResultSet(ps.executeQuery(), str);
>     }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to