Issue Details (XML | Word | Printable)

Key: DERBY-4040
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Kristian Waagan
Reporter: Kristian Waagan
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

SQLChar.getLength returns wrong length for some data values

Created: 30/Jan/09 12:04 PM   Updated: 01/Jul/09 04:25 PM
Component/s: SQL
Affects Version/s: 10.3.3.1, 10.4.2.0, 10.5.1.1
Fix Version/s: 10.3.3.1, 10.4.2.1, 10.5.1.1

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works derby-4040-1a-SQLChar_length_and_test.diff 2009-02-03 12:09 PM Kristian Waagan 9 kB
File Licensed for inclusion in ASF works derby-4040-1a-SQLChar_length_and_test.stat 2009-02-03 12:09 PM Kristian Waagan 0.2 kB
File Licensed for inclusion in ASF works derby-4040-2a-backport.diff 2009-02-18 05:02 PM Kristian Waagan 8 kB
Issue Links:
Reference
 

Bug behavior facts: Regression, Wrong query result
Resolution Date: 19/Feb/09 10:47 AM
Labels:


 Description  « Hide
SQLChar.getLength() returns the wrong length of the data value in some cases.
For the bug to be triggered, the value must contain characters that are represented by two or three bytes, and Derby must store the value as a stream.

In my ad-hoc testing, I found that a value of length 10886 with CJK characters doesn't trigger the bug, but 10887 does trigger the bug. Further, for a range of lengths the bug can also been observed for CLOB columns (when doing 'select length(clobcolumn)').

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Kristian Waagan added a comment - 30/Jan/09 12:10 PM
Bug was introduced by a checkin for DERBY-3741.

Kristian Waagan added a comment - 03/Feb/09 12:09 PM
 'derby-4040-1a-SQLChar_length_and_test.diff' fixes the bug by always decoding the stream is the data value is stored as a stream, and it also adds a few more tests (adjusted existing test).
The bug was that the byte length was used as a character length. Since these two lengths are the same for ASCII data values, it wasn't detected earlier. The limited range of the length information in the header helped conceal the bug too.

Ran regression tests without failures. I'll look at backporting the fix when it has made it into trunk.
Patch ready for review.

Kristian Waagan added a comment - 09/Feb/09 09:42 AM
Committed patch 1a to trunk with revision 742357.

Kristian Waagan added a comment - 18/Feb/09 05:02 PM
Attached the diff for the backport, 'derby-4040-2a-backport.diff'.
I had to do a manual merge, as the method InputStreamUtil.skipFully doesn't exist on the 10.4 and 10.3 branches. Instead of using that method, I simply chose to use InputStream.skip.
Regression tests ran successfully.

Committed to the 10.4 branch with revision 745571.

Kristian Waagan added a comment - 19/Feb/09 10:47 AM
Backported the fix from 10.4 to the 10.3 branch with revision 745811.

The tinderbox test for 10.4 ran cleanly.
I'm resolving the issue, and will await the tinderbox results from 10.3 before I close.

Kristian Waagan added a comment - 20/Feb/09 08:32 AM
10.3 tinderbox ran without any new failures (lang/subquery did fail).

Closing issue.