"Olleg Samoylov" <olleg(at)mipt(dot)ru> writes:
> create rule delete_first as on delete to v do instead (delete from a where
> a=old.a;update c set c=c-1);
> delete from v where a=0;
> select * from a;
> -- 0 row, as expected :-)
> select * from c;
> -- 1, this is incorrect
This isn't a bug. The DELETE causes the a=0 row to disappear from the
view, so the subsequent statement (which is implicitly conditional on
there being an a=0 row) doesn't do anything. If it did do something,
then a "delete from v" that didn't delete any rows would still decrement
c, which is not what you want, eh?
regards, tom lane