Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 62861 invoked from network); 16 Jul 2008 14:01:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Jul 2008 14:01:54 -0000 Received: (qmail 66239 invoked by uid 500); 16 Jul 2008 14:01:53 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 66212 invoked by uid 500); 16 Jul 2008 14:01:53 -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 65967 invoked by uid 99); 16 Jul 2008 14:01:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Jul 2008 07:01:52 -0700 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; Wed, 16 Jul 2008 14:01:07 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id E510D234C177 for ; Wed, 16 Jul 2008 07:01:31 -0700 (PDT) Message-ID: <1436065728.1216216891937.JavaMail.jira@brutus> Date: Wed, 16 Jul 2008 07:01:31 -0700 (PDT) From: "Bryan Pendleton (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3 In-Reply-To: <627837861.1215445531740.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-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12613960#action_12613960 ] Bryan Pendleton commented on DERBY-3764: ---------------------------------------- A "generated grouping column" is precisely the column "X" in your select sum(x) from t group by x; That is, it is a column which is used in a GROUP BY expression but which is NOT an explicit result of the query, so it must be invisibly included in the intermediate results in order to support sorting and grouping, but it not supposed to be included in the final results. removeGeneratedGroupingColumns sounds like exactly the right thing to do, and calling it in the Set node sounds correct because of this reasoning: - the grouping is performed in the set's child nodes - once the generated child nodes have been constructed, the grouping columns are no longer needed - the generated child nodes should not appear in the set's result I think that the already-committed partial fix may have perhaps been useful for queries such as: select sum(x) from t group by x union select sum(x), x from t group by x because if we used RCL.size() rather than RCL.visibleSize() to compare the two child nodes, wouldn't we think this query valid, when in fact it should complain that the two result sets do not have the same "shape"? > Union Query fail on Derby 10.4.1.3 > ---------------------------------- > > Key: DERBY-3764 > URL: https://issues.apache.org/jira/browse/DERBY-3764 > Project: Derby > Issue Type: Bug > Affects Versions: 10.3.1.4, 10.4.1.3 > Environment: Windows XP SP2, NetBeans 6.1 (IDE), Pentium 2 Core 512 Ram, Java 1.6.0_05 > Reporter: Heleno da Silva Alves > Assignee: Knut Anders Hatlen > Attachments: CONSTAS_REMESSA.sql, d3764-1a.diff, database_test.10.0.zip, database_test.10.3.zip, database_test.10.4.zip, export_contas_remessas.exp > > > Running a Query on Derby 10.4.1.3 and 10.3.1.4 I got this error message: Error code 0, SQL state XJ001: Java Exception: '4 >= 4: java.lang.ArrayIndexOutOfBoundsException'. > After throw this exception the database shutdown and lost the connection. > I'm updating an application from a previous version of Derby (Bundle-Version: 10.0.2000001 From derby.jar Manifest) so this query works fine in version 10.0. > The Query: > select 0 vlr_proc_anterior > , 0 vlr_proc_atual > , sum(vlr_contabil + vlr_ajuste) disp_financeira > from contas_remessa rec > where cd_tipo = 1105 and cd_conta = 4 > group by rec.cd_conta, rec.ds_conta > union > select case when cd_tipo = 170 then sum(vlr_contabil) + sum(vlr_ajuste) else 0 end vlr_proc_anterior > , case when cd_tipo = 175 then sum(vlr_contabil) + sum(vlr_ajuste) else 0 end vlr_proc_atual > , 0 disp_financeira > from contas_remessa where cd_tipo in (170, 175) and status = 'S' > group by cd_tipo > The deby log entry: > ---------------------------------------------------------------- > 2008-07-07 14:44:51.282 GMT: > Booting Derby version The Apache Software Foundation - Apache Derby - 10.3.1.4 - (561794): instance c013800d-011a-fdfb-6fa4-00003451d386 > on database directory C:\PAD\database > Database Class Loader started - derby.database.classpath='' > 2008-07-07 14:46:40.506 GMT Thread[SQLExecution,1,system] (XID = 3441038), (SESSIONID = 0), (DATABASE = C:\PAD\database), (DRDAID = null), Cleanup action starting > 2008-07-07 14:46:40.506 GMT Thread[SQLExecution,1,system] (XID = 3441038), (SESSIONID = 0), (DATABASE = C:\PAD\database), (DRDAID = null), Failed Statement is: select 0 vlr_proc_anterior > , 0 vlr_proc_atual > , sum(vlr_contabil + vlr_ajuste) disp_financeira > from contas_remessa rec > where cd_tipo = 1105 and cd_conta = 4 > group by rec.cd_conta, rec.ds_conta > union > select case when cd_tipo = 170 then sum(vlr_contabil) + sum(vlr_ajuste) else 0 end vlr_proc_anterior > , case when cd_tipo = 175 then sum(vlr_contabil) + sum(vlr_ajuste) else 0 end vlr_proc_atual > , 0 disp_financeira > from contas_remessa where cd_tipo in (170, 175) and status = 'S' > group by cd_tipo > java.lang.ArrayIndexOutOfBoundsException: 4 >= 4 > at java.util.Vector.elementAt(Vector.java:427) > at org.apache.derby.impl.sql.compile.QueryTreeNodeVector.elementAt(Unknown Source) > at org.apache.derby.impl.sql.compile.ResultColumnList.setUnionResultExpression(Unknown Source) > at org.apache.derby.impl.sql.compile.SetOperatorNode.buildRCL(Unknown Source) > at org.apache.derby.impl.sql.compile.SetOperatorNode.bindResultColumns(Unknown Source) > at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(Unknown Source) > at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source) > at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source) > at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source) > at org.netbeans.modules.db.sql.execute.SQLExecuteHelper.execute(SQLExecuteHelper.java:114) > at org.netbeans.modules.db.sql.loader.SQLEditorSupport$SQLExecutor.run(SQLEditorSupport.java:479) > at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:561) > at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:986) > Cleanup action completed -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.