Received: from smtp018.mail.yahoo.com (smtp018.mail.yahoo.com [216.136.174.115]) by postgresql.org (8.11.3/8.11.4) with SMTP id fB5LTWm01764 for ; Wed, 5 Dec 2001 16:29:32 -0500 (EST) (envelope-from janwieck@yahoo.com) Received: from psc.progress.com (HELO saturn.jw.home) (192.233.92.200) by smtp.mail.vip.sc5.yahoo.com with SMTP; 5 Dec 2001 21:29:32 -0000 Received: (from wieck@localhost) by saturn.jw.home (8.11.2/8.11.2) id fB5LQlp01967; Wed, 5 Dec 2001 16:26:47 -0500 From: Jan Wieck Message-Id: <200112052126.fB5LQlp01967@saturn.jw.home> Subject: Re: PL/pgSQL examples NOT involving functions In-Reply-To: <20011127195917.10530.qmail@213-145-170-138.dd.nextgentel.com> from Aasmund Midttun Godal at "Nov 27, 2001 07:59:17 pm" To: Aasmund Midttun Godal Date: Wed, 5 Dec 2001 16:26:47 -0500 (EST) CC: josh@agliodbs.com, pgsql-sql@postgresql.org X-Mailer: ELM [version 2.4ME+ PL68 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archive-Number: 200112/59 X-Sequence-Number: 5882 Aasmund Midttun Godal wrote: > Erm, sorry about the multiple postings, I just discovered a couple of interesting tidbits after I posted first... > > http://www.postgresql.org/idocs/index.php?plpgsql.html : > > "The PL/pgSQL call handler parses the function's source text and produces an internal binary instruction tree the first time the function is called." And that is still not entirely accurate. At the first function call the control language (IF, WHEN, etc.) is parsed. All expressions and queries are just remembered as strings with variables replaced by $n parameters. Now every statement will prepare a saved plan the first time it is hit. So when you have a function with conditional code and a specific branch of that code is never called, the statements in there will never be prepared. Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com # _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com