Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 74487 invoked from network); 24 Jul 2006 05:58:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 Jul 2006 05:58:34 -0000 Received: (qmail 42964 invoked by uid 500); 24 Jul 2006 05:58:33 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 42935 invoked by uid 500); 24 Jul 2006 05:58:33 -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 42922 invoked by uid 99); 24 Jul 2006 05:58:33 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 23 Jul 2006 22:58:33 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [209.237.227.198] (HELO brutus.apache.org) (209.237.227.198) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 23 Jul 2006 22:58:32 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id C476A41000E for ; Mon, 24 Jul 2006 05:56:14 +0000 (GMT) Message-ID: <28496522.1153720574802.JavaMail.jira@brutus> Date: Sun, 23 Jul 2006 22:56:14 -0700 (PDT) From: "Yip Ng (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Updated: (DERBY-939) NullPointerException at ResultSet.close() time for simple query using UNION and INTERSECT In-Reply-To: <724490560.1139591397506.JavaMail.jira@ajax.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/DERBY-939?page=all ] Yip Ng updated DERBY-939: ------------------------- Attachment: derby939trunkdiffpatch1.txt derby939trunkstatpatch1.txt Here is the patch for DERBY-939. The attached file derby939trunkdiffpatch1.txt contains the fix for this issue + testcases and is diffed against the trunk codeline and derby939trunkstatpatch1.txt contains the list of file changes. I have ran derbyall suite and no new regression is introduced by this patch. As noted from my previous comment, the NPE is caused by a missing implementation of the runtime statistics for SetOpResultSet; thus, I implemented a class called RealSetOpResultSetStatistics under org.apache.derby.impl.sql.execute.rts package where all the runtime statistics classes reside and modified SetOpResultSet to process the runtime statistics attributes that RealSetOpResultSetStatistics need to address this issue. I verified the output of the testcases plan and they do not output null string or throw NPE anymore. i.e.: SELECT i FROM t1 UNION SELECT j FROM t2 INTERSECT SELECT k FROM t3; would have the following plan structure according to the plan output. (See setOpPlan.sql for more details). SORT ( no dups ) | UNION / \ / \ TSCAN INTERSECT | / \ t1 / \ SORT SORT | | TSCAN TSCAN | | t2 t3 Here is the release note if it makes it in 10.2: ========================================================== Release Note for DERBY-939 ---------------------------------------- PROBLEM Unable to produce query plan or runtime statistics for INTERSECT or EXCEPT operation when runtime statistics is enabled or when the property derby.language.logQueryPlan is set to true. SYMPTOMS (1) A NUllPointerException(NPE) occurs when a SQL query is executed that involves a UNION and INTERSECT/EXCEPT operation in: a) when the property derby.language.logQueryPlan=true OR b) runtime statistics mode via a CALL SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(1) i.e.: Case a: java -Dderby.language.logQueryPlan=true org.apache.derby.tools.ij ij> connect 'jdbc:derby:db1;create=true'; create table t1 (i int); create table t2 (j int); create table t3 (a int); ij> select i from t1 union (select j from t2 intersect select a from t3); 1 ----------- 0 rows selected ERROR XJ001: Java exception: ': java.lang.NullPointerException'. Case b: CALL SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(1); SELECT i FROM t1 UNION SELECT j FROM t2 INTERSECT SELECT a FROM t3; 1 ----------- 0 rows selected ij> VALUES SYSCS_UTIL.SYSCS_GET_RUNTIMESTATISTIC(); 1 -------------------------------------------------------------------------------- ------------------------------------------------ ERROR 38000: The exception 'java.lang.NullPointerException' was thrown while evaluating an expression. ERROR XJ001: Java exception: ': java.lang.NullPointerException'. (2) When a query only contains a simple INTERSECT or EXCEPT operation and the property derby.language.logQueryPlan=true., Derby outputs a null string in derby.log instead of the actual execution plan in textual representation. i.e.: java -Dderby.language.logQueryPlan=true org.apache.derby.tools.ij ij> connect 'jdbc:derby:db1'; ij> SELECT i FROM t1 INTERSECT SELECT j FROM t2; ij> quit; In derby.log: 2006-07-24 05:12:57.578 GMT Thread[main,5,main] (XID =186), (SESSIONID = 0), select i from t1 intersect select j from t2 ******* null CAUSE Derby's INTERCEPT and EXCEPT runtime statistics are not implemented; therefore, resulting in the stated problem above.The affected version is Derby 10.1. SOLUTION A fix to resolve the Derby symptom is available in 10.2? builds. WORKAROUND None. ========================================================== I would appreciate it if someone can review this patch. Thanks! > NullPointerException at ResultSet.close() time for simple query using UNION and INTERSECT > ----------------------------------------------------------------------------------------- > > Key: DERBY-939 > URL: http://issues.apache.org/jira/browse/DERBY-939 > Project: Derby > Issue Type: Bug > Components: SQL > Affects Versions: 10.2.0.0, 10.1.3.0 > Environment: Embedded and server modes, with derby.language.logQueryPlan=true > Reporter: A B > Assigned To: Yip Ng > Priority: Minor > Attachments: derby939trunkdiffpatch1.txt, derby939trunkstatpatch1.txt > > > If I set "derby.language.logQueryPlan" to true and then attempt to execute the following simple query using UNION and INTERSECT, Derby will return the correct results and then, _after_ returning the results, will throw a NullPointerException. This error also occurs for 10.1. > To reproduce: > > java -Dderby.language.logQueryPlan=true org.apache.derby.tools.ij > and then do: > create table t1 (i int); > create table t2 (j int); > create table t3 (a int); > ij> select i from t1 union (select j from t2 intersect select a from t3); > 1 > ----------- > 0 rows selected > ERROR XJ001: Java exception: ': java.lang.NullPointerException'. > If I add data, the query will return the correct results, but then throw the NPE. > insert into t1 values 1, 2, 3, 4, 5; > insert into t2 values 2, 4, 6, 8, 10; > insert into t3 values 2, 3, 4; > ij> select i from t1 union (select j from t2 intersect select a from t3); > 1 > ----------- > 1 > 2 > 3 > 4 > 5 > 5 rows selected > ERROR XJ001: Java exception: ': java.lang.NullPointerException'. > The embedded and client stack traces are shown below. Both suggest that the problem occurs during the close of the result set. > -- Embedded -- > java.lang.NullPointerException > at org.apache.derby.impl.sql.execute.rts.RealUnionResultSetStatistics.getStatementExecutionPlanText(RealUnionResultSetStatistics.java:107) > at org.apache.derby.impl.sql.execute.rts.RealSortStatistics.getStatementExecutionPlanText(RealSortStatistics.java:124) > at org.apache.derby.impl.sql.execute.rts.RunTimeStatisticsImpl.getStatementExecutionPlanText(RunTimeStatisticsImpl.java:293) > at org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.finishAndRTS(BasicNoPutResultSetImpl.java:633) > at org.apache.derby.impl.sql.execute.SortResultSet.finish(SortResultSet.java:479) > at org.apache.derby.impl.jdbc.EmbedResultSet.close(EmbedResultSet.java:533) > at org.apache.derby.tools.JDBCDisplayUtil.indent_DisplayResults(JDBCDisplayUtil.java:272) > at org.apache.derby.tools.JDBCDisplayUtil.DisplayResults(JDBCDisplayUtil.java:260) > at org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:381) > at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:434) > at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:310) > at org.apache.derby.impl.tools.ij.Main.go(Main.java:203) > at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:169) > at org.apache.derby.impl.tools.ij.Main14.main(Main14.java:55) > at org.apache.derby.tools.ij.main(ij.java:60) > -- Client -- > ERROR (no SQLState): actual code point, 4692 does not match expected code point, 9224 > java.sql.SQLException: actual code point, 4692 does not match expected code point, 9224 > at org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:280) > at org.apache.derby.client.am.ResultSet.close(ResultSet.java:412) > at org.apache.derby.tools.JDBCDisplayUtil.indent_DisplayResults(JDBCDisplayUtil.java:272) > at org.apache.derby.tools.JDBCDisplayUtil.DisplayResults(JDBCDisplayUtil.java:260) > at org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:381) > at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:434) > at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:310) > at org.apache.derby.impl.tools.ij.Main.go(Main.java:203) > at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:169) > at org.apache.derby.impl.tools.ij.Main14.main(Main14.java:55) > at org.apache.derby.tools.ij.main(ij.java:60) > Caused by: org.apache.derby.client.am.DisconnectException: actual code point, 4692 does not match ex > pected code point, 9224 > at org.apache.derby.client.net.Reply.zThrowSyntaxError(Reply.java:1157) > at org.apache.derby.client.net.Reply.parseLengthAndMatchCodePoint(Reply.java:1057) > at org.apache.derby.client.net.NetConnectionReply.parseSQLCARD(NetConnectionReply.java:2519) > at org.apache.derby.client.net.NetConnectionReply.parseRDBCMMreply(NetConnectionReply.java:2 > 00) > at org.apache.derby.client.net.NetConnectionReply.readLocalCommit(NetConnectionReply.java:13 > 3) > at org.apache.derby.client.net.ConnectionReply.readLocalCommit(ConnectionReply.java:42) > at org.apache.derby.client.net.NetConnection.readLocalCommit_(NetConnection.java:1347) > at org.apache.derby.client.am.Connection.readCommit(Connection.java:624) > at org.apache.derby.client.am.Connection.readAutoCommit(Connection.java:614) > at org.apache.derby.client.am.ResultSet.readAutoCommitIfNotAutoCommitted(ResultSet.java:509) > at org.apache.derby.client.am.ResultSet.readCloseAndAutoCommit(ResultSet.java:474) > at org.apache.derby.client.am.ResultSet.flowCloseAndAutoCommitIfNotAutoCommitted(ResultSet.j > ava:455) > at org.apache.derby.client.am.ResultSet.closeX(ResultSet.java:425) > at org.apache.derby.client.am.ResultSet.close(ResultSet.java:407) > ERROR XJ001: DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ001, SQLERRMC: java.lang.NullPointerException > [XX] XJ001.U > java.sql.SQLException: DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ001, SQLERRMC: java.lang.NullPointerException[XX]XJ001.U > at org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:280) > at org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:295) > at org.apache.derby.client.am.ResultSet.close(ResultSet.java:412) > at org.apache.derby.tools.JDBCDisplayUtil.indent_DisplayResults(JDBCDisplayUtil.java:272) > at org.apache.derby.tools.JDBCDisplayUtil.DisplayResults(JDBCDisplayUtil.java:260) > at org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:381) > at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:434) > at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:310) > at org.apache.derby.impl.tools.ij.Main.go(Main.java:203) > at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:169) > at org.apache.derby.impl.tools.ij.Main14.main(Main14.java:55) > at org.apache.derby.tools.ij.main(ij.java:60) -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira