db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r916261 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/types/ engine/org/apache/derby/impl/jdbc/ engine/org/apache/derby/impl/sql/ engine/org/apache/derby/impl/sql/execute/ engine/org/apache/derby/loc/ shared/org/apache/derby/...
Date Thu, 25 Feb 2010 12:15:59 GMT
Author: kristwaa
Date: Thu Feb 25 12:15:58 2010
New Revision: 916261

URL: http://svn.apache.org/viewvc?rev=916261&view=rev
Log:
DERBY-4563: Avoid unnecessary use of getStream and getStreamWithDescriptor

Introduced the method DataValueDescriptor.hasStream() - use this method to check
if the data value is, or will be, represented by a stream.
Made DVD.getStream() and SDV.getStreamWithDescriptor() fail if hasStream returns
false (maybe this check can be removed, or made cheaper, in the near future?).

The reasoning behind the change is to make it easier to debug and investigate
issues concerned with incorrect stream state. If the stream is "leaked" from the
DVD, it is because it will be used to access the data. It will also be easier to
guarantee that the stream has a certain state, for instance that it is 
positioned just before the first byte of user data when returned from the DVD.
It may be expensive to re-position the stream, which is why getStream() != null
isn't the best way to check if the value is a stream. The need to re-position is
again caused by missing (or non-exposed) functionality in the stream coming from
store.

In most cases the stream should only be obtained once from a given DVD, but 
there are currently exceptions to the rule.

Patch file: derby-4563-1b-dvd_hasStream.diff

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLClob.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/StringDataValue.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement20.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericParameterValueSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java?rev=916261&r1=916260&r2=916261&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java Thu Feb 25 12:15:58
2010
@@ -231,6 +231,19 @@
 	}
 
     /**
+     * Tells that the value isn't represented as a stream, which is true for
+     * most Derby data types.
+     * <p>
+     * This method will be overridden by types able to use a stream as the
+     * source.
+     *
+     * @return {@code false}
+     */
+    public boolean hasStream() {
+        return false;
+    }
+
+    /**
      * Gets the value in the data stream descriptor as a trace string.
      * This default implementation simply forwards the call to
      * <code>getString</code>.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java?rev=916261&r1=916260&r2=916261&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java Thu
Feb 25 12:15:58 2010
@@ -273,16 +273,36 @@
 	 */
 	Object	getObject() throws StandardException;
 
-	/**
-	 * Gets the value in the data value descriptor as a Java InputStream.
-	 * Only data types that implements StreamStorable will have stream states.
-	 *
-	 * @return	The stream state of the data value.
-	 *
-	 * @exception StandardException   Throws an exception if the data value
-	 *								  cannot be received as a stream.
-	 */
-	InputStream	getStream() throws StandardException;
+    /**
+     * Gets the value in the data value descriptor as a stream of bytes.
+     * <p>
+     * Only data types that implement {@code StreamStorable} will have stream
+     * states, and the method {@code hasStream} should be called to determine
+     * if the value in question is, or will be, represented by a stream.
+     *
+     * @return The stream state of the data value.
+     * @throws StandardException Throws an exception if the data value
+     *      cannot be received as a stream.
+     *
+     * @see #hasStream()
+     * @see StringDataValue#getStreamWithDescriptor()
+     */
+    InputStream getStream() throws StandardException;
+
+    /**
+     * Tells if this data value is, or will be, represented by a stream.
+     * <p>
+     * This method should be called to determine if the methods {@code
+     * getStream} or {@code DataValueDescriptor.getStreamWithDescriptor} can
+     * be invoked.
+     *
+     * @return {@code true} if the value will be a stream, {@code false}
+     *      otherwise.
+     *
+     * @see #getStream()
+     * @see StringDataValue#getStreamWithDescriptor()
+     */
+    boolean hasStream();
 
     /**
      * Get a shallow copy of this {@code codeDataValueDescriptor} (DVD).

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java?rev=916261&r1=916260&r2=916261&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java Thu Feb 25
12:15:58 2010
@@ -211,6 +211,10 @@
 	 */
 	public final InputStream	getStream() throws StandardException
 	{
+        if (!hasStream()) {
+            throw StandardException.newException(
+                    SQLState.LANG_STREAM_INVALID_ACCESS, getTypeName());
+        }
 		return (stream);
 	}
 
@@ -1262,7 +1266,7 @@
         }
 
         // Check if we have a stream.
