Peter Eisentraut <peter_e@gmx.net> writes:
> What is the preferred way to implement non-database side effects, such as
> triggering emails when certain events occur? We should try to explain
> this somewhere.
> Certainly, PL/sh is not the preferred way. It's terribly inefficient and
> not nearly portable.
As Jan pointed out, either plperlu or pltclu can accomplish just about
anything you'd want in that line, even without the escape hatch of
firing a shell script.
I think Bruce has correctly identified a documentation deficiency:
there's not any material explaining the transaction-unsafety risks of
using these PLs to do stuff outside the database. We should talk
about that someplace.
My opinion is that the *preferred* way would involve having a background
client-side task that watches for things to do (eg via NOTIFY/LISTEN),
and then updates the database to indicate that it's done it. This
doesn't require any unsafe PL programming at all, but it does mean extra
work to set up a suitable client task. An example would make a great
contrib item ...
regards, tom lane