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

Re: BUG #5576: Boolean operation should not be Complete boolean evaluation

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "y(dot)y(dot)chen" <segma(dot)yychen(at)msa(dot)hinet(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5576: Boolean operation should not be Complete boolean evaluation
Date: 2010-07-29 14:14:28
Message-ID: 11349.1280412868@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
"y.y.chen" <segma(dot)yychen(at)msa(dot)hinet(dot)net> writes:
> When I run SQL -scripts in trigger/PlpgSQL:

> IF (TG_OP = 'INSERT') OR (old.size<>new.size) THEN
> .......
> END IF;

>  It raise a exception: RECORD old never be defined,
>  while TG_OP is 'INSERT'.

Yup, that's how it works.  SQL OR is not guaranteed to be short-circuit
in the same way it is in some programming languages.  You need to use
nested IF statements to make this work safely.

			regards, tom lane

In response to

pgsql-bugs by date

Next:From: yhouDate: 2010-07-30 02:01:20
Subject: BUG #5578: postrgesql database crash
Previous:From: y.y.chenDate: 2010-07-29 13:11:28
Subject: BUG #5577: Boolean operation should not be Complete boolean evaluation

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