db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-2016) ArrayIndexOutOfBoundsException for COALESCE with aggregate functions
Date Wed, 21 Nov 2007 11:20:43 GMT

    [ https://issues.apache.org/jira/browse/DERBY-2016?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12544423
] 

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

Patch c looks good! Nits: Couldn't firstNonParameterNodeIdx be private? And perhaps you could
add /** ... */ around the fine comment you wrote so that it turns up in the generated javadoc.

By the way, would it be better to initialize firstNonParameterNodeIdx with an invalid index
value (like -1) instead of 0? Not a big deal, since it must be an internal bug if we don't
find a non-parameter node in the list. But the old code would cause a NullPointerException
if it was not found, whereas the new code will silently ignore it. (Ideally, I guess we should
have had a findFirstNonParameterNode() method in ValueNodeList instead of storing it in a
field. It's only used once anyway, isn't it?)

Regardless of what you choose to do with the above comments, I'm +1 to committing patch c,
as it's definitely an improvement.

> ArrayIndexOutOfBoundsException for COALESCE with aggregate functions
> --------------------------------------------------------------------
>
>                 Key: DERBY-2016
>                 URL: https://issues.apache.org/jira/browse/DERBY-2016
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.2.1.6, 10.2.2.0, 10.3.1.4
>         Environment: 1.5.0_06-b05
>            Reporter: Christian d'Heureuse
>            Assignee: Dag H. Wanvik
>         Attachments: DERBY-2016.diff, DERBY-2016.stat, DERBY-2016b.diff, DERBY-2016b.stat,
DERBY-2016c.diff, DERBY-2016c.stat
>
>
> The following statements produce an ArrayIndexOutOfBoundsException:
> CREATE TABLE t1 (
>    f1 INTEGER);
> SELECT COALESCE(MAX(f1),0) FROM t1;
> Workaround:
>    VALUES COALESCE( (SELECT MAX(f1) FROM t1), 0);
> Stack trace:
> ----------------------------------------------------------------
> 2006-10-29 14:52:53.765 GMT:
>  Booting Derby version The Apache Software Foundation - Apache Derby - 10.2.1.6 - (452058):
instance c013800d-010e-948f-0faa-00000012f418
> on database directory C:\temp_sys\temp_Derby_TestErr_db
> Database Class Loader started - derby.database.classpath=''
> 2006-10-29 14:53:02.906 GMT Thread[main,5,main] (XID = 122), (SESSIONID = 0), (DATABASE
= c:\temp_sys\temp_Derby_TestErr_db), (DRDAID = null), Cleanup action starting
> 2006-10-29 14:53:02.906 GMT Thread[main,5,main] (XID = 122), (SESSIONID = 0), (DATABASE
= c:\temp_sys\temp_Derby_TestErr_db), (DRDAID = null), Failed Statement is: SELECT COALESCE(MAX(f1),0)
FROM t1
> java.lang.ArrayIndexOutOfBoundsException: -1
>         at org.apache.derby.impl.services.bytecode.BCMethod.popStack(Unknown Source)
>         at org.apache.derby.impl.services.bytecode.BCMethod.callMethod(Unknown Source)
>         at org.apache.derby.impl.sql.compile.ResultColumnList.generateCore(Unknown Source)
>         at org.apache.derby.impl.sql.compile.ProjectRestrictNode.generateMinion(Unknown
Source)
>         at org.apache.derby.impl.sql.compile.ProjectRestrictNode.generate(Unknown Source)
>         at org.apache.derby.impl.sql.compile.ScrollInsensitiveResultSetNode.generate(Unknown
Source)
>         at org.apache.derby.impl.sql.compile.CursorNode.generate(Unknown Source)
>         at org.apache.derby.impl.sql.compile.StatementNode.generate(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.apache.derby.impl.tools.ij.ij.executeImmediate(Unknown Source)
>         at org.apache.derby.impl.tools.ij.utilMain.doCatch(Unknown Source)
>         at org.apache.derby.impl.tools.ij.utilMain.go(Unknown Source)
>         at org.apache.derby.impl.tools.ij.Main.go(Unknown Source)
>         at org.apache.derby.impl.tools.ij.Main.mainCore(Unknown Source)
>         at org.apache.derby.impl.tools.ij.Main14.main(Unknown Source)
>         at org.apache.derby.tools.ij.main(Unknown Source)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message