Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 771B7B5DBD6 for ; Tue, 11 Oct 2011 21:08:59 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 53544-02 for ; Wed, 12 Oct 2011 00:08:52 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mail-qy0-f174.google.com (mail-qy0-f174.google.com [209.85.216.174]) by mail.postgresql.org (Postfix) with ESMTP id 2E94AB5DBD0 for ; Tue, 11 Oct 2011 21:08:52 -0300 (ADT) Received: by qyk30 with SMTP id 30so4169191qyk.19 for ; Tue, 11 Oct 2011 17:08:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=ezHlRFK6PnaFlZZl8Ce5ZUjZl7vsK+XFmE6zPsloAfg=; b=oYCOBrRcRKgelQvEd8VNcy/WE4HvlSO/Mt0FwsK4EybYNSlYb/95o+ou2QjD1qIoAz GDtglxbXZlD9peu4D44Y3p3HWy3vKz90G9QmnyWhqxvFoF1GlJn6hWkJi7avjKd91qXn CcIDMr3dncahhDcDs6hRR/h73AbLodBhlix28= Received: by 10.229.11.7 with SMTP id r7mr5381011qcr.239.1318378132107; Tue, 11 Oct 2011 17:08:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.50.11 with HTTP; Tue, 11 Oct 2011 17:08:32 -0700 (PDT) In-Reply-To: References: From: Josh Kupershmidt Date: Tue, 11 Oct 2011 20:08:32 -0400 Message-ID: Subject: Re: lo_manage trigger on updates To: Robert Haas Cc: pgsql-docs Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.899 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001 X-Spam-Level: X-Archive-Number: 201110/26 X-Sequence-Number: 7026 On Mon, Oct 10, 2011 at 1:18 PM, Robert Haas wrote: > On Thu, Aug 11, 2011 at 11:43 PM, Josh Kupershmidt w= rote: >> I think the doc section about using lo_manage() as a trigger: >> =A0 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. =A0That syntax is horribly surprising, isn't it? =A0My 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. >> 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. > > Patch? =A0:-) I toyed around with it, but then lost interest because it'd require almost rewriting the entire lo/ module, and I just wasn't in the mood. Maybe someone will feel like messing with it. Josh