[MonetDB-users] Trigger oddities

Hi, I'm experiencing some strange trigger behaviour. Not sure if I'm simply missing something, or if I've run into a bug. create table t1 (id serial, toggle boolean); create table t2 (id serial, ref bigint); insert into t1 (toggle) values (false); insert into t1 (toggle) values (false); create trigger updateMe after update on t1 referencing new row new_row for each row when new_row.toggle = true insert into t2 (ref) values (new_row.id); update t1 set toggle = true where id = 1; After this update statement, I would expect to see *1* row in t2. Instead, I see two rows: +----+-----+ | id | ref | +====+=====+ | 1 | 1 | | 2 | 2 | +----+-----+ The "when" clause seems to be ignored entirely -- I can change to "when 1 = 0" and it'll still work. If I change the trigger to create trigger updateMe after update on t1 referencing new row new_row for each row insert into t2 (ref) values (new_row.id); something equally odd happens. Instead of doing an insert for each UPDATED row, it inserts a row for each row present in t1. This seems a bit odd to me, but again, I could just be misunderstand the way this is supposed to work. Documentation on triggers is a bit sparse I'm afraid... Any help on this issue would be more than welcome! - Bram

I don't know whether this is a bug or not (it may well be), but in any case, could you submit this as a bug report on our bug tracker (https://sourceforge.net/tracker/?func=browse&group_id=56967&atid=482468)? That makes tracking the issue easier. Thanks in advance. Bram Van Dam wrote:
Hi,
I'm experiencing some strange trigger behaviour. Not sure if I'm simply missing something, or if I've run into a bug.
create table t1 (id serial, toggle boolean); create table t2 (id serial, ref bigint);
insert into t1 (toggle) values (false); insert into t1 (toggle) values (false);
create trigger updateMe after update on t1 referencing new row new_row for each row when new_row.toggle = true insert into t2 (ref) values (new_row.id);
update t1 set toggle = true where id = 1;
After this update statement, I would expect to see *1* row in t2. Instead, I see two rows:
+----+-----+ | id | ref | +====+=====+ | 1 | 1 | | 2 | 2 | +----+-----+
The "when" clause seems to be ignored entirely -- I can change to "when 1 = 0" and it'll still work.
If I change the trigger to
create trigger updateMe after update on t1 referencing new row new_row for each row insert into t2 (ref) values (new_row.id);
something equally odd happens. Instead of doing an insert for each UPDATED row, it inserts a row for each row present in t1. This seems a bit odd to me, but again, I could just be misunderstand the way this is supposed to work. Documentation on triggers is a bit sparse I'm afraid...
Any help on this issue would be more than welcome!
- Bram
------------------------------------------------------------------------------ The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
-- Sjoerd Mullender

I don't know whether this is a bug or not (it may well be), but in any case, could you submit this as a bug report on our bug tracker (https://sourceforge.net/tracker/?func=browse&group_id=56967&atid=482468)? That makes tracking the issue easier.
Done: http://sourceforge.net/tracker/?func=detail&aid=2788876&group_id=56967&atid=482468
participants (2)
-
Bram Van Dam
-
Sjoerd Mullender