Re: short ciruit logic of plpgsql in 8.2

From: "Ian Harding" <harding(dot)ian(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Richard Broersma Jr" <rabroersma(at)yahoo(dot)com>, "General PostgreSQL List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: short ciruit logic of plpgsql in 8.2
Date: 2007-05-22 17:55:44
Message-ID: 725602300705221055i3bc2317dw9f588ed6ee539b96@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

This keeps biting me. In a trigger function for INSERT OR UPDATE if you try

IF TG_OP = 'UPDATE' AND OLD.foo = 'bar' THEN
...

it will blow up on inserts because there is no OLD. I always expect
this to short circuit and am always disappointed. Easy fix, of
course...

IF TG_OP = 'UPDATE' THEN
IF OLD.foo = 'bar' THEN
...

In case this was what the OP was asking about in particular, it still
happens to me in 8.2

- Ian

On 5/17/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Richard Broersma Jr <rabroersma(at)yahoo(dot)com> writes:
> > Does anyone know if logic operations in plpgsql are short circuited in 8.2?
>
> They are often optimized, but if you expect "short circuiting" following
> exactly the rules of, say, C, you are likely to be disappointed. See
> the manual:
>
> http://www.postgresql.org/docs/8.2/static/sql-expressions.html#SYNTAX-EXPRESS-EVAL
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michelle Konzack 2007-05-22 17:58:11 Re: How to move tables in another physial place
Previous Message Ron Johnson 2007-05-22 17:45:23 Re: How to move tables in another physial place