db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kristian Waagan (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DERBY-5489) getBinary() returns incorrect data after getObject() call on BLOB column
Date Tue, 01 Nov 2011 10:28:32 GMT

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

Kristian Waagan commented on DERBY-5489:
----------------------------------------

I think we decided to forbid accessing the same column (on the same row) multiple times for
streams and LOBs (I can't find the JIRA issue right now). It may be an oversight that getBytes
doesn't throw an exception in this case. The decision was based partly on the following text
for the Java API documentation for java.sql.ResultSet:
"For maximum portability, result set columns within each row should be read in left-to-right
order, and each column should be read only once."
getString appears to have the same issue.

A possible change/fix for the code above would be to cast obj to Blob and use one of the java.sql.Blob
methods to obtain the bytes. One could also rewrite the code to chose the correct action based
on metadata instead of the type of the object returned by getObject, I suppose.

I have not looked at actually fixing the Derby positioning bug itself.
                
> getBinary() returns incorrect data after getObject() call on BLOB column
> ------------------------------------------------------------------------
>
>                 Key: DERBY-5489
>                 URL: https://issues.apache.org/jira/browse/DERBY-5489
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.7.1.1, 10.8.2.2
>            Reporter: Pawel Fronczak
>         Attachments: SelectBlobBug.java
>
>
> When ResultSet.getObject(int) is called on a BLOB column, the correct EmbedBlob object
is returned. But if afterwards the ResultSet.getBytes(int) is called on the same row, the
returned array contains invalid data - it is offset by 3 bytes and its size is incorrect.
> The problem only occurs when the stored BLOB is large enough to be internally represented
by stream and not by array of bytes (at least ~32KiB).
> It seems that the getObject method shifts the stream position and therefore the getBytes
method starts to read the data after the third byte, thus incorrectly calculating its length.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message