Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id E3A22B5DC3E for ; Wed, 25 May 2011 14:27:16 -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 57668-09 for ; Wed, 25 May 2011 17:27:09 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og105.obsmtp.com (exprod7og105.obsmtp.com [64.18.2.163]) by mail.postgresql.org (Postfix) with ESMTP id 1DD0EB5DBF9 for ; Wed, 25 May 2011 14:27:07 -0300 (ADT) Received: from mail-ew0-f54.google.com ([209.85.215.54]) (using TLSv1) by exprod7ob105.postini.com ([64.18.6.12]) with SMTP ID DSNKTd076qAe0G3B9im3z+e7uVZo+ZaDdt57@postini.com; Wed, 25 May 2011 10:27:09 PDT Received: by mail-ew0-f54.google.com with SMTP id 1so3342012ewy.41 for ; Wed, 25 May 2011 10:27:06 -0700 (PDT) Received: by 10.14.122.81 with SMTP id s57mr1838024eeh.195.1306344426529; Wed, 25 May 2011 10:27:06 -0700 (PDT) Received: from [192.168.1.183] (dsl-hkibrasgw2-ff7ac300-240.dhcp.inet.fi [88.195.122.240]) by mx.google.com with ESMTPS id y14sm1540776eeh.22.2011.05.25.10.27.04 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 May 2011 10:27:05 -0700 (PDT) Message-ID: <4DDD3BE6.7090704@enterprisedb.com> Date: Wed, 25 May 2011 20:27:02 +0300 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.1.16) Gecko/20110505 Icedove/3.0.11 MIME-Version: 1.0 To: Tom Lane CC: PostgreSQL-development Subject: Re: Nested CASE-WHEN scoping References: <4DDCEEB8.50602@enterprisedb.com> <5487.1306334876@sss.pgh.pa.us> <4DDD35B6.2050203@enterprisedb.com> <23538.1306343493@sss.pgh.pa.us> In-Reply-To: <23538.1306343493@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=-5 required=5 tests=none X-Spam-Level: X-Archive-Number: 201105/1292 X-Sequence-Number: 188326 On 25.05.2011 20:11, Tom Lane wrote: > 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. Well, if you want to get away without the capability to reference multiple CaseTestExprs at a time, you'll have to detect the danger and abort the inlining process. That's a bit pessimal, although this is a pretty artificial case in the first place so maybe we don't care much. (I'm still going to need more placeholder slots to handle IN and BETWEEN. Of course, I can just copy-paste CaseTestExpr into something like InTestExpr and BetweenTestExpr, but it seems like it would be good to unite all that infrastructure) -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com