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 2006/01/16 20:19:41 UTC
svn commit: r369549 - in /db/derby/code/trunk/java:
drda/org/apache/derby/impl/drda/
testing/org/apache/derbyTesting/functionTests/master/
testing/org/apache/derbyTesting/functionTests/master/DerbyNet/jdk15/
testing/org/apache/derbyTesting/functionTest...
Author: kmarsden
Date: Mon Jan 16 11:19:26 2006
New Revision: 369549
URL: http://svn.apache.org/viewcvs?rev=369549&view=rev
Log:
DERBY-170 Inserting large string value into non-existent table causes communication link failure over Network Server.
Attached is a proposed patch for DERBY-170, which teaches the skipDSS method how to handle segmented DDM objects. changes.html attached to DERBY-170 provides a bit of background and discussion for the reviewer. I have successfully run derbyall with this patch. The patch includes a new test, and new master output files.
Contributed by Bran Pendleton
Modified:
db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMReader.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/jdk15/prepStmt.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk15/prepStmt.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/prepStmt.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/prepStmt.java
Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMReader.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMReader.java?rev=369549&r1=369548&r2=369549&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMReader.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMReader.java Mon Jan 16 11:19:26 2006
@@ -1372,6 +1372,11 @@
*/
protected void skipDss() throws DRDAProtocolException
{
+ while (dssIsContinued)
+ {
+ skipBytes((int)dssLength);
+ readDSSContinuationHeader();
+ }
skipBytes((int)dssLength);
topDdmCollectionStack = EMPTY_STACK;
ddmScalarLen = 0;
@@ -1482,6 +1487,7 @@
private void ensureBLayerDataInBuffer (int desiredDataSize, boolean adjustLen)
throws DRDAProtocolException
{
+ ensureALayerDataInBuffer (desiredDataSize);
if (dssIsContinued)
{
if (desiredDataSize > dssLength)
@@ -1491,10 +1497,6 @@
compressBLayerData (continueDssHeaderCount);
}
}
- else
- {
- ensureALayerDataInBuffer (desiredDataSize);
- }
if (adjustLen)
adjustLengths(desiredDataSize);
}
@@ -1734,8 +1736,11 @@
"fill",
5);
}
- count += actualBytesRead;
- totalBytesRead += actualBytesRead;
+ if (actualBytesRead != -1)
+ {
+ count += actualBytesRead;
+ totalBytesRead += actualBytesRead;
+ }
}
while ((totalBytesRead < minimumBytesNeeded) && (actualBytesRead != -1));
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/jdk15/prepStmt.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/jdk15/prepStmt.out?rev=369549&r1=369548&r2=369549&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/jdk15/prepStmt.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/jdk15/prepStmt.out Mon Jan 16 11:19:26 2006
@@ -76,4 +76,5 @@
Negative test setString with Invalid Timestamp:20
SQLState: 22007 message: The syntax of the string representation of a datetime value is incorrect.
Test jira614 completed successfully -- no Distributed Protocol Exception occurred
+Jira170: caught expected table not found
prepStmt Test Ends
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk15/prepStmt.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk15/prepStmt.out?rev=369549&r1=369548&r2=369549&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk15/prepStmt.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk15/prepStmt.out Mon Jan 16 11:19:26 2006
@@ -76,4 +76,5 @@
Negative test setString with Invalid Timestamp:20
SQLState: 22007 message: The syntax of the string representation of a datetime value is incorrect.
Test jira614 completed successfully -- no Distributed Protocol Exception occurred
+Jira170: caught expected table not found
prepStmt Test Ends
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/prepStmt.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/prepStmt.out?rev=369549&r1=369548&r2=369549&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/prepStmt.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/prepStmt.out Mon Jan 16 11:19:26 2006
@@ -76,4 +76,5 @@
Negative test setString with Invalid Timestamp:20
SQLState: 22007 message: The syntax of the string representation of a datetime value is incorrect.
Test jira614 completed successfully -- no Distributed Protocol Exception occurred
+Jira170: caught expected table not found
prepStmt Test Ends
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/prepStmt.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/prepStmt.java?rev=369549&r1=369548&r2=369549&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/prepStmt.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/prepStmt.java Mon Jan 16 11:19:26 2006
@@ -309,6 +309,7 @@
test5130(conn);
test5172(conn);
jira614Test(conn);
+ jira170Test(conn);
conn.close();
// refresh conn before cleaning up
conn = ij.startJBMS();
@@ -743,6 +744,48 @@
for (int i = 0; i < howMany; i++)
buf.append(c);
return buf.toString();
+ }
+ // Jira-170 has to do with how the server handles re-synchronization of
+ // the data stream when an enormous parameter value follows a failed
+ // prepare statement. Note that it is deliberate here that we are preparing
+ // a statement referring to a non-existing table.
+ private static void jira170Test(Connection conn)
+ throws Exception
+ {
+ Statement stmt = conn.createStatement();
+ PreparedStatement ps = null ;
+ try {
+ stmt.execute("drop table jira170");
+ } catch (Throwable t) { }
+ // Create a huge array of chars to be used as the input parameter
+ char []cData = new char[1000000];
+ for (int i = 0; i < cData.length; i++)
+ cData[i] = Character.forDigit(i%10, 10);
+ // The behavior of this test program depends on how the JDBC driver
+ // handles statement prepares. The DB2 Universal JDBC driver implements
+ // something called "deferred prepares" by default. This means that it
+ // doesn't do the prepare of the statement until the statement is
+ // actually executed. Other drivers, such as the standard Derby client
+ // driver, do the prepare at the time of the prepare. This means that,
+ // depending on which driver we're using and what the driver's
+ // configuration is, we'll get the "table not found" error either on
+ // the prepare or on the execute. It doesn't really matter for the
+ // purposes of the test, because the whole point is that we *dont*
+ // get a DRDA Protocol Exception, but rather a table-not-found
+ // exception.
+ try {
+ ps = conn.prepareStatement("insert into jira170 values (?)");
+ ps.setString(1, new String(cData));
+ ps.execute();
+ System.out.println("Test Jira170 failed: no exception when trying to execute a failed prepare with an enormous parameter");
+ }
+ catch (SQLException e)
+ {
+ if (e.getSQLState().equals("42X05"))
+ System.out.println("Jira170: caught expected table not found");
+ else
+ e.printStackTrace();
+ }
}
}