Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 54806 invoked from network); 19 Nov 2009 00:24:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 19 Nov 2009 00:24:04 -0000 Received: (qmail 11055 invoked by uid 500); 19 Nov 2009 00:24:04 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 10989 invoked by uid 500); 19 Nov 2009 00:24:03 -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 10973 invoked by uid 99); 19 Nov 2009 00:24:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Nov 2009 00:24:03 +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; Thu, 19 Nov 2009 00:24:00 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id C29E0234C4AC for ; Wed, 18 Nov 2009 16:23:39 -0800 (PST) Message-ID: <410271754.1258590219796.JavaMail.jira@brutus> Date: Thu, 19 Nov 2009 00:23:39 +0000 (UTC) From: "Bryan Pendleton (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-4450) GROUP BY in an IN-subquery inside HAVING clause whose select list is subset of group by columns, gives NPE In-Reply-To: <810559109.1258588539691.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-4450?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12779757#action_12779757 ] Bryan Pendleton commented on DERBY-4450: ---------------------------------------- > select sum(j) from t group by i having i in (select i from t group by i,j ); Is this legal? I thought that a HAVING clause could only mention items in the result column list. > GROUP BY in an IN-subquery inside HAVING clause whose select list is subset of group by columns, gives NPE > ---------------------------------------------------------------------------------------------------------- > > Key: DERBY-4450 > URL: https://issues.apache.org/jira/browse/DERBY-4450 > Project: Derby > Issue Type: Bug > Components: SQL > Reporter: Dag H. Wanvik > > Found this while working on DERBY-4397 for a similar case with ORDER BY inside an IN-subquery: > Repro: > create table t(i int not null, constraint c unique (i), j int, k int); > insert into t values (1,10,1),(2,40,1),(3,45,1),(4,46,1),(5,90,1); > select sum(j) from t group by i having i in (select i from t group by i,j ); > gives NPE: > ERROR XJ001: Java exception: ': java.lang.NullPointerException'. > java.sql.SQLException: Java exception: ': java.lang.NullPointerException'. > at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95) > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:87) > at org.apache.derby.impl.jdbc.Util.javaException(Util.java:244) > 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:2201) > at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81) > at org.apache.derby.impl.jdbc.EmbedResultSet.closeOnTransactionError(EmbedResultSet.java:4338) > at org.apache.derby.impl.jdbc.EmbedResultSet.movePosition(EmbedResultSet.java:467) > at org.apache.derby.impl.jdbc.EmbedResultSet.next(EmbedResultSet.java:371) > 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:448) > at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:522) > at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:363) > at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:261) > at org.apache.derby.impl.tools.ij.Main.go(Main.java:229) > at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:184) > at org.apache.derby.impl.tools.ij.Main.main(Main.java:75) > at org.apache.derby.tools.ij.main(ij.java:59) > Caused by: java.sql.SQLException: Java exception: ': java.lang.NullPointerException'. > at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45) > at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:119) > at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:70) > ... 22 more > Caused by: java.lang.NullPointerException > at org.apache.derby.impl.sql.execute.BaseActivation.getColumnFromRow(BaseActivation.java:1451) > at org.apache.derby.exe.acf81e0010x0125x09b5xf628x000003d4bf801.e5(Unknown Source) > at org.apache.derby.impl.services.reflect.DirectCall.invoke(ReflectGeneratedClass.java:149) > at org.apache.derby.impl.sql.execute.ProjectRestrictResultSet.getNextRowCore(ProjectRestrictResultSet.java:268) > at org.apache.derby.impl.sql.execute.AnyResultSet.getNextRowCore(AnyResultSet.java:171) > at org.apache.derby.exe.acf81e0010x0125x09b5xf628x000003d4bf801.g0(Unknown Source) > at org.apache.derby.exe.acf81e0010x0125x09b5xf628x000003d4bf801.e3(Unknown Source) > at org.apache.derby.impl.services.reflect.DirectCall.invoke(ReflectGeneratedClass.java:145) > at org.apache.derby.impl.sql.execute.ProjectRestrictResultSet.getNextRowCore(ProjectRestrictResultSet.java:268) > at org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.getNextRow(BasicNoPutResultSetImpl.java:471) > at org.apache.derby.impl.jdbc.EmbedResultSet.movePosition(EmbedResultSet.java:427) -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.