[CentralOH] PL/Python slides

Josh Williams joshwilliams at ij.net
Fri Jan 29 06:29:34 CET 2010


Hello Python People,

The slides and code from the PL/Python presentation are up and available
at:
http://joshwilliams.name/plpython/

A couple additional comments & corrections that aren't up on there...

PostgreSQL actually does support deferred triggers, so that actions
performed outside the database can happen as close to the transaction
commit as possible (and consequently don't happen if the transaction is
rolled back.)  See CREATE CONSTRAINT TRIGGER, which has been around with
deferrable support since 8.2.[1]

There's a couple caveats, though.  Constraint triggers only support
running as AFTER/FOR EACH ROW.  This wouldn't be a big deal for a
trigger that deletes files that have pointers removed (actually it'd
probably be ideal for that) but for something like our hypothetical
financial app we'd have to be careful and/or clever lest we risk sending
redundant email on a multi-account update.

Additionally the function should probably take as much care as possible
to handle any errors itself, or at least avoid raising any to Postgres
at all cost, since any other row triggers may have already been executed
and had side effects that won't be rolled back.  So I'd advise using
this carefully and only when necessary, but even so it can be a powerful
feature.


Since there was some interest the Ohio PostgreSQL Users Group is up at
http://pugs.postgresql.org/ohiopug though now that I look the mailing
list[2] isn't clearly linked from there.  Will need to fix that...

- Josh

[1]http://www.postgresql.org/docs/current/interactive/sql-createconstraint.html
[2]http://archives.postgresql.org/ohiopug/




More information about the CentralOH mailing list