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] [Updated] (DERBY-5236) Client driver silently truncates strings that exceed 32KB
Date Thu, 08 Sep 2011 12:48:09 GMT

     [ 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-3a-warning.diff

I don't see a quick solution to get the entire string sent to the client, so I'm adding a
patch that adds a java.sql.DataTruncation warning to the result instead for now.

The server adds warnings before the row data. However, we don't know until after we've tried
writing the data whether we had to truncate any values. Because of this, I've changed the
server code to save the position of the SQLCAGRP section in which the warnings are written,
and if it detects that data was truncated, it goes back and overwrites it with the data truncation
warnings later.

On the client side, some changes were needed for it to correctly deserialize a java.sql.DataTruncation
object. It wouldn't break without these changes, but it would create an ordinary SQLWarning
instead of DataTruncation. The DataTruncation object has fields so that the caller can find
out exactly which column was truncated, and by how much.

Unfortunately, the server isn't capable of sending chained warnings yet, so in the case of
multiple columns being truncated, we only get a warning for the first one. But that's another

The patch also makes the test verify that the proper DataTruncation warnings are received,
and a test case that verifies that it also works as expected with output parameters in stored
procedures has been added.

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


View raw message