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] [Updated] (DERBY-6443) ArrayIndexOutOfBoundsException when calling function from trigger
Date Tue, 07 Jan 2014 11:15:53 GMT

     [ https://issues.apache.org/jira/browse/DERBY-6443?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Knut Anders Hatlen updated DERBY-6443:
--------------------------------------

    Attachment: d6443-1a.diff

Attaching d6443-1a.diff which contains a fix for the bug and a regression test case to verify
the fix.

The point of the alreadyBound flag in StaticMethodCallNode seems to be to prevent infinite
recursion, since StaticMethodCallNode.bindExpression() can be called recursively in some circumstances.
If the check for the flag is removed, many regression tests fail with StackOverflowError.

Since the purpose of the flag is to prevent infinite recursion, not to prevent re-binding
of the node, I changed it so that it is only true when bindExpression() is executing. This
means recursive calls will see that it's true, and return immediately. It is reset to false
when the top-level call to bindExpression() returns, so that re-binding the node will actually
do some work. The flag was also renamed from alreadyBound to isInsideBind to reflect its new
meaning.

All regression tests ran cleanly with the patch.

> ArrayIndexOutOfBoundsException when calling function from trigger
> -----------------------------------------------------------------
>
>                 Key: DERBY-6443
>                 URL: https://issues.apache.org/jira/browse/DERBY-6443
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.0.2.1, 10.10.1.1
>            Reporter: Tim Dudgeon
>            Assignee: Knut Anders Hatlen
>         Attachments: d6443-1a.diff
>
>
> I'm having problems will calling functions from within a trigger.
> The problem seems to be with the outer function call (FLOOR() in this case, but it also
happens with other functions). It works fine in the SELECT statement, but when used in the
trigger it throws a ArrayIndexOutOfBoundsException.
> Remove the FLOOR() part from the trigger and it works fine.
> {code}
> -- create source table and some data
> CREATE TABLE foo (name VARCHAR(20), val DOUBLE);
> INSERT INTO foo (name, val) VALUES ('A', 10), ('A', 20), ('B', 30), ('C', 40);
> -- calling the function works fine here
> SELECT name, FLOOR(AVG(LOG10(val))), COUNT(*)
> FROM foo
> GROUP BY name;
> -- create target table for trigger
> CREATE TABLE summary (name VARCHAR(20), aver DOUBLE, size INT);
> -- create the trigger
> CREATE TRIGGER trg_foo AFTER INSERT ON foo
> REFERENCING NEW TABLE AS changed FOR EACH STATEMENT MODE DB2SQL
> INSERT INTO summary (name, aver, size)
> SELECT name, FLOOR(AVG(LOG10(val))), COUNT(*)
> FROM changed
> GROUP BY name;
> -- insert rows to cause trigger to fire
> INSERT INTO foo (name, val) VALUES ('A', 10), ('A', 20), ('B', 30), ('C', 40);
> SELECT * FROM foo;
> SELECT * FROM summary;
> {code}



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message