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

Re: wierd AND condition evaluation for plpgsql

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Louis-David Mitterrand <vindex(at)apartia(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: wierd AND condition evaluation for plpgsql
Date: 2002-05-28 14:06:03
Message-ID: 2787.1022594763@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
Louis-David Mitterrand <vindex(at)apartia(dot)org> writes:
> I just noticed plpgsql evaluates all AND'ed conditions even if the first
> one fails. Example:

> 	elsif TG_OP = ''UPDATE'' and old.type_reponse = ''abandon''

> This will break stuff if the trigger is used on INSERT as
> "old.type_reponse" will be substituted and return an error.

I think you are confusing "evaluation" with "syntax checking".

Try putting the reference to OLD inside a nested IF command.

			regards, tom lane

In response to

pgsql-hackers by date

Next:From: Kovacs ZoltanDate: 2002-05-28 14:26:09
Subject: Re: cache lookup failed: hack pg_* tables?
Previous:From: Kovacs ZoltanDate: 2002-05-28 13:53:34
Subject: cache lookup failed: hack pg_* tables?

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