Skip site navigation (1) Skip section navigation (2)

Re: Short circuit operations in plpgsql?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Steve Atkins <steve(at)blighty(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Short circuit operations in plpgsql?
Date: 2004-12-20 19:55:20
Message-ID: 27516.1103572520@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-general
Steve Atkins <steve(at)blighty(dot)com> writes:
>   IF TG_OP='INSERT' OR NEW.foo != OLD.foo THEN
>     -- do stuff

> Is there anything that guarantees that the NEW.foo != OLD.foo won't
> be evaluated (and hence fail, as there is no OLD) on an insert?

The only way is to split the expression into two IF commands.  The real
problem is not with the evaluation per se, but with plpgsql having to
pass down all the variable values used in the expression before
evaluation can start.

			regards, tom lane

In response to

pgsql-general by date

Next:From: RosnyDate: 2004-12-20 20:24:17
Subject: Installing postgres 8 using Remote Desktop Connection
Previous:From: Tom LaneDate: 2004-12-20 19:53:40
Subject: Re: Diskspace

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group