Re: [HACKERS] Odd plpgsql behaviour

2004-11-15 Thread Tom Lane
Mike Rylander <[EMAIL PROTECTED]> writes: > IIRC, the reason for this is that the entire IF test is passed to the > SQL engine as a SELECT statement after replacing the TG_* identifiers > with their respective values. > In this case, since OLD.name does not exist during INSERT it cannot be > replac

Re: [HACKERS] Odd plpgsql behaviour

2004-11-15 Thread Mike Rylander
On Mon, 15 Nov 2004 15:12:24 +0800, Christopher Kings-Lynne <[EMAIL PROTECTED]> wrote: > On 7.4: > > This is what we wanted to do: > > IF TG_OP = 'INSERT' OR (TG_OP = 'UPDATE' AND NEW.name != OLD.name) THEN > EXECUTE x; > END IF; > > However, we had to write it like this: > > IF TG_OP = 'INSE

[HACKERS] Odd plpgsql behaviour

2004-11-14 Thread Christopher Kings-Lynne
On 7.4: This is what we wanted to do: IF TG_OP = 'INSERT' OR (TG_OP = 'UPDATE' AND NEW.name != OLD.name) THEN EXECUTE x; END IF; However, we had to write it like this: IF TG_OP = 'INSERT' THEN EXECUTE x; ELSIF TG_OP = 'UPDATE' AND NEW.name != OLD.name THEN EXECUTE x; END IF; Because in the first