db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r784701 - /db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLClob.java
Date Mon, 15 Jun 2009 09:35:07 GMT
Author: kristwaa
Date: Mon Jun 15 09:35:07 2009
New Revision: 784701

URL: http://svn.apache.org/viewvc?rev=784701&view=rev
Log:
DERBY-4245 (partial): Sorting a table containing a CLOB fails after upgrade to 10.5.
Fixes the NPE bug for both clean 10.5 databases and upgraded databases. Note
that there is a remaining bug for upgraded databases that will be fixed with a
subsequent patch under this issue.

Patch file: derby-4245-2a-sqlclob_fix.diff


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLClob.java

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=784701&r1=784700&r2=784701&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 Mon Jun 15 09:35:07
2009
@@ -236,11 +236,11 @@
         long charLength = 0;
         try {
             if (repositionStream) {
-                rewindStream(csd.getDataOffset());
+                rewindStream(stream, csd.getDataOffset());
             }
             charLength = UTF8Util.skipUntilEOF(stream);
             // We just drained the whole stream. Reset it.
-            rewindStream(0);
+            rewindStream(stream, 0);
         } catch (IOException ioe) {
             throwStreamingIOException(ioe);
         }
@@ -342,7 +342,7 @@
                 if (read > hdrInfo.headerLength()) {
                     // We have read too much. Reset the stream.
                     read = hdrInfo.headerLength();
-                    rewindStream(read);
+                    rewindStream(stream, read);
                 }
                 csd = new CharacterStreamDescriptor.Builder().stream(stream).
                     bufferable(false).positionAware(false).
@@ -686,11 +686,12 @@
                                             : (int)csd.getByteLength();
             hdrInfo = new HeaderInfo(hdrLen, valueLength);
             // Make sure the stream is correctly positioned.
-            rewindStream(hdrLen);
+            rewindStream((InputStream)in, hdrLen);
         } else {
-            final boolean markSet = stream.markSupported();
+            final InputStream srcIn = (InputStream)in;
+            final boolean markSet = srcIn.markSupported();
             if (markSet) {
-                stream.mark(MAX_STREAM_HEADER_LENGTH);
+                srcIn.mark(MAX_STREAM_HEADER_LENGTH);
             }
             byte[] header = new byte[MAX_STREAM_HEADER_LENGTH];
             int read = in.read(header);
@@ -707,11 +708,11 @@
                 if (markSet) {
                     // Stream is not a store Resetable one, use mark/reset
                     // functionality instead.
-                    stream.reset();
-                    InputStreamUtil.skipFully(stream, hdrInfo.headerLength());
-                } else if (stream instanceof Resetable) {
+                    srcIn.reset();
+                    InputStreamUtil.skipFully(srcIn, hdrInfo.headerLength());
+                } else if (in instanceof Resetable) {
                     // We have a store stream.
-                    rewindStream(hdrInfo.headerLength());
+                    rewindStream(srcIn, hdrInfo.headerLength());
                 }
             }
         }
@@ -763,14 +764,15 @@
      * Rewinds the stream to the beginning and then skips the specified number
      * of bytes.
      *
-     * @param pos number of bytes to skip
+     * @param in input stream to rewind
+     * @param offset number of bytes to skip
      * @throws IOException if resetting or reading from the stream fails
      */
-    private void rewindStream(long pos)
+    private void rewindStream(InputStream in, long offset)
             throws IOException {
         try {
-            ((Resetable)stream).resetStream();
-            InputStreamUtil.skipFully(stream, pos);
+            ((Resetable)in).resetStream();
+            InputStreamUtil.skipFully(in, offset);
         } catch (StandardException se) {
             IOException ioe = new IOException(se.getMessage());
             ioe.initCause(se);



Mime
View raw message