public inbox for [email protected]
help / color / mirror / Atom feedFrom: Josh Kupershmidt <[email protected]>
To: pgsql-docs <[email protected]>
Subject: lo_manage trigger on updates
Date: Thu, 11 Aug 2011 23:43:47 -0400
Message-ID: <CAK3UJRHaEuzfnZaxarcV8=RP1sC5xLxumzqx6iiyqpJVS89rjw@mail.gmail.com> (raw)
Hi all,
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?
On a similar note, the warning on that page about truncates could be
softened if we extended the lo_manage() function to handle truncates,
and set it up as on ON TRUNCATE trigger as well.
Josh
Attachments:
[application/octet-stream] lo.diff (1.7K, 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..0ced3ae
*** a/doc/src/sgml/lo.sgml
--- b/doc/src/sgml/lo.sgml
***************
*** 69,82 ****
<programlisting>
CREATE TABLE image (title TEXT, raster lo);
! CREATE TRIGGER t_raster BEFORE UPDATE OR DELETE ON image
FOR EACH ROW EXECUTE PROCEDURE lo_manage(raster);
</programlisting>
<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>
--- 69,90 ----
<programlisting>
CREATE TABLE image (title TEXT, raster lo);
! CREATE TRIGGER t_raster BEFORE UPDATE OF raster OR DELETE ON image
FOR EACH ROW EXECUTE PROCEDURE lo_manage(raster);
</programlisting>
<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 may wish to restrict the trigger
! to only fire upon UPDATEs of the <type>lo</> column(s) in the table by
! specifying the column name via BEFORE UPDATE OF
! <replaceable class="parameter">column_name</replaceable> as in the example
! above.
! </para>
!
! <para>
! 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]
Subject: Re: lo_manage trigger on updates
In-Reply-To: <CAK3UJRHaEuzfnZaxarcV8=RP1sC5xLxumzqx6iiyqpJVS89rjw@mail.gmail.com>
* 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