Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 81AE5B5DBF8 for ; Wed, 25 May 2011 14:12:02 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 18234-03 for ; Wed, 25 May 2011 17:11:54 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 0B5D1B5DBE5 for ; Wed, 25 May 2011 14:11:53 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p4PHBX9E023539; Wed, 25 May 2011 13:11:33 -0400 (EDT) To: Heikki Linnakangas cc: PostgreSQL-development Subject: Re: Nested CASE-WHEN scoping In-reply-to: <4DDD35B6.2050203@enterprisedb.com> References: <4DDCEEB8.50602@enterprisedb.com> <5487.1306334876@sss.pgh.pa.us> <4DDD35B6.2050203@enterprisedb.com> Comments: In-reply-to Heikki Linnakangas message dated "Wed, 25 May 2011 20:00:38 +0300" Date: Wed, 25 May 2011 13:11:33 -0400 Message-ID: <23538.1306343493@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.01 tagged_above=-5 required=5 tests=T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201105/1286 X-Sequence-Number: 188320 Heikki Linnakangas writes: > On 25.05.2011 17:47, Tom Lane wrote: >> [ scratches head ... ] Why does the save/restore in ExecEvalCase not >> take care of this? > The mistake happens during planning, when the SQL function is inlined > and pre-evaluated. Hm. I'm inclined to think this may be more of a bug in the inlining process than anything else. I have to run off for a doctor's appointment, but will look at this closer later today. regards, tom lane