A Little Noise

January 26, 2010

Trigger on firing table

Filed under: MySQL — snoyes @ 4:07 pm
CREATE TABLE t1 (id int);
CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW 
  INSERT INTO t1 VALUES (NEW.id);

That’s not allowed; it won’t let you create the trigger.

CREATE TABLE t1 (id int);
CREATE TABLE f1 (id int) ENGINE=FEDERATED CONNECTION='localhost/test/t1';
CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW 
  INSERT INTO f1 VALUES (NEW.id);

The server lets that through. Don’t do it.

2 Comments »

  1. I think you can do the same “feature” with merge table.


    Tom

    Comment by Tom Hanlon — January 26, 2010 @ 5:38 pm

  2. C’mon! it is not a bug, it’s a feature! :)
    http://datacharmer.blogspot.com/2008/01/multiple-triggers-for-same-event-bug-or.html

    Or may be not. It depends on how much you want to break your system. If using replication, for example, Federated will break it independently of triggers. http://bugs.mysql.com/bug.php?id=31757

    Cheers

    Giuseppe

    Comment by Giuseppe Maxia — January 27, 2010 @ 8:21 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress