Re: [GENERAL] PL/PGSQL: why IF test the whole condition before failing or not?

2009-08-20 Thread Jasen Betts
On 2009-08-18, Suporte PK wrote: > Hi list, > > I'm having trouble with - believe me! - the IF operator on a PL/PGSQL > function used by a trigger. > > I'm using one unique function to process the three triggers events > (delete, update and insert), but when I reference OLD or NEW on a IF > CON

Re: [GENERAL] PL/PGSQL: why IF test the whole condition before failing or not?

2009-08-18 Thread Tom Lane
Suporte PK writes: > IF TG_OP = 'UPDATE' AND OLD.field != NEW.field THEN > ... > The question is: if the trigger was not fired by an UPDATE event, > shouldn't it make the first test and then ignore the rest of the condition? No. This is a very very common error. The behavior is not as short-ci

[GENERAL] PL/PGSQL: why IF test the whole condition before failing or not?

2009-08-18 Thread Suporte PK
Hi list, I'm having trouble with - believe me! - the IF operator on a PL/PGSQL function used by a trigger. I'm using one unique function to process the three triggers events (delete, update and insert), but when I reference OLD or NEW on a IF CONDITION, I get an error even when testing BEFOR