Search Postgresql Archives

Re: plpgsql - or operator?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux