On Mon, Oct 10, 2011 at 01:18:56PM -0400, Robert Haas wrote: > On Thu, Aug 11, 2011 at 11:43 PM, Josh Kupershmidt <schmi...@gmail.com> 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 <br...@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. +
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>
-- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs