Issue Details (XML | Word | Printable)

Key: DERBY-121
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: A B
Reporter: Lynh Nguyen
Votes: 0
Watchers: 0
Operations

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

Network Server reading blob/clob data size

Created: 15/Jan/05 11:13 AM   Updated: 04/Jun/05 04:30 PM
Return to search
Component/s: Network Server
Affects Version/s: 10.1.1.0
Fix Version/s: 10.1.1.0

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works derby-121_2.stat 2005-06-03 03:21 AM A B 1 kB
Text File Licensed for inclusion in ASF works derby-121_3.patch 2005-06-03 05:44 AM A B 20 kB
Environment: The is a bit shift typo in Network Server reading clob/blob data size

Resolution Date: 04/Jun/05 04:30 PM


 Description  « Hide
in DDMReader.java
...
... readLengthAndCodePoint() ... {
...

switch (numberOfExtendedLenBytes) {
case 8:
ddmScalarLen =
((buffer[pos++] & 0xff) << 64) +
((buffer[pos++] & 0xff) << 56) +
((buffer[pos++] & 0xff) << 48) +
((buffer[pos++] & 0xff) << 40) +
((buffer[pos++] & 0xff) << 32) +
((buffer[pos++] & 0xff) << 16) +
((buffer[pos++] & 0xff) << 8) +
((buffer[pos++] & 0xff) << 0);
adjustSize = 12;
break;
case 6:
ddmScalarLen =
((buffer[pos++] & 0xff) << 48) +
((buffer[pos++] & 0xff) << 40) +
((buffer[pos++] & 0xff) << 32) +
((buffer[pos++] & 0xff) << 16) +
((buffer[pos++] & 0xff) << 8) +
((buffer[pos++] & 0xff) << 0);
adjustSize = 10;
break;
case 4:
ddmScalarLen =
((buffer[pos++] & 0xff) << 32) +
((buffer[pos++] & 0xff) << 16) +
((buffer[pos++] & 0xff) << 8) +
((buffer[pos++] & 0xff) << 0);
adjustSize = 8;
break;
...
The shift bits should be in order:
0,8,16,24
0,8,16,24,32,40
0,8,16,24,32,40,48,56

This will only affect a lob if its length requires at least 24 bits--i.e. if the lob has a length of at least 2^24 bytes.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Kathey Marsden added a comment - 25/May/05 07:56 AM
A corresponding change also needs to be made for the client

A B added a comment - 03/Jun/05 03:21 AM
Attaching patch to test and resolve this issue. In order to test, I had to create a new suite (separate from "derbyall") since the test case requires more JVM heap size than usual. The actual fix for the problem is as given in the description for this defect--I made that fix in both the Network Server code and in the Derby Client.

A B made changes - 03/Jun/05 03:21 AM
Field Original Value New Value
Attachment derby-121_2.patch [ 20390 ]
Attachment derby-121_2.stat [ 20389 ]
A B made changes - 03/Jun/05 03:22 AM
Assignee A B [ army ]
A B made changes - 03/Jun/05 03:22 AM
Status Open [ 1 ] In Progress [ 3 ]
A B added a comment - 03/Jun/05 05:44 AM
Modified patch so that lobLengthTests.java uses a table name that correctly indicates the size of the test table we're using.

Also, per Kathey M's request, I'm including a "check-in comment" here:

----
1) Change Network Server and Derby Client code to do correct bit-shifting when processing the length of LOBs that are larger than 2^24 bytes (DERBY-121). 2) Add a new suite, "largeData", for running tests that require extra machine resources, and add the test for DERBY-121 to that suite (because the test for DERBY-121 requires extra heap memory for the server's JVM).
----

A B made changes - 03/Jun/05 05:44 AM
Attachment derby-121_3.patch [ 20392 ]
A B made changes - 03/Jun/05 05:47 AM
Description in DDMReader.java
...
... readLengthAndCodePoint() ... {
...

switch (numberOfExtendedLenBytes) {
case 8:
ddmScalarLen =
((buffer[pos++] & 0xff) << 64) +
((buffer[pos++] & 0xff) << 56) +
((buffer[pos++] & 0xff) << 48) +
((buffer[pos++] & 0xff) << 40) +
((buffer[pos++] & 0xff) << 32) +
((buffer[pos++] & 0xff) << 16) +
((buffer[pos++] & 0xff) << 8) +
((buffer[pos++] & 0xff) << 0);
adjustSize = 12;
break;
case 6:
ddmScalarLen =
((buffer[pos++] & 0xff) << 48) +
((buffer[pos++] & 0xff) << 40) +
((buffer[pos++] & 0xff) << 32) +
((buffer[pos++] & 0xff) << 16) +
((buffer[pos++] & 0xff) << 8) +
((buffer[pos++] & 0xff) << 0);
adjustSize = 10;
break;
case 4:
ddmScalarLen =
((buffer[pos++] & 0xff) << 32) +
((buffer[pos++] & 0xff) << 16) +
((buffer[pos++] & 0xff) << 8) +
((buffer[pos++] & 0xff) << 0);
adjustSize = 8;
break;
...
The shift bits should be in order:
0,8,16,24
0,8,16,24,32,40
0,8,16,24,32,40,48,56

This will only affect the larger clob/blob (over 64K ...)
in DDMReader.java
...
... readLengthAndCodePoint() ... {
...

switch (numberOfExtendedLenBytes) {
case 8:
ddmScalarLen =
((buffer[pos++] & 0xff) << 64) +
((buffer[pos++] & 0xff) << 56) +
((buffer[pos++] & 0xff) << 48) +
((buffer[pos++] & 0xff) << 40) +
((buffer[pos++] & 0xff) << 32) +
((buffer[pos++] & 0xff) << 16) +
((buffer[pos++] & 0xff) << 8) +
((buffer[pos++] & 0xff) << 0);
adjustSize = 12;
break;
case 6:
ddmScalarLen =
((buffer[pos++] & 0xff) << 48) +
((buffer[pos++] & 0xff) << 40) +
((buffer[pos++] & 0xff) << 32) +
((buffer[pos++] & 0xff) << 16) +
((buffer[pos++] & 0xff) << 8) +
((buffer[pos++] & 0xff) << 0);
adjustSize = 10;
break;
case 4:
ddmScalarLen =
((buffer[pos++] & 0xff) << 32) +
((buffer[pos++] & 0xff) << 16) +
((buffer[pos++] & 0xff) << 8) +
((buffer[pos++] & 0xff) << 0);
adjustSize = 8;
break;
...
The shift bits should be in order:
0,8,16,24
0,8,16,24,32,40
0,8,16,24,32,40,48,56

This will only affect a lob if its length requires at least 24 bits--i.e. if the lob has a length of at least 2^24 bytes.
A B made changes - 03/Jun/05 06:09 AM
Fix Version/s 10.1.0.0 [ 10993 ]
Repository Revision Date User Message
ASF #179859 Fri Jun 03 19:12:14 UTC 2005 kmarsden DERBY-121 - Network Server issue reading blob/clob data size

1) Change Network Server and Derby Client code to do correct bit-shifting when processing the length of LOBs that are larger than 2^24 bytes (DERBY-121). 2) Add a new suite, "largeData", for running tests that require extra machine resources, and add the test for DERBY-121 to that suite (because the test for DERBY-121 requires extra heap memory for the server's JVM).

Contributed by Army Brown
Files Changed
ADD /incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/lobLengthTests_app.properties
ADD /incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/lobLengthTests.java
MODIFY /incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMReader.java
MODIFY /incubator/derby/code/trunk/java/testing/build.xml
MODIFY /incubator/derby/code/trunk/java/testing/README.htm
ADD /incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/build.xml
ADD /incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/largeData.properties
MODIFY /incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/NetServer.java
ADD /incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/copyfiles.ant
ADD /incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/largeDataClient.properties
ADD /incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata
ADD /incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/largeDataTests.runall
MODIFY /incubator/derby/code/trunk/java/client/org/apache/derby/client/net/Reply.java
ADD /incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/lobLengthTests.out
ADD /incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/largeDataNet.properties

Kathey Marsden added a comment - 04/Jun/05 04:13 AM
Committed ...

Sending java\client\org\apache\derby\client\net\Reply.java
Sending java\drda\org\apache\derby\impl\drda\DDMReader.java
Sending java\testing\README.htm
Sending java\testing\build.xml
Sending java\testing\org\apache\derbyTesting\functionTests\harness\NetServer.java
Adding java\testing\org\apache\derbyTesting\functionTests\master\lobLengthTests.out
Adding java\testing\org\apache\derbyTesting\functionTests\suites\largeData.properties
Adding java\testing\org\apache\derbyTesting\functionTests\suites\largeDataClient.properties
Adding java\testing\org\apache\derbyTesting\functionTests\suites\largeDataNet.properties
Adding java\testing\org\apache\derbyTesting\functionTests\suites\largeDataTests.runall
Adding java\testing\org\apache\derbyTesting\functionTests\tests\largedata
Adding java\testing\org\apache\derbyTesting\functionTests\tests\largedata\build.xml
Adding java\testing\org\apache\derbyTesting\functionTests\tests\largedata\copyfiles.ant
Adding java\testing\org\apache\derbyTesting\functionTests\tests\largedata\lobLengthTests.java
Adding java\testing\org\apache\derbyTesting\functionTests\tests\largedata\lobLengthTests_app.properties
Transmitting file data ..............
Committed revision 179859.

A B made changes - 04/Jun/05 05:48 AM
Status In Progress [ 3 ] Open [ 1 ]
A B added a comment - 04/Jun/05 05:51 AM
Patch was committed with svn revision 179859. I updated my codeline and ran the new suite to double-check, and it looks good. So I'm resolving and closing this issue.

A B made changes - 04/Jun/05 05:52 AM
Status Open [ 1 ] Closed [ 6 ]
Andrew McIntyre added a comment - 04/Jun/05 04:29 PM
Reopening to fix resolved field in JIRA.

Andrew McIntyre made changes - 04/Jun/05 04:29 PM
Status Closed [ 6 ] Reopened [ 4 ]
Andrew McIntyre added a comment - 04/Jun/05 04:30 PM
Patch was committed with svn revision 179859. Closing.

Andrew McIntyre made changes - 04/Jun/05 04:30 PM
Status Reopened [ 4 ] Closed [ 6 ]
Resolution Fixed [ 1 ]