From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | MadHatter <madhtr(at)schif(dot)org> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: plpgsql - or operator? |
Date: | 2008-07-09 08:21:28 |
Message-ID: | 48747508.2040601@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
MadHatter wrote:
> If I have an expression (a or b)a where a=TRUE and b=FALSE, why is b
> evaluated? Any true operand before an or operator means the entire
> expression is true .
There is no "before" - PG makes no guarantee about evaluation order.
Don't forget a,b might well be subqueries and you don't want to prevent
PG from applying optimisations.
> ---------------------------- EXAMPLE
>
> create or replace function pinsusers() returns trigger as
>
> $$
>
> declare msg varchar;
>
> begin
>
> --THROWS EXCEPTION when ((TG_OP = 'INSERT') is TRUE "record old
> is not assigned yet"
>
> msg = ((TG_OP = 'INSERT') or (new.password<>old.password));
You're looking at nested IF .. THEN's I'm afraid. Or using pl/perl or
similar.
--
Richard Huxton
Archonet Ltd
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Ringer | 2008-07-09 08:23:56 | Re: Feature: FOR UPDATE SKIP LOCKED |
Previous Message | Csaba Nagy | 2008-07-09 08:10:58 | Re: Feature: FOR UPDATE SKIP LOCKED |