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

Started by y.y.chenover 15 years ago2 messagesbugs
Jump to latest
#1y.y.chen
segma.yychen@msa.hinet.net

The following bug has been logged online:

Bug reference: 5576
Logged by: y.y.chen
Email address: segma.yychen@msa.hinet.net
PostgreSQL version: 8.4.x
Operating system: WINDOWS-XP
Description: Boolean operation should not be Complete boolean
evaluation
Details:

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'.

--------------------------------
It is happen in 8.3.11,8.4.1~8.4.4-1
But 9.0.0.beta 3 is OK!

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: y.y.chen (#1)
Re: BUG #5576: Boolean operation should not be Complete boolean evaluation

"y.y.chen" <segma.yychen@msa.hinet.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