[ 
https://issues.apache.org/jira/browse/DERBY-5236?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Knut Anders Hatlen updated DERBY-5236:
--------------------------------------

    Attachment: d5236-2a-longer-strings.diff

Attached is a patch that improves the "write-full-string.diff" patch in the 
following ways:

- Truncate long strings to 65535 bytes to avoid overflow in the length field 
(which caused protocol errors)

- Align with character boundaries when truncating so that the server doesn't 
send invalid UTF-8 sequences to the client

- Add more test cases and move them into the existing 
derbynet.PrepareStatementTest

The patch still doesn't make the queries fail or add any warnings if the 
strings are truncated, but I think it can go in separately since it allows more 
strings to be sent untruncated, and those that are still truncated are sent as 
longer values than currently.

All the regression tests ran cleanly with the patch.

> 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
>            Assignee: Knut Anders Hatlen
>         Attachments: d5236-1a-client-fetch-complete.diff, 
> d5236-2a-longer-strings.diff, 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