Skip site navigation (1) Skip section navigation (2)

Re: Plperlu and sending emails, is it safe?

From: Thomas Hallgren <thhal(at)mailblocks(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Plperlu and sending emails, is it safe?
Date: 2004-06-28 15:18:30
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
Tom Lane wrote:
> The real issue here is transactional semantics.  What happens if the
> transaction that fired the trigger rolls back due to a later error?
> The transaction effectively never happened, but you can't unsend the mail.
As I browsed to the code for commit, I found this in xact.c (much to my 
surprise, I was told nothing like this existed):

  * Register or deregister callback functions for end-of-xact cleanup
  * These functions are intended for use by dynamically loaded modules.
  * For built-in modules we generally just hardwire the appropriate calls
  * (mainly because it's easier to control the order that way, where
  * needed).
  * Note that the callback occurs post-commit or post-abort, so the
  * callback functions can only do noncritical cleanup.
RegisterEOXactCallback(EOXactCallback callback, void *arg)

If Plperlu have hooks for these callbacks, you could prepare the email 
using a trigger up to a point where everything is as ready as it 
possibly can be without actually being sent. Then, at the end of the 
transaction, you either send or remove all prepared emails depending on 
the outcome.

I plan to add hooks for EOXactCallbacks in Pl/Java if I no one advice me 
that it would be really bad idea.

I would like to make it possible to add a callback that's called just at 
the start of a transaction as well. Such callbacks would have the 
ability to generate an error and abort the transaction. Would such a 
patch be well received?

Kind regards,

Thomas Hallgren

In response to


pgsql-general by date

Next:From: Thomas HallgrenDate: 2004-06-28 15:32:55
Subject: Re: Plperlu and sending emails, is it safe?
Previous:From: UMPA DevelopmentDate: 2004-06-28 15:15:48
Subject: Group by - Case insensitivity

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group