Hi,
https://issues.apache.org/jira/browse/DERBY-3663
I am converting the store/streamingColumn test to a Junit testcase
named StreamingColumn. The initial submissions are attached to the
JIRA.
In the testStream10 test, I ran into a problem.
When inserting extin/derby.banner (length 414000) a truncation error
should be thrown, which would be asserted with "22001".
But only in network server mode, this assertion fails because the
exception code is XJ001.
The stack trace is
--------
1)
testStream10(org.apache.derbyTesting.functionTests.tests.store.StreamingColumnTest)junit.framework.ComparisonFailure:
Unexpected SQL state. expected:<[22]001> but was:<[XJ]001>
at
org.apache.derbyTesting.junit.BaseJDBCTestCase.assertSQLState(BaseJDBCTestCase.java:760)
at
org.apache.derbyTesting.junit.BaseJDBCTestCase.assertSQLState(BaseJDBCTestCase.java:795)
at
org.apache.derbyTesting.junit.BaseJDBCTestCase.assertSQLState(BaseJDBCTestCase.java:809)
at
org.apache.derbyTesting.functionTests.tests.store.StreamingColumnTest.testStream10(StreamingColumnTest.java:1125)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at
org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:103)
at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
at junit.extensions.TestSetup.run(TestSetup.java:25)
at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
at junit.extensions.TestSetup.run(TestSetup.java:25)
at
org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
at junit.extensions.TestSetup.run(TestSetup.java:25)
at
org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
at junit.extensions.TestSetup.run(TestSetup.java:25)
at
org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
at junit.extensions.TestSetup.run(TestSetup.java:25)
Caused by: java.sql.SQLException: Java exception: 'A truncation error
was encountered trying to shrink {0} '{1}' to length {2}.:
org.apache.derby.iapi.services.io.DerbyIOException'.
at
org.apache.derby.client.am.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:46)
at
org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:362)
at
org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:371)
at
org.apache.derby.client.am.PreparedStatement.executeUpdate(PreparedStatement.java:399)
at
org.apache.derbyTesting.functionTests.tests.store.StreamingColumnTest.testStream10(StreamingColumnTest.java:1117)
... 43 more
Caused by: org.apache.derby.client.am.SqlException: Java exception: 'A
truncation error was encountered trying to shrink {0} '{1}' to length
{2}.: org.apache.derby.iapi.services.io.DerbyIOException'.
at
org.apache.derby.client.am.Statement.completeExecute(Statement.java:1601)
at
org.apache.derby.client.net.NetStatementReply.parseEXCSQLSTTreply(NetStatementReply.java:322)
at
org.apache.derby.client.net.NetStatementReply.readExecute(NetStatementReply.java:71)
at
org.apache.derby.client.net.StatementReply.readExecute(StatementReply.java:55)
at
org.apache.derby.client.net.NetPreparedStatement.readExecute_(NetPreparedStatement.java:189)
at
org.apache.derby.client.am.PreparedStatement.readExecute(PreparedStatement.java:1799)
at
org.apache.derby.client.am.PreparedStatement.flowExecute(PreparedStatement.java:2096)
at
org.apache.derby.client.am.PreparedStatement.executeUpdateX(PreparedStatement.java:404)
at
org.apache.derby.client.am.PreparedStatement.executeUpdate(PreparedStatement.java:390)
... 44 more
-------------------------------------------
I've changed the code to check if the file being inserted is
derby.banner and if usingDerbyNetClient() to assert to "XJ001".
----------------------------------
try {// if trying to insert data > 32700, there will be an exception
ps.executeUpdate();
if (i == 2) {
fail("Length 414000 should have
thrown a truncation error!");
}
} catch (SQLException e) {
if (fileLength[i] >
DB2_LONGVARCHAR_MAXWIDTH) {
if (usingDerbyNetClient() && i
== 2) {
assertSQLState("XJ001",
e);
} else {
assertSQLState("22001",
e);
}
} else {
throw e;
}
} catch {...}
-------------------------------
Is this acceptable? Or could there be some other fault that is causing
the XJ001 to be thrown?
Thanks.
Suran