Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 5139 invoked from network); 4 Sep 2007 16:09:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Sep 2007 16:09:08 -0000 Received: (qmail 18874 invoked by uid 500); 4 Sep 2007 16:09:01 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 18844 invoked by uid 500); 4 Sep 2007 16:09:01 -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 18760 invoked by uid 99); 4 Sep 2007 16:09:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Sep 2007 09:09:01 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Sep 2007 16:09:05 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 2F8BE71420A for ; Tue, 4 Sep 2007 09:08:45 -0700 (PDT) Message-ID: <19360751.1188922125191.JavaMail.jira@brutus> Date: Tue, 4 Sep 2007 09:08:45 -0700 (PDT) From: "A B (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-3032) java.lang.ClassCastException returning null from a case statement in subquery In-Reply-To: <31409441.1188412110890.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DERBY-3032?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12524774 ] A B commented on DERBY-3032: ---------------------------- Thank you for the patch, Kathey. I verified that it solves the reported problem and does not affect the performance as seen in DERBY-2986. I also ran the new test case before and after applying the engine changes, and it behaved as expected (failed without the fix, passed with it). > I added comments to try to make it apparent that that is what is happenning, but wonder if > there is better way to reorganize this to make it clearer I think the comments help (thanks for adding them), but I also agree that some sort of code reorganization might be good here. The code as it is feels a tad awkward. Nonetheless, the patch as posted solves the problem so I'm +1 to commit. If anyone has the time to do some re-org as follow-up work, that'd be great--but I wouldn't let that block the current patch. Thank you again for picking this one up and resolving it so quickly. > java.lang.ClassCastException returning null from a case statement in subquery > ------------------------------------------------------------------------------ > > Key: DERBY-3032 > URL: https://issues.apache.org/jira/browse/DERBY-3032 > Project: Derby > Issue Type: Bug > Affects Versions: 10.3.1.5 > Reporter: Kathey Marsden > Assignee: Kathey Marsden > Attachments: derby-3032_diff.txt, derby-3032_stat.txt > > > The following query returning NULL date from a case statement in a subquery causees a ClassCastException in 10.3. > The query works fine in 10.2 > ij> create table t (d date, vc varchar(30)); > 0 rows inserted/updated/deleted > ij> insert into t values(CURRENT_DATE, 'hello'); > 1 row inserted/updated/deleted > ij> SELECT d from t where d = (SELECT CASE WHEN 1 = 1 THEN CURRENT_DATE ELSE NULL END from t); > D > ---------- > 2007-08-28 > 1 row selected > ij> SELECT d from t where d = (SELECT CASE WHEN 1 = 0 THEN CURRENT_DATE ELSE NULL END from t); > D > ---------- > ERROR 38000: The exception 'java.lang.ClassCastException: org.apache.derby.iapi.types.SQLChar incompatible with org.apac > he.derby.iapi.types.DateTimeDataValue' was thrown while evaluating an expression. > java.sql.SQLException: The exception 'java.lang.ClassCastException: org.apache.derby.iapi.types.SQLChar incompatible wit > h org.apache.derby.iapi.types.DateTimeDataValue' was thrown while evaluating an expression. > at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45) > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:88) > at org.apache.derby.impl.jdbc.Util.seeNextException(Util.java:224) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:398) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346) > at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:1572) > at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81) > at org.apache.derby.impl.jdbc.EmbedResultSet.closeOnTransactionError(EmbedResultSet.java:4323) > at org.apache.derby.impl.jdbc.EmbedResultSet.movePosition(EmbedResultSet.java:464) > at org.apache.derby.impl.jdbc.EmbedResultSet.next(EmbedResultSet.java:368) > at org.apache.derby.tools.JDBCDisplayUtil.indent_DisplayResults(JDBCDisplayUtil.java:382) > at org.apache.derby.tools.JDBCDisplayUtil.indent_DisplayResults(JDBCDisplayUtil.java:338) > at org.apache.derby.tools.JDBCDisplayUtil.indent_DisplayResults(JDBCDisplayUtil.java:241) > at org.apache.derby.tools.JDBCDisplayUtil.DisplayResults(JDBCDisplayUtil.java:229) > at org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:449) > at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:523) > at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:364) > at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:262) > at org.apache.derby.impl.tools.ij.Main.go(Main.java:215) > at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:181) > at org.apache.derby.impl.tools.ij.Main14.main(Main14.java:56) > at org.apache.derby.tools.ij.main(ij.java:71) > Caused by: java.sql.SQLException: Java exception: 'org.apache.derby.iapi.types.SQLChar incompatible with org.apache.derb > y.iapi.types.DateTimeDataValue: java.lang.ClassCastException'. > at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45) > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:88) > at org.apache.derby.impl.jdbc.Util.javaException(Util.java:245) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:403) > ... 19 more > Caused by: java.lang.ClassCastException: org.apache.derby.iapi.types.SQLChar incompatible with org.apache.derby.iapi.typ > es.DateTimeDataValue > at org.apache.derby.exe.ac12564092x0114xaec2x9627x0000002183d82.g0(Unknown Source) > at org.apache.derby.exe.ac12564092x0114xaec2x9627x0000002183d82.e1(Unknown Source) > at org.apache.derby.impl.services.reflect.DirectCall.invoke(ReflectGeneratedClass.java:141) > at org.apache.derby.impl.sql.execute.ProjectRestrictResultSet.getNextRowCore(ProjectRestrictResultSet.java:267) > at org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.getNextRow(BasicNoPutResultSetImpl.java:468) > at org.apache.derby.impl.jdbc.EmbedResultSet.movePosition(EmbedResultSet.java:424) > ... 13 more > ERROR XJ001: Java exception: 'org.apache.derby.iapi.types.SQLChar incompatible with org.apache.derby.iapi.types.DateTime > DataValue: java.lang.ClassCastException'. > java.sql.SQLException: Java exception: 'org.apache.derby.iapi.types.SQLChar incompatible with org.apache.derby.iapi.type > s.DateTimeDataValue: java.lang.ClassCastException'. > at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45) > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:88) > at org.apache.derby.impl.jdbc.Util.javaException(Util.java:245) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:403) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:398) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346) > at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:1572) > at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81) > at org.apache.derby.impl.jdbc.EmbedResultSet.closeOnTransactionError(EmbedResultSet.java:4323) > at org.apache.derby.impl.jdbc.EmbedResultSet.movePosition(EmbedResultSet.java:464) > at org.apache.derby.impl.jdbc.EmbedResultSet.next(EmbedResultSet.java:368) > at org.apache.derby.tools.JDBCDisplayUtil.indent_DisplayResults(JDBCDisplayUtil.java:382) > at org.apache.derby.tools.JDBCDisplayUtil.indent_DisplayResults(JDBCDisplayUtil.java:338) > at org.apache.derby.tools.JDBCDisplayUtil.indent_DisplayResults(JDBCDisplayUtil.java:241) > at org.apache.derby.tools.JDBCDisplayUtil.DisplayResults(JDBCDisplayUtil.java:229) > at org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:449) > at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:523) > at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:364) > at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:262) > at org.apache.derby.impl.tools.ij.Main.go(Main.java:215) > at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:181) > at org.apache.derby.impl.tools.ij.Main14.main(Main14.java:56) > at org.apache.derby.tools.ij.main(ij.java:71) > Caused by: java.lang.ClassCastException: org.apache.derby.iapi.types.SQLChar incompatible with org.apache.derby.iapi.typ > es.DateTimeDataValue > at org.apache.derby.exe.ac12564092x0114xaec2x9627x0000002183d82.g0(Unknown Source) > at org.apache.derby.exe.ac12564092x0114xaec2x9627x0000002183d82.e1(Unknown Source) > at org.apache.derby.impl.services.reflect.DirectCall.invoke(ReflectGeneratedClass.java:141) > at org.apache.derby.impl.sql.execute.ProjectRestrictResultSet.getNextRowCore(ProjectRestrictResultSet.java:267) > at org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.getNextRow(BasicNoPutResultSetImpl.java:468) > at org.apache.derby.impl.jdbc.EmbedResultSet.movePosition(EmbedResultSet.java:424) > ... 13 more -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.