You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2005/10/07 02:07:58 UTC
svn commit: r306965 - in /db/derby/code/branches/10.1/java:
engine/org/apache/derby/iapi/reference/ engine/org/apache/derby/impl/jdbc/
engine/org/apache/derby/loc/
testing/org/apache/derbyTesting/functionTests/master/
testing/org/apache/derbyTesting/fu...
Author: kmarsden
Date: Thu Oct 6 17:07:49 2005
New Revision: 306965
URL: http://svn.apache.org/viewcvs?rev=306965&view=rev
Log:
DERBY-562 Derby incorrectly throws Exception when streaming to BLOB field
Merged from trunk with:
svn merge -r 292829:292830 https://svn.apache.org/repos/asf/db/derby/code/trunk
Contributed by Sunitha Kambhampati
Modified:
db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/reference/SQLState.java
db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/jdbc/RawToBinaryFormatStream.java
db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/jdbc/ReaderToUTF8Stream.java
db/derby/code/branches/10.1/java/engine/org/apache/derby/loc/messages_en.properties
db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/characterStreams.out
db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/resultsetStream.out
db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/characterStreams.java
Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/reference/SQLState.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/reference/SQLState.java?rev=306965&r1=306964&r2=306965&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/reference/SQLState.java (original)
+++ db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/reference/SQLState.java Thu Oct 6 17:07:49 2005
@@ -1357,7 +1357,7 @@
String TYPE_MISMATCH = "XJ020.S";
String INVALID_JDBCTYPE = "XJ021.S";
String SET_STREAM_FAILURE = "XJ022.S";
- String SET_STREAM_INSUFFICIENT_DATA = "XJ023.S";
+ String SET_STREAM_INEXACT_LENGTH_DATA = "XJ023.S";
String SET_UNICODE_INVALID_LENGTH = "XJ024.S";
String NEGATIVE_STREAM_LENGTH = "XJ025.S";
String NO_AUTO_COMMIT_ON = "XJ030.S";
Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/jdbc/RawToBinaryFormatStream.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/jdbc/RawToBinaryFormatStream.java?rev=306965&r1=306964&r2=306965&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/jdbc/RawToBinaryFormatStream.java (original)
+++ db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/jdbc/RawToBinaryFormatStream.java Thu Oct 6 17:07:49 2005
@@ -79,7 +79,7 @@
int remainingBytes = clearLimit();
if (remainingBytes > 0)
- throw new IOException(MessageService.getTextMessage(SQLState.SET_STREAM_INSUFFICIENT_DATA));
+ throw new IOException(MessageService.getTextMessage(SQLState.SET_STREAM_INEXACT_LENGTH_DATA));
// if we had a limit try reading one more byte.
// JDBC 3.0 states the stream muct have the correct number of characters in it.
@@ -93,7 +93,7 @@
c = -1;
}
if (c >= 0)
- throw new IOException(MessageService.getTextMessage(SQLState.SET_STREAM_INSUFFICIENT_DATA));
+ throw new IOException(MessageService.getTextMessage(SQLState.SET_STREAM_INEXACT_LENGTH_DATA));
}
}
Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/jdbc/ReaderToUTF8Stream.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/jdbc/ReaderToUTF8Stream.java?rev=306965&r1=306964&r2=306965&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/jdbc/ReaderToUTF8Stream.java (original)
+++ db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/jdbc/ReaderToUTF8Stream.java Thu Oct 6 17:07:49 2005
@@ -160,7 +160,7 @@
int remainingBytes = reader.clearLimit();
if (remainingBytes > 0)
- throw new IOException(MessageService.getTextMessage(SQLState.SET_STREAM_INSUFFICIENT_DATA));
+ throw new IOException(MessageService.getTextMessage(SQLState.SET_STREAM_INEXACT_LENGTH_DATA));
// if we had a limit try reading one more character.
// JDBC 3.0 states the stream muct have the correct number of characters in it.
@@ -174,7 +174,7 @@
c = -1;
}
if (c >= 0)
- throw new IOException(MessageService.getTextMessage(SQLState.SET_STREAM_INSUFFICIENT_DATA));
+ throw new IOException(MessageService.getTextMessage(SQLState.SET_STREAM_INEXACT_LENGTH_DATA));
}
// can put the correct length into the stream.
Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/loc/messages_en.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/engine/org/apache/derby/loc/messages_en.properties?rev=306965&r1=306964&r2=306965&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/engine/org/apache/derby/loc/messages_en.properties (original)
+++ db/derby/code/branches/10.1/java/engine/org/apache/derby/loc/messages_en.properties Thu Oct 6 17:07:49 2005
@@ -1063,7 +1063,7 @@
XJ018.S=Column name cannot be null.
XJ020.S=Object type not convertible to TYPE ''{0}'', invalid java.sql.Types value, or object was null.
XJ022.S=Unable to set stream: ''{0}''.
-XJ023.S=Input stream held less data than requested length.
+XJ023.S=Input stream did not have exact amount of data as the requested length.
XJ025.S=Input stream cannot have negative length.
XJ030.S=Cannot set AUTOCOMMIT ON when in a nested connection.
XJ042.S=''{0}'' is not a valid value for property ''{1}''.
Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/characterStreams.out
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/characterStreams.out?rev=306965&r1=306964&r2=306965&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/characterStreams.out (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/characterStreams.out Thu Oct 6 17:07:49 2005
@@ -2,9 +2,13 @@
Test setAsciiStream into CHAR
CORRECT NUMBER OF BYTES IN STREAM
MORE BYTES IN STREAM THAN PASSED IN VALUE
-MORE BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+MORE BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of data as the requested length.: java.io.IOException'.
LESS BYTES IN STREAM THAN PASSED IN VALUE
-LESS BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+LESS BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of data as the requested length.: java.io.IOException'.
NULL ASCII STREAM
ID |C |CLEN |VC |VCLEN |LVC |LVCLEN
-----------------------------------------------------------------------------------------------------------------------------
@@ -22,9 +26,13 @@
Test setAsciiStream into VARCHAR
CORRECT NUMBER OF BYTES IN STREAM
MORE BYTES IN STREAM THAN PASSED IN VALUE
-MORE BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+MORE BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of data as the requested length.: java.io.IOException'.
LESS BYTES IN STREAM THAN PASSED IN VALUE
-LESS BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+LESS BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of data as the requested length.: java.io.IOException'.
NULL ASCII STREAM
ID |C |CLEN |VC |VCLEN |LVC |LVCLEN
-----------------------------------------------------------------------------------------------------------------------------
@@ -42,9 +50,13 @@
Test setAsciiStream into LONG VARCHAR
CORRECT NUMBER OF BYTES IN STREAM
MORE BYTES IN STREAM THAN PASSED IN VALUE
-MORE BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+MORE BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of data as the requested length.: java.io.IOException'.
LESS BYTES IN STREAM THAN PASSED IN VALUE
-LESS BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+LESS BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of data as the requested length.: java.io.IOException'.
NULL ASCII STREAM
ID |C |CLEN |VC |VCLEN |LVC |LVCLEN
-----------------------------------------------------------------------------------------------------------------------------
@@ -60,24 +72,36 @@
9,<NULL>,<NULL>,Lieberman ran with Gore
12,<NULL>,<NULL>,<NULL>
Test setCharacterStream into CHAR
-MORE CHARACTERS IN READER THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException was thrown when reading a 'java.sql.String' from an InputStream.
-LESS CHARACTERS IN READER STREAM THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+MORE CHARACTERS IN READER THAN SPECIFIED LENGTH - REJECTED
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of data as the requested length.: java.io.IOException'.
+LESS CHARACTERS IN READER STREAM THAN SPECIFIED LENGTH - REJECTED
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of data as the requested length.: java.io.IOException'.
ID |C |CLEN |VC |VCLEN |LVC |LVCLEN
-----------------------------------------------------------------------------------------------------------------------------
13 |A Mississippi Republican |24 |NULL |NULL |NULL |NULL
14 |Lott has apologized |19 |NULL |NULL |NULL |NULL
17 |NULL |NULL |NULL |NULL |NULL |NULL
Test setCharacterStream into VARCHAR
-MORE CHARACTERS IN READER THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException was thrown when reading a 'java.sql.String' from an InputStream.
-LESS CHARACTERS IN READER STREAM THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+MORE CHARACTERS IN READER THAN SPECIFIED LENGTH - REJECTED
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of data as the requested length.: java.io.IOException'.
+LESS CHARACTERS IN READER STREAM THAN SPECIFIED LENGTH - REJECTED
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of data as the requested length.: java.io.IOException'.
ID |C |CLEN |VC |VCLEN |LVC |LVCLEN
-----------------------------------------------------------------------------------------------------------------------------
18 |NULL |NULL |A Mississippi Republican |24 |NULL |NULL
19 |NULL |NULL |Lott has apologized |19 |NULL |NULL
22 |NULL |NULL |NULL |NULL |NULL |NULL
Test setCharacterStream into LONG VARCHAR
-MORE CHARACTERS IN READER THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException was thrown when reading a 'java.sql.String' from an InputStream.
-LESS CHARACTERS IN READER STREAM THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+MORE CHARACTERS IN READER THAN SPECIFIED LENGTH - REJECTED
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of data as the requested length.: java.io.IOException'.
+LESS CHARACTERS IN READER STREAM THAN SPECIFIED LENGTH - REJECTED
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String' from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of data as the requested length.: java.io.IOException'.
ID |C |CLEN |VC |VCLEN |LVC |LVCLEN
-----------------------------------------------------------------------------------------------------------------------------
23 |NULL |NULL |NULL |NULL |A Mississippi Republican |24
Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/resultsetStream.out
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/resultsetStream.out?rev=306965&r1=306964&r2=306965&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/resultsetStream.out (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/resultsetStream.out Thu Oct 6 17:07:49 2005
@@ -10,7 +10,7 @@
len=56
number of reads=56
EXPECTED SQLSTATE(XSDA4): An unexpected exception was thrown
-EXPECTED SQLSTATE(XJ001): Java exception: 'Input stream held less data than requested length.: java.io.IOException'.
+EXPECTED SQLSTATE(XJ001): Java exception: 'Input stream did not have exact amount of data as the requested length.: java.io.IOException'.
EXPECTED SQLSTATE(XSDA4): An unexpected exception was thrown
-EXPECTED SQLSTATE(XJ001): Java exception: 'Input stream held less data than requested length.: java.io.IOException'.
+EXPECTED SQLSTATE(XJ001): Java exception: 'Input stream did not have exact amount of data as the requested length.: java.io.IOException'.
Test resultsetStream finished
Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/characterStreams.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/characterStreams.java?rev=306965&r1=306964&r2=306965&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/characterStreams.java (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/characterStreams.java Thu Oct 6 17:07:49 2005
@@ -83,6 +83,21 @@
System.out.println("Test characterStreams finished");
}
+
+
+ private static void expectedException(SQLException sqle) {
+
+ while (sqle != null) {
+ String sqlState = sqle.getSQLState();
+ if (sqlState == null) {
+ sqlState = "<NULL>";
+ }
+ System.out.println("EXPECTED SQL Exception: (" + sqlState + ") "
+ + sqle.getMessage());
+
+ sqle = sqle.getNextException();
+ }
+ }
static void setStreams(Connection conn) throws Exception {
ResultSet rs;
@@ -227,7 +242,8 @@
ps.executeUpdate();
System.out.println("FAIL - MORE BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - ACCEPTED");
} catch (SQLException sqle) {
- System.out.println("MORE BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED " + sqle.toString());
+ System.out.println("MORE BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED ");
+ expectedException(sqle);
}
// more bytes than the stream contains
@@ -238,7 +254,8 @@
ps.executeUpdate();
System.out.println("FAIL - LESS BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - ACCEPTED");
} catch (SQLException sqle) {
- System.out.println("LESS BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED " + sqle.toString());
+ System.out.println("LESS BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED ");
+ expectedException(sqle);
}
// null
@@ -263,7 +280,8 @@
ps.executeUpdate();
System.out.println("FAIL - MORE CHARACTERS IN READER THAN SPECIFIED LENGTH - ACCEPTED");
} catch (SQLException sqle) {
- System.out.println("MORE CHARACTERS IN READER THAN SPECIFIED LENGTH - REJECTED " + sqle.toString());
+ System.out.println("MORE CHARACTERS IN READER THAN SPECIFIED LENGTH - REJECTED ");
+ expectedException(sqle);
}
// more bytes than the stream contains,
@@ -273,7 +291,8 @@
ps.executeUpdate();
System.out.println("FAIL - LESS CHARACTERS IN READER THAN SPECIFIED LENGTH - ACCEPTED");
} catch (SQLException sqle) {
- System.out.println("LESS CHARACTERS IN READER STREAM THAN SPECIFIED LENGTH - REJECTED " + sqle.toString());
+ System.out.println("LESS CHARACTERS IN READER STREAM THAN SPECIFIED LENGTH - REJECTED ");
+ expectedException(sqle);
}
// null