firing of h2 trigger

128 views
Skip to first unread message

Vineela Gampa

unread,
Apr 18, 2013, 3:48:38 PM4/18/13
to h2-da...@googlegroups.com
Hi

When does h2 start firing the trigger ? From my test it sounded like h2 fires the trigger before commit happens ? Is that correct ?



Thanks
Vineela

Rami Ojares

unread,
Apr 18, 2013, 10:54:45 PM4/18/13
to h2-da...@googlegroups.com

Hi Vineela,

The answer is yes. Triggers are fired at statement boundary. That means after or before statement and always before commit.

--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Mark Addleman

unread,
Apr 19, 2013, 12:03:44 PM4/19/13
to h2-da...@googlegroups.com
We would like to use triggers as an indication to our application that data has changed in H2.  Is there a way to get notified on the commit?  Otherwise, what do you think about enhancing the trigger semantics to support notify at the transaction boundary?

Rami Ojares

unread,
Apr 19, 2013, 1:19:32 PM4/19/13
to h2-da...@googlegroups.com
I suggested that once but I couldn't get my head around H2's source code.

- Rami

Mark Addleman

unread,
Apr 19, 2013, 3:23:54 PM4/19/13
to h2-da...@googlegroups.com
To Thomas or any other h2 committee : we'll gladly submit a patch for a commit callback feature if you give us a hint where to start.

Noel Grandin

unread,
Apr 20, 2013, 3:49:49 PM4/20/13
to h2-da...@googlegroups.com
Heh. There isn't really. At the point in time that commit occurs, the rows has already been written into binary format, so there would be nothing to pass to the trigger. 

What might be possible is to create a special kind of trigger that fires on a commit. 
Then you could probably use a combination of a normal trigger and a commit trigger to do what you want. 

For that, I think the Session class is where you want to start. 


On Friday, 19 April 2013, Mark Addleman wrote:
To Thomas or any other h2 committee : we'll gladly submit a patch for a commit callback feature if you give us a hint where to start.

Mark Addleman

unread,
Apr 20, 2013, 3:58:48 PM4/20/13
to h2-da...@googlegroups.com

Yes. I was thinking of some sort of two step approach.  We'll take a look at the session class.thanks

You received this message because you are subscribed to a topic in the Google Groups "H2 Database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/h2-database/huLqCpFQOhw/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to h2-database...@googlegroups.com.
Message has been deleted

Thomas Mueller

unread,
Apr 21, 2013, 2:10:56 PM4/21/13
to H2 Google Group
Hi,

I wonder, why is the current trigger mechanism not good enough for your? What feature are you missing? See also http://h2database.com/html/grammar.html#create_trigger

Regards,
Thomas


On Sat, Apr 20, 2013 at 10:11 PM, Mark Addleman <markad...@gmail.com> wrote:

Mark.A...@CA.com

On Apr 20, 2013 12:49 PM, "Noel Grandin" <noelg...@gmail.com> wrote:
You received this message because you are subscribed to a topic in the Google Groups "H2 Database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/h2-database/huLqCpFQOhw/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to h2-database...@googlegroups.com.

To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Mark Addleman

unread,
Apr 21, 2013, 4:27:24 PM4/21/13
to h2-da...@googlegroups.com

We want to use the trigger to detect changes in a table then drive new work in a different transaction.   Since triggers are fired before the commit, the second transaction doesn't see the updates.

We don't really need any row information in the trigger, we really just need to know when the commit completes

Reply all
Reply to author
Forward
0 new messages