-        if (getStream() != null) {
+        if (hasStream()) {
             return (getTypeName() + "(" + getStream().toString() + ")");
         }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java?rev=916261&r1=916260&r2=916261&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java Thu Feb 25 12:15:58
2010
@@ -80,6 +80,16 @@
 	}
 
     /**
+     * Tells if this BLOB value is, or will be, represented by a stream.
+     *
+     * @return {@code true} if the value is represented by a stream,
+     *      {@code false} otherwise.
+     */
+    public boolean hasStream() {
+        return stream != null;
+    }
+
+    /**
      * Returns a clone of this BLOB value.
      * <p>
      * Unlike the other binary types, BLOBs can be very large. We try to clone

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java?rev=916261&r1=916260&r2=916261&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java Thu Feb 25 12:15:58
2010
@@ -566,24 +566,25 @@
     /**
      * @exception StandardException     Thrown on error
      */
-    public InputStream  getStream() throws StandardException
-    {
+    public InputStream  getStream() throws StandardException {
+        if (!hasStream()) {
+            throw StandardException.newException(
+                    SQLState.LANG_STREAM_INVALID_ACCESS, getTypeName());
+        }
         return stream;
     }
 
     /**
      * Returns a descriptor for the input stream for this character data value.
      *
-     * @return Unless the method is overridden, {@code null} is returned.
-     * @throws StandardException if obtaining the descriptor fails
+     * @return Nothing, throws exception.
+     * @throws StandardException if the value isn't represented by a stream
      * @see SQLClob#getStreamWithDescriptor()
      */
     public CharacterStreamDescriptor getStreamWithDescriptor()
             throws StandardException {
-        // For now return null for all non-Clob types.
-        // TODO: Is this what we want, or do we want to treat some of the other
-        //       string types as streams as well?
-        return null;
+        throw StandardException.newException(
+                SQLState.LANG_STREAM_INVALID_ACCESS, getTypeName());
     }
 
     /**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLClob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLClob.java?rev=916261&r1=916260&r2=916261&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLClob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLClob.java Thu Feb 25 12:15:58
2010
@@ -350,7 +350,8 @@
             // Lazily reset the descriptor here, to avoid further changes in
             // {@code SQLChar}.
             csd = null;
-            return null;
+            throw StandardException.newException(
+                    SQLState.LANG_STREAM_INVALID_ACCESS, getTypeName());
         }
         // NOTE: Getting down here several times is potentially dangerous.
         // When the stream is published, we can't assume we know the position
@@ -421,6 +422,16 @@
         return this.csd;
     }
 
+    /**
+     * Tells if this CLOB value is, or will be, represented by a stream.
+     *
+     * @return {@code true} if the value is represented by a stream,
+     *      {@code false} otherwise.
+     */
+    public boolean hasStream() {
+        return stream != null;
+    }
+
 	public Time	getTime(java.util.Calendar cal) throws StandardException
 	{
 		throw dataTypeConversion("java.sql.Time");
@@ -443,7 +454,7 @@
         }
 
         // Check if we have a stream.
-        if (getStream() != null) {
+        if (hasStream()) {
             return (getTypeName() + "(" + getStream().toString() + ")");
         }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/StringDataValue.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/StringDataValue.java?rev=916261&r1=916260&r2=916261&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/StringDataValue.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/StringDataValue.java Thu Feb
25 12:15:58 2010
@@ -229,9 +229,9 @@
      * is capable of repositioning itself.
      *
      * @return A descriptor for the stream, which includes a reference to the
-     *      stream itself, or {@code null} if the value cannot be represented
-     *      as a stream.
-     * @throws StandardException if obtaining the descriptor fails
+     *      stream itself.
+     * @throws StandardException if obtaining the descriptor fails, or if the
+     *      value isn't represented as a stream.
      */
     public CharacterStreamDescriptor getStreamWithDescriptor()
             throws StandardException;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java?rev=916261&r1=916260&r2=916261&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java Thu Feb 25 12:15:58
2010
@@ -172,8 +172,9 @@
                stream and store it temporarily until it is either discarded or
                inserted into the database.
          */
-        InputStream dvdStream = dvd.getStream();
-        if (dvdStream == null) { // a) Blob already materialized in memory
+        if (dvd.hasStream()) { // Cases b) and c)
+            streamPositionOffset = handleStreamValue(dvd.getStream(), con);
+        } else { // a) Blob already materialized in memory
             materialized = true;
             streamPositionOffset = Integer.MIN_VALUE;
             // copy bytes into memory so that blob can live after result set
@@ -189,7 +190,29 @@
                 throw StandardException.newException (
                                         SQLState.SET_STREAM_FAILURE, e);
             }
-        } else if (dvdStream instanceof Resetable) { // b) Resetable stream
+        }
+        //add entry in connection so it can be cleared 
+        //when transaction is not valid
+        con.addLOBReference (this);
+    }
+
+
+    /**
+     * Constructs a Blob object on top of a stream.
+     *
+     * @param dvdStream the source stream
+     * @param con the connection owning the Blob
+     * @return The offset into the stream where the user data begins (used if
+     *      resetting the stream).
+     * @throws StandardException if accessing the stream fails, or if writing
+     *      data to temporary storage fails
+     */
+    private int handleStreamValue(InputStream dvdStream, EmbedConnection con)
+            throws StandardException {
+        int offset = 0;
+        // b) Resetable stream
+        //    In this case the stream is coming from the Derby store.
+        if (dvdStream instanceof Resetable) {
             materialized = false;
 
             /*
@@ -210,7 +233,7 @@
                 // The BinaryToRawStream will read the encoded length bytes.
                 BinaryToRawStream tmpStream =
                         new BinaryToRawStream(myStream, con);
-                streamPositionOffset = (int)myStream.getPosition();
+                offset = (int)myStream.getPosition();
                 // Check up front if the stream length is specified.
                 streamLength = tmpStream.getLength();
                 tmpStream.close();
@@ -225,7 +248,10 @@
                 throw StandardException.newException(
                      SQLState.LANG_STREAMING_COLUMN_I_O_EXCEPTION, ioe, "BLOB");
             }
-        } else { // c) Non-resetable stream
+        // c) Non-resetable stream
+        //    This is most likely a stream coming in from the user, and we
+        //    don't have any guarantees on how it behaves.
+        } else {
             // The code below will only work for RawToBinaryFormatStream.
             if (SanityManager.DEBUG) {
                 SanityManager.ASSERT(
@@ -235,7 +261,7 @@
             // The source stream isn't resetable, so we have to write it to a
             // temporary location to be able to support the Blob operations.
             materialized = true;
-            streamPositionOffset = Integer.MIN_VALUE;
+            offset = Integer.MIN_VALUE;
             try {
                 control = new LOBStreamControl(getEmbedConnection());
                 BinaryToRawStream tmpStream =
@@ -259,12 +285,9 @@
                                         SQLState.SET_STREAM_FAILURE, ioe);
             }
         }
-        //add entry in connection so it can be cleared 
-        //when transaction is not valid
-        con.addLOBReference (this);
+        return offset;
     }
 
-
     /**
      * Sets the position of the Blob to {@code logicalPos}, where position 0 is
      * the beginning of the Blob content.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement20.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement20.java?rev=916261&r1=916260&r2=916261&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement20.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement20.java
Thu Feb 25 12:15:58 2010
@@ -1132,12 +1132,12 @@
                     pushStack = true;
                     setupContextStack();
 
-                    CharacterStreamDescriptor csd =
+                    if (param.hasStream()) {
+                        CharacterStreamDescriptor csd =
                             param.getStreamWithDescriptor();
-                    if (csd == null) {
-                        reader = new StringReader(param.getString());
-                    } else {
                         reader = new UTF8Reader(csd, this, syncObject);
+                    } else {
+                        reader = new StringReader(param.getString());
                     }
                 } catch (Throwable t) {
                     throw EmbedResultSet.noStateChangeException(t);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java?rev=916261&r1=916260&r2=916261&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java Thu Feb 25 12:15:58
2010
@@ -111,21 +111,9 @@
             SanityManager.ASSERT(!dvd.isNull(),
                                  "clob is created on top of a null column");
 
-        CharacterStreamDescriptor csd = dvd.getStreamWithDescriptor();
         // See if a String or a stream will be the source of the Clob.
-        if (csd == null) {
-            try {
-                clob = new TemporaryClob(dvd.getString(),
-                        this);
-            }
-            catch (SQLException sqle) {
-                throw StandardException.newException (sqle.getSQLState(), sqle);
-            }
-            catch (IOException e) {
-                throw StandardException.newException (
-                                        SQLState.SET_STREAM_FAILURE, e);
-            }
-        } else {
+        if (dvd.hasStream()) {
+            CharacterStreamDescriptor csd = dvd.getStreamWithDescriptor();
             /*
              We are expecting this stream to be a FormatIdInputStream with an
              OverflowInputStream inside. FormatIdInputStream implements
@@ -151,6 +139,18 @@
                 }
                 throw se;
             }
+        } else {
+            try {
+                clob = new TemporaryClob(dvd.getString(),
+                        this);
+            }
+            catch (SQLException sqle) {
+                throw StandardException.newException (sqle.getSQLState(), sqle);
+            }
+            catch (IOException e) {
+                throw StandardException.newException (
+                                        SQLState.SET_STREAM_FAILURE, e);
+            }
         }
         con.addLOBReference (this);
     }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java?rev=916261&r1=916260&r2=916261&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java Thu Feb
25 12:15:58 2010
@@ -1135,26 +1135,24 @@
 			pushStack = true;
 			setupContextStack();
 
-            CharacterStreamDescriptor csd = dvd.getStreamWithDescriptor();
-
-            if (csd == null) {
-
+            java.io.Reader ret; // The reader we will return to the user
+            if (dvd.hasStream()) {
+                CharacterStreamDescriptor csd = dvd.getStreamWithDescriptor();
+                // See if we have to enforce a max field size.
+                if (lmfs > 0) {
+                    csd = new CharacterStreamDescriptor.Builder().copyState(csd).
+                            maxCharLength(lmfs).build();
+                }
+                ret = new UTF8Reader(csd, this, syncLock);
+            } else {
 				String val = dvd.getString();
 				if (lmfs > 0) {
 					if (val.length() > lmfs)
 						val = val.substring(0, lmfs);
 				}
-				java.io.Reader ret = new java.io.StringReader(val);
-				currentStream = ret;
-				return ret;
-			}
-
-            // See if we have to enforce a max field size.
-            if (lmfs > 0) {
-                csd = new CharacterStreamDescriptor.Builder().copyState(csd).
-                        maxCharLength(lmfs).build();
+                ret = new java.io.StringReader(val);
             }
-            java.io.Reader ret = new UTF8Reader(csd, this, syncLock);
+
 			currentStream = ret;
 			return ret;
 
@@ -3976,7 +3974,7 @@
 				// should set up a context stack if we have a long column,
 				// since a blob may keep a pointer to a long column in the
 				// database
-				if (dvd.getStream() != null)
+				if (dvd.hasStream())
 					pushStack = true;
 
 				if (pushStack)
@@ -4027,14 +4025,12 @@
 				if (wasNull = dvd.isNull())
 					return null;
 
-				// should set up a context stack if we have a long column,
-				// since a Clob may keep a pointer to a long column in the
-				// database
-				if (dvd.getStream() != null)
-					pushStack = true;
-
-				if (pushStack)
-					setupContextStack();
+                // Set up a context stack if we have CLOB whose value is a long
+                // column in the database.
+                if (dvd.hasStream()) {
+                    pushStack = true;
+                    setupContextStack();
+                }
 
                 return new EmbedClob(getEmbedConnection(), dvd);
 			} catch (Throwable t) {

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=916261&r1=916260&r2=916261&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 Feb 25 12:15:58 2010
@@ -264,17 +264,12 @@
                 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) {
+                if (dvd.hasStream()) {
                     // 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,
+                    pvstarget.getParameterForSet(i).setValue(dvd.getStream(),
                             DataValueDescriptor.UNKNOWN_LOGICAL_LENGTH);
                 } else {
                     pvstarget.getParameterForSet(i).setValue(dvd);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java?rev=916261&r1=916260&r2=916261&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ProjectRestrictResultSet.java
Thu Feb 25 12:15:58 2010
@@ -517,7 +517,7 @@
 
                 // See if the column has been marked for cloning.
                 // If the value isn't a stream, don't bother cloning it.
-                if (cloneMap[index] && dvd.getStream() != null) {
+                if (cloneMap[index] && dvd.hasStream()) {
                     dvd = dvd.cloneValue(false);
                 }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml?rev=916261&r1=916260&r2=916261&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml Thu Feb 25 12:15:58
2010
@@ -6157,6 +6157,12 @@
             </msg>
 
             <msg>
+                <name>42Z12.U</name>
+                <text>Internal error: Invalid attempt to access a {0} as a stream</text>
+                <arg>dataType</arg>
+            </msg>
+
+            <msg>
                 <name>42Z30.U</name>
                 <text>time spent in this ResultSet =</text>
             </msg>

Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java?rev=916261&r1=916260&r2=916261&view=diff
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
(original)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
Thu Feb 25 12:15:58 2010
@@ -1012,6 +1012,7 @@
 	String LANG_COLUMN_DEFAULT										   = "42Z09.U";
 	String LANG_UDT_BUILTIN_CONFLICT										   = "42Z10";
 	String LANG_STREAM												   = "42Z11.U";
+    String LANG_STREAM_INVALID_ACCESS                                  = "42Z12.U";
 
 	// String LANG_UPDATABLE_VTI_BAD_GETMETADATA						   = "42Z14";
 



Mime
View raw message