db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r901760 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericParameterValueSet.java
Date Thu, 21 Jan 2010 16:23:22 GMT
Author: kristwaa
Date: Thu Jan 21 16:23:21 2010
New Revision: 901760

URL: http://svn.apache.org/viewvc?rev=901760&view=rev
Log:
DERBY-4455: Prepared statement failure with CLOB: Stream has already been read and end-of-file
reached and cannot be re-used.
Don't materialize streams when transferring data values from one statement to another.
The code causing the bug was/is only invoked when using XA.

Patch file: derby-4455-1c.diff


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericParameterValueSet.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericParameterValueSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericParameterValueSet.java?rev=901760&r1=901759&r2=901760&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericParameterValueSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericParameterValueSet.java
Thu Jan 21 16:23:21 2010
@@ -21,29 +21,21 @@
 
 package org.apache.derby.impl.sql;
 
-import org.apache.derby.iapi.services.loader.ClassFactory;
+import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.services.loader.ClassInspector;
-import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
-
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.reference.JDBC30Translation;
+import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.sql.ParameterValueSet;
-
 import org.apache.derby.iapi.types.DataTypeDescriptor;
-import org.apache.derby.iapi.types.DataValueFactory;
 import org.apache.derby.iapi.types.DataValueDescriptor;
 import org.apache.derby.iapi.types.UserDataValue;
-
-import org.apache.derby.iapi.reference.SQLState;
-
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.types.SQLBit;
+import org.apache.derby.iapi.types.SQLBlob;
+import org.apache.derby.iapi.types.SQLChar;
 
 import java.io.InputStream;
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
 import java.sql.Types;
-import org.apache.derby.iapi.reference.JDBC30Translation;
 
 /**
  * Implementation of ParameterValueSet
@@ -269,7 +261,24 @@
 
 			if (oldp.isSet)
 			{
-				pvstarget.getParameterForSet(i).setValue(oldp.getValue());
+                DataValueDescriptor dvd = oldp.getValue();
+                InputStream is = null;
+                // See if the value type can hold a stream.
+                // SQLBinary isn't public, check for both SQLBlob and SQLBit.
+                if (dvd instanceof SQLChar || dvd instanceof SQLBlob ||
+                        dvd instanceof SQLBit) {
+                    is = dvd.getStream();
+                }
+                if (is != null) {
+                    // DERBY-4455: Don't materialize the stream when
+                    // transferring it. If the stream has been drained already,
+                    // and the user doesn't set a new value before executing
+                    // the prepared statement again, Derby will fail.
+                    pvstarget.getParameterForSet(i).setValue(is,
+                            DataValueDescriptor.UNKNOWN_LOGICAL_LENGTH);
+                } else {
+                    pvstarget.getParameterForSet(i).setValue(dvd);
+                }
 			}
 		}
 	}



Mime
View raw message