Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 66786 invoked from network); 31 Mar 2009 15:21:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 31 Mar 2009 15:21:13 -0000 Received: (qmail 24919 invoked by uid 500); 31 Mar 2009 15:21:11 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 24873 invoked by uid 500); 31 Mar 2009 15:21:11 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 24865 invoked by uid 99); 31 Mar 2009 15:21:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 31 Mar 2009 15:21:11 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 31 Mar 2009 15:21:10 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id A57F7234C004 for ; Tue, 31 Mar 2009 08:20:50 -0700 (PDT) Message-ID: <1352988425.1238512850676.JavaMail.jira@brutus> Date: Tue, 31 Mar 2009 08:20:50 -0700 (PDT) From: "Kristian Waagan (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-4122) ClassCastException in SQLClob when running in soft upgrade mode (10.4.2.0 -> 10.5.1.0) In-Reply-To: <1616531082.1238095851764.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DERBY-4122?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12694146#action_12694146 ] Kristian Waagan commented on DERBY-4122: ---------------------------------------- In patch 3b, there are some issues that need to be resolved: 1) How to best determine if a stream is resetable or not. 2) Is it okay to materialize small Clobs in SQLClob.setObject? And what should the threshold for a small Clob be? The problem in 1 is that no matter if the source stream is resetable or not, we wrap it in a FormatIdInputStream. This class implements the Resetable interface, and a test for instanceof Resetable will fail with the reported ClassCastException. Some options from the top of my head (I'll spend more time investigating, but would appreciate comments); a) Introduce yet another class (a "non-resetable-FormatIdInputStream") b) Add the method isResetable to the Resetable interface (kind of contradicting...) c) Try to reset / rewind, catch ClassCastException and fallback to passing along the "bytes peeked at". d) Add instance variable in SQLChar, which allows us to do the instanceof check before we wrap the stream in a FormatIdInputStream. e) Your suggestion? Note that I haven't had time to throughly investigate this yet, so I may have missed something that's simpler and easier to implement. A few comments on some of the options I mentioned so far: a) This adds to the overhead, but the fact that this problem arises suggests there is a design problem in the current implementation. It is not clear to me what kind of changes this approach requires. c) Probably doable, but this makes exception catching part of the "flow control" for Clobs written with the old header format. d) Adds more state to a central data type, which has to be maintained. I think the maintenance costs should be modest, but I haven't investigated that. It may be possible to add this information to the CharacterStreamDescriptor-object, but again I don't know how this will play out. That said, the current patch already works... Feedback appreciated! > ClassCastException in SQLClob when running in soft upgrade mode (10.4.2.0 -> 10.5.1.0) > -------------------------------------------------------------------------------------- > > Key: DERBY-4122 > URL: https://issues.apache.org/jira/browse/DERBY-4122 > Project: Derby > Issue Type: Bug > Components: Regression Test Failure > Affects Versions: 10.5.1.0 > Environment: Windows Vista 64, Sun JDK 1.6.0_10, Junit 3.8.2 > Reporter: Suran Jayathilaka > Assignee: Kristian Waagan > Priority: Blocker > Attachments: derby-4122-1a-incorrect_stream_positioning.diff, derby-4122-2a-bc4btest.diff, derby-4122-3a-classcast_fix.diff, derby-4122-3b-classcast_fix.diff > > > This bug was found when doing soft upgrade testing from Derby version 10.4.2.0 to 10.5.1.0 (RC1) > Steps followed are as follows. > 1. Run setEmbeddedCP.bat from version 10.4.2.0's bin folder > 2. In a test folder run ij > 3. create system/wombat database. > ij> connect 'jdbc:derby:system/wombat;create=true'; > 4. exit ij > 5. Copy the 10.5.1.0 derby jars (from lib folder) and the derbyTesting.jar from 10.4.2.0 to the test folder and set classpath with them (including junit and ORO) > 6. Run suites.All > java -Xmx512M -Xms512M -Dderby.tests.trace=true junit.textui.TestRunner org.apache.derbyTesting.functionTests.suites.All > Result: > Tests run: 10479, Failures: 56, Errors: 34 > The exception stack trace from a failed test follows. > ------------------------------------------------------------------------------------------------------------- > 3) testClobInTriggerTable(org.apache.derbyTesting.functionTests.tests.lang.TriggerTest)java.sql.SQLException: Java exception: 'org.apache.derby.iapi.types.ReaderToUTF8Stream cannot be cast to org.apache.derby.iapi.types.Resetable: java.lang.ClassCastException'. > at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source) > at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement.execute(Unknown Source) > at org.apache.derbyTesting.functionTests.tests.lang.TriggerTest.testClobInTriggerTable(TriggerTest.java:529) > at org.apache.derbyTesting.functionTests.tests.lang.TriggerTest.testClobInTriggerTable(TriggerTest.java:451) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:102) > 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) > Caused by: java.sql.SQLException: Java exception: 'org.apache.derby.iapi.types.ReaderToUTF8Stream cannot be cast to org.apache.derby.iapi.types.Resetable: java.lang.ClassCastException'. > at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source) > ... 39 more > Caused by: java.lang.ClassCastException: org.apache.derby.iapi.types.ReaderToUTF8Stream cannot be cast to org.apache.derby.iapi.types.Resetable > at org.apache.derby.iapi.types.SQLClob.rewindStream(Unknown Source) > at org.apache.derby.iapi.types.SQLClob.readExternal(Unknown Source) > at org.apache.derby.iapi.types.SQLChar.getString(Unknown Source) > at org.apache.derby.iapi.types.SQLChar.loadStream(Unknown Source) > at org.apache.derby.impl.sql.execute.UpdateResultSet.objectifyStream(Unknown Source) > at org.apache.derby.impl.sql.execute.UpdateResultSet.collectAffectedRows(Unknown Source) > at org.apache.derby.impl.sql.execute.UpdateResultSet.open(Unknown Source) > at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(Unknown Source) > at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source) > ... 32 more > ------------------------------------------------------------------------------------------------------------------ > When looking at the SVN revisions for SQLClob with Kathey Marsden, we found the following statement in revision # 738408, related to DERBY-3907, which might be related to this issue. > "NOTE: Databases created with this revision (or later) containing Clobs, cannot be accessed by earlier trunk revisions." > Patch file: derby-3907-7a3-use_new_header_format.diff > -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.