db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DERBY-5236) Client driver silently truncates strings that exceed 32KB
Date Thu, 26 May 2011 08:59:47 GMT

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

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

All the regression tests pass with the patch, but I don't think it's the correct solution.
At least not a complete solution.

The patch does make the repro pass, but that repro uses a string that's only 20000 characters
and needs 60000 bytes in UTF-8. But since a VARCHAR may contain up to ~32K characters, it
may need as much as 96KB when represented in UTF-8. But writeLDString() uses a two-byte length
field, so it can only be used for strings that take up to 64KB. If I change the repro to use
a 25000 character string that takes 75000 bytes, it still fails.

> 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

Mime
View raw message