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 Mamta Satoor <ms...@gmail.com> on 2013/09/12 02:40:25 UTC

Triggers should be fired in the order they were created?

Hi,

I am working on DERBY-5866(
testFiringConstraintOrder(org.apache.derbyTesting.functionTests.tests.lang.TriggerTest)junit.framework.AssertionFailedError:
matching triggers need to be fired in order creation:1,NO CASCADE
BEFORE,DELETE,ROW). The test fixture testFiringConstraintOrder creates
handful of triggers of various types and expects that the triggers will be
fired in the order they were created. Intermittently, the test fails
because the order of firing does not match order of creation. I will change
the test such that the next intermittent failure will leave a database
behind for further debugging. But I was wondering if anyone knows of a
scenario when order of firing might not be same as order of creation. Or
possibly, this is a bug?

thanks,
Mamta

Re: Triggers should be fired in the order they were created?

Posted by Mamta Satoor <ms...@gmail.com>.
Thanks Knut. I will checkin changes to the test so that we will have a db
to work with the next time around the test fails.


On Thu, Sep 12, 2013 at 12:34 AM, Knut Anders Hatlen <knut.hatlen@oracle.com
> wrote:

> Mamta Satoor <ms...@gmail.com> writes:
>
> > Hi,
> >
> > I am working on DERBY-5866( testFiringConstraintOrder
> >
> (org.apache.derbyTesting.functionTests.tests.lang.TriggerTest)junit.framework.
> > AssertionFailedError: matching triggers need to be fired in order
> > creation:1,NO CASCADE BEFORE,DELETE,ROW). The test fixture
> > testFiringConstraintOrder creates handful of triggers of various types
> > and expects that the triggers will be fired in the order they were
> > created. Intermittently, the test fails because the order of firing
> > does not match order of creation. I will change the test such that the
> > next intermittent failure will leave a database behind for further
> > debugging. But I was wondering if anyone knows of a scenario when
> > order of firing might not be same as order of creation. Or possibly,
> > this is a bug?
>
> Hi Mamta,
>
> Triggers firing out of order is a bug.
>
> The reference manual says they should be fired in the order of creation:
>
> http://db.apache.org/derby/docs/10.10/ref/rrefsqlj43125.html
>
> |   When multiple triggers are defined for the same database event for
> |   the same table for the same trigger time (before or after), triggers
> |   are fired in the order in which they were created.
>
> Also, I found this in SQL:2003, part 2, section 4.38.1 General
> description of triggers:
>
> |   The order of execution of a set of triggers is ascending by value of
> |   their timestamp of creation in their descriptors, such that the
> |   oldest trigger executes first.
>
>
> --
> Knut Anders
>

Re: Triggers should be fired in the order they were created?

Posted by Knut Anders Hatlen <kn...@oracle.com>.
Mamta Satoor <ms...@gmail.com> writes:

> Hi,
>
> I am working on DERBY-5866( testFiringConstraintOrder
> (org.apache.derbyTesting.functionTests.tests.lang.TriggerTest)junit.framework.
> AssertionFailedError: matching triggers need to be fired in order
> creation:1,NO CASCADE BEFORE,DELETE,ROW). The test fixture
> testFiringConstraintOrder creates handful of triggers of various types
> and expects that the triggers will be fired in the order they were
> created. Intermittently, the test fails because the order of firing
> does not match order of creation. I will change the test such that the
> next intermittent failure will leave a database behind for further
> debugging. But I was wondering if anyone knows of a scenario when
> order of firing might not be same as order of creation. Or possibly,
> this is a bug?

Hi Mamta,

Triggers firing out of order is a bug.

The reference manual says they should be fired in the order of creation:

http://db.apache.org/derby/docs/10.10/ref/rrefsqlj43125.html

|   When multiple triggers are defined for the same database event for
|   the same table for the same trigger time (before or after), triggers
|   are fired in the order in which they were created.

Also, I found this in SQL:2003, part 2, section 4.38.1 General
description of triggers:

|   The order of execution of a set of triggers is ascending by value of
|   their timestamp of creation in their descriptors, such that the
|   oldest trigger executes first.


-- 
Knut Anders