You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Ben (Jira)" <ji...@apache.org> on 2022/07/01 13:59:00 UTC

[jira] [Updated] (DERBY-7143) HarmonySerialBlob.getBinaryStream(long, long) makes it impossible to retrieve the last character of the Blob.

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

Ben updated DERBY-7143:
-----------------------
    Description: 
As far as I understand it, the method HarmonySerialBlob.getBinaryStream(long, long) takes two arguments <pos> and <length> and is supposed to produce a ByteArrayInputStream() with a substring of the Blob's Contents that starts at <pos> and has length <length>.

Unfortunately, the error handling in this method makes it impossible to retrieve a suffix of the Blobs contents as the last character is always missing.

In detail:
When calling this method with <pos>=0, then it raises the SQLException XJ087. Hence, <pos> must always be > 0.
When calling this method with <pos>=1 and <length>=blob.length(), then it also raises the SQLException, because pos+length > blob.length(). Hence, <length> can at most be set to blob.length()-1.

When calling this method with <pos>=1 and <length>=blob.length()-1, then it gives a ByteArrayInputStream which is missing the last character from the blob.

The fact that the last character is missing makes sense, when <length> is set to blob.length()-1.

But it does not make sense to prohibit setting <length>=blob.length() when this is the only way to include the last character in the ByteArrayInputStream.

  was:
As far as I understand it, the method HarmonySerialBlob.getBinaryStream(long, long) takes two arguments <pos> and <length> and is supposed to produce a ByteArrayInputStream() with a substring of the Blob's Contents that starts at <pos> and has length <length>.

Unfortunately, the error handling in this method makes it impossible to retrieve the Blob's entire contents as the last character is always missing.

In detail:
When calling this method with <pos>=0, then it raises the SQLException XJ087. Hence, <pos> must always be > 0.
When calling this method with <pos>=1 and <length>=blob.length(), then it also raises the SQLException, because pos+length > blob.length(). Hence, <length> can at most be set to blob.length()-1.

When calling this method with <pos>=1 and <length>=blob.length()-1, then it gives a ByteArrayInputStream which is missing the last character from the blob.

The fact that the last character is missing makes sense, when <length> is set to blob.length()-1.

But it does not make sense to prohibit setting <length>=blob.length() when this is the only way to include the last character in the ByteArrayInputStream.


> HarmonySerialBlob.getBinaryStream(long, long) makes it impossible to retrieve the last character of the Blob.
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-7143
>                 URL: https://issues.apache.org/jira/browse/DERBY-7143
>             Project: Derby
>          Issue Type: Bug
>          Components: Network Client, SQL
>    Affects Versions: 10.15.2.0
>            Reporter: Ben
>            Priority: Major
>
> As far as I understand it, the method HarmonySerialBlob.getBinaryStream(long, long) takes two arguments <pos> and <length> and is supposed to produce a ByteArrayInputStream() with a substring of the Blob's Contents that starts at <pos> and has length <length>.
> Unfortunately, the error handling in this method makes it impossible to retrieve a suffix of the Blobs contents as the last character is always missing.
> In detail:
> When calling this method with <pos>=0, then it raises the SQLException XJ087. Hence, <pos> must always be > 0.
> When calling this method with <pos>=1 and <length>=blob.length(), then it also raises the SQLException, because pos+length > blob.length(). Hence, <length> can at most be set to blob.length()-1.
> When calling this method with <pos>=1 and <length>=blob.length()-1, then it gives a ByteArrayInputStream which is missing the last character from the blob.
> The fact that the last character is missing makes sense, when <length> is set to blob.length()-1.
> But it does not make sense to prohibit setting <length>=blob.length() when this is the only way to include the last character in the ByteArrayInputStream.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)