public inbox for [email protected]  
help / color / mirror / Atom feed
From: Bruce Momjian <[email protected]>
To: Robert Haas <[email protected]>
Cc: Josh Kupershmidt <[email protected]>
Cc: pgsql-docs <[email protected]>
Subject: Re: lo_manage trigger on updates
Date: Tue, 14 Aug 2012 23:22:20 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <CA+TgmoZQEbFFRR9X25azdBMpWcYx6RDncTODF0hOcR9GYRz0dw@mail.gmail.com>
References: <CAK3UJRHaEuzfnZaxarcV8=RP1sC5xLxumzqx6iiyqpJVS89rjw@mail.gmail.com>
	<CA+TgmoZQEbFFRR9X25azdBMpWcYx6RDncTODF0hOcR9GYRz0dw@mail.gmail.com>

On Mon, Oct 10, 2011 at 01:18:56PM -0400, Robert Haas wrote:
> On Thu, Aug 11, 2011 at 11:43 PM, Josh Kupershmidt <[email protected]> wrote:
> > I think the doc section about using lo_manage() as a trigger:
> >   http://www.postgresql.org/docs/current/static/lo.html
> >
> > could have its example tweaked to use a column-level BEFORE UPDATE
> > trigger, so as to save unnecessary trigger firings. Something like the
> > attached, perhaps?
> 
> Uh, wow.  That syntax is horribly surprising, isn't it?  My eyes want
> to parse it as:
> 
> BEFORE (UPDATE OF raster) OR (DELETE ON image)
> 
> ...which is totally wrong.
> 
> I'm inclined to think that maybe we should leave that example as-is,
> and maybe add the variant you're proposing as a second example,
> showing how the basic version can be refined.

I have implemented this suggestion with the attached, applied patch to
9.3.

-- 
  Bruce Momjian  <[email protected]>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +


Attachments:

  [text/x-diff] lo.diff (1.3K, 2-lo.diff)
  download | inline diff:
diff --git a/doc/src/sgml/lo.sgml b/doc/src/sgml/lo.sgml
new file mode 100644
index 3d56ba3..0c11fdc
*** a/doc/src/sgml/lo.sgml
--- b/doc/src/sgml/lo.sgml
*************** CREATE TRIGGER t_raster BEFORE UPDATE OR
*** 76,82 ****
    <para>
     For each column that will contain unique references to large objects,
     create a <literal>BEFORE UPDATE OR DELETE</> trigger, and give the column
!    name as the sole trigger argument.  If you need multiple <type>lo</>
     columns in the same table, create a separate trigger for each one,
     remembering to give a different name to each trigger on the same table.
    </para>
--- 76,90 ----
    <para>
     For each column that will contain unique references to large objects,
     create a <literal>BEFORE UPDATE OR DELETE</> trigger, and give the column
!    name as the sole trigger argument.  You can also restrict the trigger
!    to only execute on updates to the column with:
! 
! <programlisting>
! CREATE TRIGGER t_raster BEFORE UPDATE OF raster OR DELETE ON image
!     FOR EACH ROW EXECUTE PROCEDURE lo_manage(raster);
! </programlisting>
! 
!    If you need multiple <type>lo</>
     columns in the same table, create a separate trigger for each one,
     remembering to give a different name to each trigger on the same table.
    </para>


view thread (5+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: lo_manage trigger on updates
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox