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 Jack Klebanoff <kl...@Mutagen.Net> on 2004/08/26 23:05:39 UTC

Trigger Bug Fix

I would like to submit a fix for a bug in triggers.

The bug is that a trigger of the form:
  create trigger ... values myFunction();
has no effect. MyFunction is not called even if the trigger is fired. 
Side effects of myFunction do not happen. Derby does not allow a "CALL" 
statement inside a trigger action so a values statement is the only way 
to call a function/procedure in a trigger action.

The cause of the bug is that since the values are not actually used by 
the trigger, the trigger code does not fetch the row(s) returned by the 
trigger action. The fix is simple: change class 
org.apache.derby.impl.sql.execute.GenericTriggerExecutor to fetch (and 
discard) the rows returned by a trigger action.

Please review the change. The diff file is attached.

I am an IBM employee and I have worked on Cloudscape for several years. 
However I am not a Derby committer. This is my first submission. I am 
learning the process.

Jack Klebanoff



Re: Trigger Bug Fix

Posted by Jack Klebanoff <kl...@Mutagen.Net>.
Daniel John Debrunner wrote:

> Jack Klebanoff wrote:
>
> | I would like to submit a fix for a bug in triggers.
> |
> | The bug is that a trigger of the form:
> |  create trigger ... values myFunction();
> | has no effect. MyFunction is not called even if the trigger is fired.
> | Side effects of myFunction do not happen. Derby does not allow a "CALL"
> | statement inside a trigger action so a values statement is the only way
> | to call a function/procedure in a trigger action.
> |
> | The cause of the bug is that since the values are not actually used by
> | the trigger, the trigger code does not fetch the row(s) returned by the
> | trigger action. The fix is simple: change class
> | org.apache.derby.impl.sql.execute.GenericTriggerExecutor to fetch (and
> | discard) the rows returned by a trigger action.
> |
> | Please review the change. The diff file is attached.
>
>
> I think you need to close the ResultSet (rs). Other locations in the
> code where a ResultSet is processed terminate with an rs.close(). Eg.
> see DeleteCascadeResultSet, ConstraintConstantAction.
>
> Dan.
>
I changed the code to close the ResultSet. The diff file is attached.

Jack

Re: Trigger Bug Fix

Posted by Daniel John Debrunner <dj...@debrunners.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jack Klebanoff wrote:

| I would like to submit a fix for a bug in triggers.
|
| The bug is that a trigger of the form:
|  create trigger ... values myFunction();
| has no effect. MyFunction is not called even if the trigger is fired.
| Side effects of myFunction do not happen. Derby does not allow a "CALL"
| statement inside a trigger action so a values statement is the only way
| to call a function/procedure in a trigger action.
|
| The cause of the bug is that since the values are not actually used by
| the trigger, the trigger code does not fetch the row(s) returned by the
| trigger action. The fix is simple: change class
| org.apache.derby.impl.sql.execute.GenericTriggerExecutor to fetch (and
| discard) the rows returned by a trigger action.
|
| Please review the change. The diff file is attached.


I think you need to close the ResultSet (rs). Other locations in the
code where a ResultSet is processed terminate with an rs.close(). Eg.
see DeleteCascadeResultSet, ConstraintConstantAction.

Dan.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFBLmPOIv0S4qsbfuQRAhEkAKC2yVq7Xpudm1B70axhgDkGDa8kIACeLCCi
jMHNZz2txjVdprSTfcO6tPA=
=Dprm
-----END PGP SIGNATURE-----