[ http://issues.apache.org/jira/browse/DERBY-1516?page=all ]

Craig Russell updated DERBY-1516:
---------------------------------

    Attachment: DERBY-1516.patch

This patch solves the discrepancy between the treatment of getBytes and 
getSubString where the requested length is zero. This makes up 2 lines of the 
patch, in the first 10 lines of EmbedBlob and EmbedClob. Most of the rest of 
the patch is testing.

I've updated embedded and network Lobs to consistently check validity of 
position requested. The position must be between 1 and the last position of the 
Lob. I've added positive test cases for retrieving zero length byte[ ] and zero 
length Strings from position 1 and the last position of Blob and Clobs. 

I've added negative test cases for retrieving zero length byte[ ] and String 
from position 0 and one past the end of the Blob and Clob.

I've changed the message regarding invalid length so that zero length is not 
mentioned as an error.

I've removed the code to disable tests that was put in because of issues 5243 
and 5914. There is no longer any difference between the behavior of embedded 
and network drivers due to these issues. The canons for blobTest2, clobTest2, 
blobTest6, and clobTest6 are now the same for embedded and network.

I just had to reformat some of the test code which had random placement of 
beginning and ending braces, indentations, and try/catch formatting, and 
greater than 80 character lines. I removed commented-out code that represented 
the previous versions of clobTest2 and blobTest2.

I preserved the treatment of requests that started within the Lob but ran off 
the end. These cases still return a shorter result than requested, returning 
the last element of the Lob as the last element of the result. So there should 
be no backward compatibility issues. All the existing code will still work with 
this patch. 


> Inconsistent behavior for getBytes and getSubString for embedded versus 
> network
> -------------------------------------------------------------------------------
>
>                 Key: DERBY-1516
>                 URL: http://issues.apache.org/jira/browse/DERBY-1516
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>            Reporter: Craig Russell
>         Assigned To: Craig Russell
>            Priority: Minor
>         Attachments: DERBY-1516.patch, DERBY-1516.patch, DERBY-1516.patch, 
> DERBY-1516.patch
>
>
> org.apache.derby.client.am.Clob.getSubString(pos, length) and 
> org.apache.derby.client.am.Blob.getBytes(pos, length) check the length for 
> less than zero. 
>             if ((pos <= 0) || (length < 0)) {
>                 throw new SqlException(agent_.logWriter_, "Invalid position " 
> + pos + " or length " + length);
> But org.apache.derby.impl.jdbc.EmbedClob(pos, length) and 
> org.apache.derby.impl.jdbc.EmbedBlob(pos, length) check the length for less 
> than or equal to zero.
>        if (length <= 0)
>             throw Util.generateCsSQLException(
>                 SQLState.BLOB_NONPOSITIVE_LENGTH, new Integer(length));
> The specification does not disallow length of zero, so zero length should be 
> allowed. I believe that the implementation in org.apache.derby.client.am is 
> correct, and the implementation in org.apache.derby.impl.jdbc is incorrect. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to