Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T1UEx-0003fo-Tg for pgsql-docs@postgresql.org; Wed, 15 Aug 2012 03:25:51 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T1UEv-0003V4-Tt for pgsql-docs@postgresql.org; Wed, 15 Aug 2012 03:25:51 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1T1UEv-0008Bl-D6; Tue, 14 Aug 2012 23:25:49 -0400 Date: Tue, 14 Aug 2012 23:25:49 -0400 From: Bruce Momjian To: Josh Kupershmidt Cc: Robert Haas , pgsql-docs Subject: Re: lo_manage trigger on updates Message-ID: <20120815032549.GD25473@momjian.us> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201208/19 X-Sequence-Number: 7412 On Tue, Oct 11, 2011 at 08:08:32PM -0400, Josh Kupershmidt wrote: > On Mon, Oct 10, 2011 at 1:18 PM, Robert Haas wrote: > > On Thu, Aug 11, 2011 at 11:43 PM, Josh Kupershmidt 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. > > Yeah, the syntax we have is really confusing. I notice this tidbit on that page: > > | The ability to specify multiple actions for a single trigger using OR > | is a PostgreSQL extension of the SQL standard. > > Maybe the folks dreaming up the SQL standard are sharper than they get > credit for. > > > 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. > > The nice thing about keeping the example the way it is, is that it's > pretty simple to understand, and maybe adding the second slightly more > complicated example would just confuse things. We could just add in a > blurb like this at the end of "How to Use It": > > You may wish to restrict the trigger > to only fire upon UPDATEs of the lo column(s) in the table by > specifying the column name via BEFORE UPDATE OF > column_name. I think I like that idea so I used your text instead of the full new example. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. +