You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Heleno da Silva Alves (JIRA)" <ji...@apache.org> on 2008/07/07 17:45:31 UTC

[jira] Created: (DERBY-3764) Union Query fail on Derby 10.4.1.3

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.4.1.3, 10.3.1.4
         Environment: Windows XP SP2, NetBeans 6.1 (IDE), Pentium 2 Core 512 Ram, Java 1.6.0_05
            Reporter: Heleno da Silva Alves


    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.


[jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12613952#action_12613952 ] 

Knut Anders Hatlen commented on DERBY-3764:
-------------------------------------------

Not sure if it is the correct fix, but adding a call to resultColumns.removeGeneratedGroupingColumns() after cloning the result column list from the left result set in SetOperatorNode.buildRCL() seems to fix the problem. I think it makes sense to remove the non-visible columns from the cloned RCL at that point, since they are only meaningful for the left result set, not for the union result set. But I'm not sure exactly what's meant by a generated grouping column, so it's not quite clear to me if that's the correct method to call.

If it is the correct approach to trim away the non-visible columns from the clone at that point in the code, I think the already committed partial fix is unnecessary, but it shouldn't do any harm.

> 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.


[jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12611741#action_12611741 ] 

Knut Anders Hatlen commented on DERBY-3764:
-------------------------------------------

Here's a simpler way to reproduce the bug:

ij> create table t(x int);
0 rows inserted/updated/deleted
ij> select sum(x) from t group by x union select sum(x) from t group by x;
ERROR XJ001: Java exception: '1 >= 1: java.lang.ArrayIndexOutOfBoundsException'.

> 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
>         Attachments: CONSTAS_REMESSA.sql, 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.


[jira] Updated: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-3764:
--------------------------------------

    Attachment: d3764-1a.diff

The attached patch fixes setUnionResultExpression() and isExactTypeAndLengthMatch() and adds a test case to GroupByTest which fails with ArrayIndexOutOfBoundsException without the fixes and passes with them. All the regression tests ran cleanly with the patch.

> 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.


[jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612856#action_12612856 ] 

Knut Anders Hatlen commented on DERBY-3764:
-------------------------------------------

Other set operations than UNION have similar problems:

ij> create table t (x int);
0 rows inserted/updated/deleted
ij> select sum(x) from t group by x except values 1;
ERROR 42X77: Column position '2' is out of range for the query expression.
ij> select sum(x) from t group by x intersect values 1;
ERROR 42X77: Column position '2' is out of range for the query expression.

The above queries worked with Derby 10.2.2.0.

> 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.


[jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12611753#action_12611753 ] 

Knut Anders Hatlen commented on DERBY-3764:
-------------------------------------------

The simpler repro doesn't have the exact same stack trace as the reported error. The reported error happens during the bind phase, whereas the simpler repro fails during byte code generation. The simpler repro can also be made into failing during bind by rewriting it to:

ij> create table t(x int);
0 rows inserted/updated/deleted
ij> select sum(x) from t group by x union values 1;
ERROR XJ001: Java exception: '1 >= 1: java.lang.ArrayIndexOutOfBoundsException'.

> 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
>         Attachments: CONSTAS_REMESSA.sql, 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.


[jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612889#action_12612889 ] 

Bryan Pendleton commented on DERBY-3764:
----------------------------------------

Thanks for the patch; I agree that addressing these problems as
a first step is a good plan.

The patch looks quite reasonable to me. Here's a couple thoughts:

1) In your comment above you said that these changes resolved
the original form of the query, but not the alternate form. Yet in your
patch both forms of the query are compiled, but the execution is
commented out. With the patch, is it possible actually execute
the original form of the query? If so, it seems like the patch should do so.

2) As you note, there are some other variants that are worth testing,
such as different set operations, and perhaps cases where the two
children of the union do *not* have the same number of visible columns
or where the data types of the visible columns are not quite matching.
So if you get a chance to add more test cases, either now or later, that
would be great.


> 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.


[jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612897#action_12612897 ] 

Knut Anders Hatlen commented on DERBY-3764:
-------------------------------------------

I guess I didn't fully answer your first question. The two queries in the test both fail if they are executed. The statement that doesn't fail when it's executed, is the one that is mentioned in the description of the issue and that uses the attached scripts CONSTAS_REMESSA.sql and export_contas_remessas.exp.

> 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.


[jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12613981#action_12613981 ] 

Knut Anders Hatlen commented on DERBY-3764:
-------------------------------------------

Thanks Bryan, it sounds like this is the way to go, then.

The query you mentioned perhaps could be helped by the partial fix will probably be handled correctly without that fix as well, because of this code at the beginning of SetOperatorNode.buildRCL():

		/* Verify that both sides of the union have the same # of columns in their
		 * RCL.
		 */
		if (leftResultSet.getResultColumns().visibleSize() !=
			rightResultSet.getResultColumns().visibleSize())
		{
			throw StandardException.newException(SQLState.LANG_UNION_UNMATCHED_COLUMNS,
                                                 getOperatorName());
		}

I guess we could keep the fix, but perhaps we should add asserts at those places in the code to verify that size()==visibleSize().

> 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.


[jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12611571#action_12611571 ] 

Knut Anders Hatlen commented on DERBY-3764:
-------------------------------------------

It looks like the bug was introduced in the following revision:

------------------------------------------------------------------------
r516454 | abrown | 2007-03-09 17:37:20 +0100 (fr, 09 mar 2007) | 8 lines

DERBY-681: Remove the "wrap group by's in a subselect" rewrite in the parser.
This patch preserves the having clause through bind and optimize phases and
then, during the final rewrite for aggregates in the GroupByNode, it transforms
the having clause to a valid restriction. See text file attached to the Jira
for more information.

Contributed by Manish Khettry (manish_khettry@yahoo.com)

------------------------------------------------------------------------

> 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
>         Attachments: CONSTAS_REMESSA.sql, 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.


[jira] Updated: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Heleno da Silva Alves (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Heleno da Silva Alves updated DERBY-3764:
-----------------------------------------

    Attachment: database_test.10.4.zip

Derby 10.4 - Fail

> 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
>         Attachments: CONSTAS_REMESSA.sql, 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.


[jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12611797#action_12611797 ] 

Bryan Pendleton commented on DERBY-3764:
----------------------------------------

I agree with you that setUnionResultExpression should be using visibleSize().

We may have a number of places to fix, unfortunately.

The mergeSort assertion failure feels like a code generation problem, so the
next step might be to step through GroupByNode.generate() and see if you
can watch it generating the code, and look for places where it processes the
ResultColumnList, and see if there's a place in there where it should be
using visibleSize (which is 1) instead of size (which is 2).


> 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
>         Attachments: CONSTAS_REMESSA.sql, 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.


[jira] Assigned: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen reassigned DERBY-3764:
-----------------------------------------

    Assignee: Knut Anders Hatlen

I haven't had time to check out Bryan's suggestions yet, but I am planning to dig more into to it, so I'm assigning the issue to me.

> 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, 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.


[jira] Updated: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Heleno da Silva Alves (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Heleno da Silva Alves updated DERBY-3764:
-----------------------------------------

    Attachment: export_contas_remessas.exp

Some Data to CONTAS_REMESSA Table

> 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
>         Attachments: CONSTAS_REMESSA.sql, 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.


[jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12611756#action_12611756 ] 

Bryan Pendleton commented on DERBY-3764:
----------------------------------------

It might be as simple as needing an "isGenerated" check when manipulating
the ResultColumn data somewhere in ResultColumnList.setUnionResultExpression()
or perhaps SetOperatorNode.buildRCL()

In "select sum(x) from t group by x", there should be, conceptually, two
result columns in the result column list:
 - sum(x)
 - x

sum(x) is a normal resultcolumn, while x should have the isGenerated
flag set, indicating that it is sort of a "shadow" column which was added
to the result column list in order to enable the sorting and grouping of
the data, but is not part of the user-visible result column list.

Hope this is useful, it's just sort of an educated guess but I thought it
might be worth posting if it gave you a place to start poking around.



> 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
>         Attachments: CONSTAS_REMESSA.sql, 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.


[jira] Updated: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik updated DERBY-3764:
---------------------------------

    Issue & fix info: [High Value Fix]

> 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
>          Components: SQL
>    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
>             Fix For: 10.3.3.1, 10.4.2.0, 10.5.1.1
>
>         Attachments: CONSTAS_REMESSA.sql, d3764-1a.diff, d3764-2a.diff, d3764-2a.stat, 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.


[jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Bryan Pendleton (JIRA)" <ji...@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.


[jira] Resolved: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen resolved DERBY-3764.
---------------------------------------

       Resolution: Fixed
    Fix Version/s: 10.4.1.4
                   10.3.3.1

Committed to 10.4 with revision 679035.
Committed to 10.3 with revision 679037.

> 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
>             Fix For: 10.3.3.1, 10.4.1.4, 10.5.0.0
>
>         Attachments: CONSTAS_REMESSA.sql, d3764-1a.diff, d3764-2a.diff, d3764-2a.stat, 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.


[jira] Updated: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-3764:
--------------------------------------

       Derby Info: [Regression]  (was: [Regression, Patch Available])
    Fix Version/s: 10.5.0.0

Thanks for reviewing the patch and for all your help with this issue, Bryan.
Committed revision 678668.
I'm leaving the issue open until the fix has been back-ported to 10.3 and 10.4.

> 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
>             Fix For: 10.5.0.0
>
>         Attachments: CONSTAS_REMESSA.sql, d3764-1a.diff, d3764-2a.diff, d3764-2a.stat, 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.


[jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12615285#action_12615285 ] 

Bryan Pendleton commented on DERBY-3764:
----------------------------------------

Hi Knut, the patch looks great. The new tests are very thorough and complete.
Thanks for taking the time to cover all these different cases. +1 to commit.

> 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, d3764-2a.diff, d3764-2a.stat, 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.


[jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12613924#action_12613924 ] 

Knut Anders Hatlen commented on DERBY-3764:
-------------------------------------------

I think the key here is to find out why the group by columns from the first expression in the union are added to the result. It seems to be the case for all the set operations. If you have the following queries

  A: SELECT SUM(x) FROM t GROUP BY x
  B: VALUES 1

all of these combinations fail

  A UNION B
  A UNION ALL B
  A EXCEPT B
  A EXCEPT ALL B
  A INTERSECT B
  A INTERSECT ALL B

However, if the order is reversed (e.g, B UNION A), all of the queries succeed.

> 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.


[jira] Updated: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-3764:
--------------------------------------

    Derby Info: [Regression]  (was: [Regression, Patch Available])

Committed the 1a patch with revision 676819.

> 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.


[jira] Updated: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Heleno da Silva Alves (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Heleno da Silva Alves updated DERBY-3764:
-----------------------------------------

    Attachment: database_test.10.3.zip

Derby 10.3.1.4 (NetBeans 6.1) - Fail

> 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
>         Attachments: CONSTAS_REMESSA.sql, database_test.10.0.zip, database_test.10.3.zip
>
>
>     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.


[jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612900#action_12612900 ] 

Knut Anders Hatlen commented on DERBY-3764:
-------------------------------------------

Yet another type of failure (only seen with the patch applied, otherwise the out-of-bounds exception is thrown first):

ij> select max(x) from t group by x union all values 1;
1          |X          
-----------------------
ERROR XJ001: Java exception: ': java.lang.NullPointerException'.

Note the extra column in addition to the NPE. Wasn't there recently a discussion on derby-user about queries that returned extra columns?

The query worked in 10.2.2.0.

> 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.


[jira] Updated: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kathey Marsden updated DERBY-3764:
----------------------------------

    Component/s: SQL

> 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
>          Components: SQL
>    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
>             Fix For: 10.3.3.1, 10.4.1.4, 10.5.0.0
>
>         Attachments: CONSTAS_REMESSA.sql, d3764-1a.diff, d3764-2a.diff, d3764-2a.stat, 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.


[jira] Updated: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Heleno da Silva Alves (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Heleno da Silva Alves updated DERBY-3764:
-----------------------------------------

    Attachment: CONSTAS_REMESSA.sql

To create the Test Table

> 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
>         Attachments: CONSTAS_REMESSA.sql
>
>
>     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.


[jira] Updated: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-3764:
--------------------------------------

    Derby Info: [Patch Available, Regression]  (was: [Regression])

> 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.


[jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12613905#action_12613905 ] 

Knut Anders Hatlen commented on DERBY-3764:
-------------------------------------------

The reason why the original query doesn't fail during execution, is that both sub-queries in the union are empty, so that no data is sorted. If I insert more data into the table, that query also failed:

ij> insert into contas_remessa (cd_remessa,cd_tipo,cd_entidade,cd_mes,cd_conta,automatica,vlr_contabil,status) values (0,170,0,0,0,'',0,'S');
1 row inserted/updated/deleted
ij> 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 ;
> > > > > > > > > > > ERROR XJ001: Java exception: 'ASSERT FAILED col[3]  is null: org.apache.derby.shared.common.sanity.AssertFailure'.

> 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.


[jira] Updated: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kathey Marsden updated DERBY-3764:
----------------------------------

    Fix Version/s: 10.3.3.1

> 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
>          Components: SQL
>    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
>             Fix For: 10.3.3.1, 10.4.2.0, 10.5.0.0
>
>         Attachments: CONSTAS_REMESSA.sql, d3764-1a.diff, d3764-2a.diff, d3764-2a.stat, 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.


[jira] Updated: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-3764:
--------------------------------------

    Attachment: d3764-2a.stat
                d3764-2a.diff

Attaching a new patch which removes the extra columns in SetOperatorNode.buildRCL and adds asserts to check that size()==visibleSize() where the previous fix was added. It also adds test cases that test all the different set operations and different number of columns and grouping columns.

All the regression tests in suites.All and derbyall passed with the patch.

> 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, d3764-2a.diff, d3764-2a.stat, 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.


[jira] Updated: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Heleno da Silva Alves (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Heleno da Silva Alves updated DERBY-3764:
-----------------------------------------

    Attachment: database_test.10.3.zip

Derby 10.0 - Fail

> 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
>         Attachments: CONSTAS_REMESSA.sql, database_test.10.0.zip, database_test.10.3.zip
>
>
>     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.


[jira] Updated: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Heleno da Silva Alves (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Heleno da Silva Alves updated DERBY-3764:
-----------------------------------------

    Attachment: database_test.10.0.zip

Derby 10.0 - Works Fine

> 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
>         Attachments: CONSTAS_REMESSA.sql, database_test.10.0.zip
>
>
>     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.


[jira] Updated: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kathey Marsden updated DERBY-3764:
----------------------------------

          Derby Info: [Regression]
    Derby Categories: [High Value Fix]

I verified on trunk using the script to create the table and import data.
Here is the debug stack trace. The latest on the 10.2 looks ok. The problem seems to start with 10.3.  Marking as a regression.

ij> 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 ;
ERROR XJ001: Java exception: 'Array index out of range: 4: java.lang.ArrayIndexOutOfBoundsException'.
java.sql.SQLException: Java exception: 'Array index out of range: 4: java.lang.ArrayIndexOutOfBoundsException'.
        at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45)
        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.handleException(TransactionResourceImpl.java:346)
        at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2183)
        at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81)
        at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:614)
        at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:555)
        at org.apache.derby.impl.tools.ij.ij.executeImmediate(ij.java:329)
        at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:508)
        at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:350)
        at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:248)
        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.Main.main(Main.java:73)
        at org.apache.derby.tools.ij.main(ij.java:59)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 4
        at java.util.Vector.elementAt(Vector.java:266)
        at org.apache.derby.impl.sql.compile.QueryTreeNodeVector.elementAt(QueryTreeNodeVector.java:51)
        at org.apache.derby.impl.sql.compile.ResultColumnList.setUnionResultExpression(ResultColumnList.java:2242)
        at org.apache.derby.impl.sql.compile.SetOperatorNode.buildRCL(SetOperatorNode.java:631)
        at org.apache.derby.impl.sql.compile.SetOperatorNode.bindResultColumns(SetOperatorNode.java:558)
        at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(CursorNode.java:239)
        at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:314)
        at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:88)
        at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConne
ctionContext.java:794)
        at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:606)
        ... 9 more
ij>

> 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
>         Attachments: CONSTAS_REMESSA.sql, 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.


[jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12613901#action_12613901 ] 

Knut Anders Hatlen commented on DERBY-3764:
-------------------------------------------

It seems like the group by columns of the first sub-expression are always added to the result. When I said the original query worked with the fix that was committed, it wasn't entirely correct, since the result had two extra columns (cd_conta and ds_conta).

> 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.


[jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612839#action_12612839 ] 

Knut Anders Hatlen commented on DERBY-3764:
-------------------------------------------

It seems like changing RCL.setUnionResultExpression() to use
visibleSize() instead of size() is enough to fix the query in the
original report.

The simpler query (SELECT MAX(x) FROM t GROUP BY x UNION VALUES 1)
does however run into another ArrayIndexOutOfBoundsException in
RCL.isExactTypeAndLengthMatch(), which is the same problem as I
mentioned earlier that
   SELECT MAX(x) FROM t GROUP BY x
     UNION
   SELECT MAX(x) FROM t GROUP BY x
would run into during byte code generation.

I think the solution for isExactTypeAndLengthMatch() is the same as
for setUnionResultExpression() -- we should change size() to
visibleSize().

Although we still see problems during execution with these fixes, we
may consider checking them in as partial improvements, especially
since they appear to be enough for the originally reported query.

> 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, 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.


[jira] Updated: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-3764:
--------------------------------------

    Derby Info: [Patch Available, Regression]  (was: [Regression])

> 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, d3764-2a.diff, d3764-2a.stat, 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.


[jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612909#action_12612909 ] 

Bryan Pendleton commented on DERBY-3764:
----------------------------------------

Yes, there was such a discussion, and it's nice to see that you
appear to have found a reproducible test case. I believe that
the 2nd column should not have appeared in the output, and
indicates yet more places where the ResultColumnList is misbehaving.


> 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.


[jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12611786#action_12611786 ] 

Knut Anders Hatlen commented on DERBY-3764:
-------------------------------------------

Thanks for the suggestion, Bryan. Sounds like that's worth looking into. Here's what I found by taking a brief look at the code mentioned in the stack trace:

ResultColumnList.setUnionResultExpression() asserts that visibleSize() == otherRCL.visibleSize(), which means that the two sub-queries in the union have the same number of columns. But when it iterates over the columns, it uses size() which includes the group by columns. Since the two sub-queries have a different number of columns in the group by clause, an index-out-of-bounds exception is thrown when the method iterates over the group by columns.

I think setUnionResultExpression() should use visibleSize() instead of size(). I'm assuming here that the non-visible columns are at the end of the RCL (I vaguely recall having read something about that in a comment sometime, but I don't know this code very well). By making this change, I could get the statement to compile, but it failed during execution instead:

org.apache.derby.shared.common.sanity.AssertFailure: ASSERT FAILED template.length (2) expected to be = to nCols (1)
	at org.apache.derby.shared.common.sanity.SanityManager.THROWASSERT(SanityManager.java:162)
	at org.apache.derby.shared.common.sanity.SanityManager.THROWASSERT(SanityManager.java:147)
	at org.apache.derby.impl.store.access.sort.MergeSort.checkColumnTypes(MergeSort.java:441)
	at org.apache.derby.impl.store.access.sort.MergeInserter.insert(MergeInserter.java:98)
	at org.apache.derby.impl.sql.execute.SortResultSet.loadSorter(SortResultSet.java:317)
	at org.apache.derby.impl.sql.execute.SortResultSet.openCore(SortResultSet.java:268)
	at org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.open(BasicNoPutResultSetImpl.java:245)
	at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:384)
	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1235)
	at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:625)

> 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
>         Attachments: CONSTAS_REMESSA.sql, 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.


[jira] Updated: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Heleno da Silva Alves (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Heleno da Silva Alves updated DERBY-3764:
-----------------------------------------

    Attachment:     (was: database_test.10.3.zip)

> 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
>         Attachments: CONSTAS_REMESSA.sql, database_test.10.0.zip, database_test.10.3.zip
>
>
>     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.


[jira] Commented: (DERBY-3764) Union Query fail on Derby 10.4.1.3

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612892#action_12612892 ] 

Knut Anders Hatlen commented on DERBY-3764:
-------------------------------------------

Thanks Bryan, those are all good suggestions. I am planning both to investigate why we don't see the execution problem with the original query, and to add more tests. I'm not sure we can add the original query directly since the attached repro wasn't licensed to the ASF, but once we find out what makes the difference between the queries, it should be easy to add something equivalent to it.

> 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.