[ http://issues.apache.org/jira/browse/DERBY-1516?page=comments#action_12426707 ] Craig Russell commented on DERBY-1516: --------------------------------------
Hi Dan, Thanks for your comments. > I mean comments clarifying the length & position arguments passed in and the > valid ranges etc. Though while you were in there you could see if the > description was correct, e.g. EmbedClob.getSubString() says: > NOTE: return the empty string if pos is too large > which I don't think is true before or after your changes. I think I understand your comments and will try to update the comments to reflect reality. > Why length +1, why not > length? If 0 < pos <= length, then there is no way to get any bytes (even zero bytes) from a 0-length blob. And I don't believe that this is the intent. Nor is it consistent with what other vendors have implemented. There is no loss of functionality in the "length + 1" behavior. If your position is length + 1, then you can only get zero-length results from it. And this is exactly the case of a zero-length Lob. The title of this issue is "inconsistent behavior for embedded versus network". So something's gotta give. And after looking at it in detail, I'm convinced that the right behavior is to be consistent with regard to getBytes and getSubString; with regard to zero-length and non-zero-length Lobs; and with regard to embedded versus network. And this patch does it. > 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, 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
