Actually, at least in some cases, PG does short-circuit logic: create function seeme() returns bool as ' begin raise notice ''seeme''; return true; end' language plpgsql;
joel@joel=# select false and seeme(); ?column? ---------- f (1 row) joel@joel=# select true and seeme(); NOTICE: seeme ?column? ---------- t (1 row) In your case, the problem is short-circuiting a test, it's that the full statement must be parsed and prepared, and it's probably in this stage that the illegal use of old. in an insert jumps up. HTH. Joel BURTON | [EMAIL PROTECTED] | joelburton.com | aim: wjoelburton Knowledge Management & Technology Consultant > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]]On Behalf Of Louis-David > Mitterrand > Sent: Tuesday, May 28, 2002 3:21 AM > To: [EMAIL PROTECTED] > Subject: [HACKERS] wierd AND condition evaluation for plpgsql > > > > Hi, > > I just noticed plpgsql evaluates all AND'ed conditions even if the first > one fails. Example: > > elsif TG_OP = ''UPDATE'' and old.type_reponse = ''abandon'' > > This will break stuff if the trigger is used on INSERT as > "old.type_reponse" will be substituted and return an error. > > Shouldn't plpgsql shortcut AND conditions when a previous one fails, as > perl does? > > -- > OENONE: Quoi ? > PHEDRE: Je te l'ai prédit, mais tu n'as pas voulu. > (Phèdre, J-B Racine, > acte 3, scène 3) > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to [EMAIL PROTECTED] so that your > message can get through to the mailing list cleanly > ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster