"Andrus" <eetasoft(at)online(dot)ee> writes:
> Postgres 8.1 calls "foo" delete trigger when record is deleted from master
> table "klient". Why ?
Because you have an ON DELETE CASCADE. That leads to a DELETE ... WHERE ...
on the slave table; whether any records actually get deleted depends on
what the DELETE finds. This is a general hazard of using STATEMENT
triggers: you have no info about whether the statement actually did
anything. (It's rather silly to imagine that a BEFORE STATEMENT trigger
would have any way to know that anyway. We currently don't tell an
AFTER STATEMENT trigger anything either; though that may change
someday.)
regards, tom lane