db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig Russell (JIRA)" <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-1516) Inconsistent behavior for getBytes and getSubString for embedded versus network
Date Wed, 02 Aug 2006 18:50:14 GMT
    [ http://issues.apache.org/jira/browse/DERBY-1516?page=comments#action_12425340 ] 
Craig Russell commented on DERBY-1516:

There is different behavior between embedded and network in other areas as well as the one
I'm looking at here. I'd like to see what people think about this as well. It's hard to add
test cases for zero-length requests without rationalizing the current behavior.

1. Both embedded and network do not return an error but truncate the result when going past
the end of the Clob. That is, ask a Clob with length 25 for 50 characters starting at position
1 and get 26 characters and no exception.

Proposal: Leave this behavior; we would need to add a new message, since the current message
"SQLSTATE(XJ076): The position argument '5,910' exceeds the size of the BLOB/CLOB" cannot
be used to describe running off the end of the Clob. I'd like to see this changed in future,
to match the java.lang.String behavior, but this is a compatibility issue (existing applications
might depend on this behavior).

2. Different behavior for zero-length Clobs:
Embedded Clob with zero length: throws an exception trying to get any non-zero length substring
Network Clob with zero length throws an exception only if the position is not == 1.

Proposal: Change Network to throw an exception on any request to get a non-zero length substring.


> 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
> 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


View raw message