plpgsql and control structures - Mailing list pgsql-general

From Nick Boutelier
Subject plpgsql and control structures
Date
Msg-id 7827ee3c-d51d-4858-abc1-eb4b36025aed@y23g2000pre.googlegroups.com
Whole thread Raw
Responses Re: plpgsql and control structures  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
I noticed that if I use...

IF (TG_OP = 'DELETE' AND OLD.myColumn) THEN
  -- Do something
END IF;

when an insert happens, I get an error that 'OLD' has not been
assigned. I would of thought that the control structure would just
ignored the rest of the 'if' statement if the first part (TG_OP) was
false.

Does this mean I have to branch out my control structures if I want
better speed? If the first part of the 'if' is rarely true, then I
might as well put the second control within the first.

-Nick

pgsql-general by date:

Previous
From: wstrzalka
Date:
Subject: Re: Pet Peeves?
Next
From: "Eric Brown"
Date:
Subject: Is dropping pg_ts_* harmful?