db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r673454 - in /db/derby/code/branches/10.4: ./ java/engine/org/apache/derby/iapi/types/ java/testing/org/apache/derbyTesting/functionTests/suites/ java/testing/org/apache/derbyTesting/functionTests/tests/memory/
Date Wed, 02 Jul 2008 18:18:08 GMT
Author: kmarsden
Date: Wed Jul  2 11:18:07 2008
New Revision: 673454

URL: http://svn.apache.org/viewvc?rev=673454&view=rev
Log:
DERBY-3732 SQL Length function materializes BLOB into memory

port revision 672818 from trunk


Added:
    db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/memory/BlobMemTest.java
      - copied, changed from r672818, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/BlobMemTest.java
    db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/memory/_Suite.java
      - copied unchanged from r672818, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/_Suite.java
Modified:
    db/derby/code/branches/10.4/build.xml
    db/derby/code/branches/10.4/java/engine/org/apache/derby/iapi/types/SQLBinary.java
    db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/AllPackages.java

Modified: db/derby/code/branches/10.4/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/build.xml?rev=673454&r1=673453&r2=673454&view=diff
==============================================================================
--- db/derby/code/branches/10.4/build.xml (original)
+++ db/derby/code/branches/10.4/build.xml Wed Jul  2 11:18:07 2008
@@ -1978,6 +1978,33 @@
       </junit>	
   </target>
 
+	  
+  <!-- low memory suite runs with 16MB heap  -->
+  <target name="junit-lowmem"  depends="checkVMLevel,junit-init" if="vmLevelIsAtLeast1.5">
+    <condition property="derby.junit.classpath" value="">
+      <not>
+        <isset property="derby.junit.classpath"/>
+      </not>
+    </condition>
+  	 <junit printsummary="on"
+           fork="yes" forkmode="perTest"
+           jvm="${derby.junit.jvm}" maxmemory="16m"
+           showoutput="yes"
+           dir="junit_${derby.junit.timestamp}"
+           tempdir="junit_${derby.junit.timestamp}"
+  	 	   errorproperty="tests.failed"
+  	       failureproperty="tests.failed">
+      <formatter type="xml"/>
+  	 	
+      <test name="org.apache.derbyTesting.functionTests.tests.memory._Suite"
+      	todir="junit_${derby.junit.timestamp}"/>
+        <classpath>
+       	    <pathelement path="${derby.junit.classpath}"/>
+            <pathelement location="${javatools.dir}/junit.jar"/>
+        </classpath>
+      </junit>	
+  </target>
+
   <!-- Runs Derby's JMX tests if the required VM level (1.5 or higher) is detected -->
   <target name="junit-jmx" depends="checkVMLevel,junit-init" if="vmLevelIsAtLeast1.5">
     <junit  printsummary="on"
@@ -2056,7 +2083,7 @@
       
   </target>
    
-  <target name="junit-all" depends="junit-core,junit-jdbc4,junit-jmx">
+  <target name="junit-all" depends="junit-core,junit-jdbc4,junit-jmx,junit-lowmem">
   </target>
  
   <target name="junitreport" depends="junit-sysinfo,junit-all">

Modified: db/derby/code/branches/10.4/java/engine/org/apache/derby/iapi/types/SQLBinary.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/iapi/types/SQLBinary.java?rev=673454&r1=673453&r2=673454&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/iapi/types/SQLBinary.java (original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/iapi/types/SQLBinary.java Wed
Jul  2 11:18:07 2008
@@ -229,7 +229,7 @@
 		}
 		catch (IOException ioe)
 		{
-			throw StandardException.newException(SQLState.LANG_STREAMING_COLUMN_I_O_EXCEPTION, ioe,
getTypeName());
+			throwStreamingIOException(ioe);
 		}
 		return dataValue;
 	}
@@ -242,12 +242,49 @@
 	public final int	getLength() throws StandardException
 	{
 		if (stream != null) {
-
 			if (streamValueLength != -1)
 				return streamValueLength;
+			else if (stream instanceof Resetable){
+				try {
+					// If we have the stream length encoded.
+					// just read that.
+					streamValueLength = readBinaryLength((ObjectInput) stream);
+					if (streamValueLength != 0)
+						return streamValueLength;
+					// Otherwise we will have to read the whole stream.
+					for (;;) {
+						long skipsize = stream.skip(Integer.MAX_VALUE);
+						streamValueLength += skipsize;
+						if (stream.read() == -1)
+							break;
+						else
+							streamValueLength++;
+					}
+					return streamValueLength;
+				}
+				catch (IOException ioe) {
+					throwStreamingIOException(ioe);
+				}
+				finally {
+					try {
+						((Resetable) stream).resetStream();
+					} catch (IOException ioe) {
+						throwStreamingIOException(ioe);
+					}
+				}
+				
+			}
 		}
+		byte[] bytes = getBytes();
+		return (bytes == null) ? 0 : bytes.length;
+		
+	}
+
 
-		return (getBytes() == null) ? 0 : getBytes().length;
+	private void throwStreamingIOException(IOException ioe) throws StandardException {
+		throw StandardException.
+			newException(SQLState.LANG_STREAMING_COLUMN_I_O_EXCEPTION,
+						 ioe, getTypeName());
 	}
 
 	/*

Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/AllPackages.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/AllPackages.java?rev=673454&r1=673453&r2=673454&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/AllPackages.java
(original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/AllPackages.java
Wed Jul  2 11:18:07 2008
@@ -59,6 +59,7 @@
 	 suite.addTest(org.apache.derbyTesting.functionTests.tests.tools._Suite.suite());
         suite.addTest(org.apache.derbyTesting.functionTests.tests.engine._Suite.suite());
         suite.addTest(org.apache.derbyTesting.functionTests.tests.demo._Suite.suite());
+        suite.addTest(org.apache.derbyTesting.functionTests.tests.memory._Suite.suite());
 
         // Suites that are compiled using Java SE 6 target need to
         // be added this way, otherwise creating the suite

Copied: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/memory/BlobMemTest.java
(from r672818, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/BlobMemTest.java)
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/memory/BlobMemTest.java?p2=db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/memory/BlobMemTest.java&p1=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/BlobMemTest.java&r1=672818&r2=673454&rev=673454&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/BlobMemTest.java
(original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/memory/BlobMemTest.java
Wed Jul  2 11:18:07 2008
@@ -72,7 +72,7 @@
      * @throws IllegalArgumentException 
      */
     private void testBlobLength(boolean lengthless) throws SQLException, IOException, IllegalArgumentException,
IllegalAccessException, InvocationTargetException {
-        setAutoCommit(false);
+        getConnection().setAutoCommit(false);
         Statement s = createStatement();
         s.executeUpdate("CREATE TABLE BLOBTAB (K INT CONSTRAINT PK PRIMARY KEY, B BLOB("
+ LONG_BLOB_LENGTH + "))");
         



Mime
View raw message