From: Tom Lane <tgl@sss.pgh.pa.us>
To: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: Nested CASE-WHEN scoping
Date: Thu, 16 Jun 2011 16:56:30 -0400
Message-ID: <25826.1308257790@sss.pgh.pa.us> (raw)
In-Reply-To: <4DE93A08.90309@enterprisedb.com>
References: <4DDCEEB8.50602@enterprisedb.com>
<5487.1306334876@sss.pgh.pa.us>
<4DDD35B6.2050203@enterprisedb.com>
<27772.1306359110@sss.pgh.pa.us>
<4DE38CCD.80702@enterprisedb.com>
<23055.1306765290@sss.pgh.pa.us>
<4DE512FC.9070707@enterprisedb.com>
<4DE93A08.90309@enterprisedb.com>
Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:
> The complicated part is to ensure that levelsup is always set correctly.
> At parse time, levelsup is always set to 0, as the syntax doesn't allow
> referencing upper levels directly. When an SQL function is inlined, any
> ExpressionParams in the expressions that are substituted for Params need
> to have their levelsup adjusted, so that it still refers to the right
> value if there's CASE expressions in the inlined function. Also, when an
> ExpressionParam is replaced with a Const, the levelsup fields of any
> other ExpressionParams within the CaseExpr referring to higher levels
> need to have their levelsup decremented to account for the fact that the
> CaseExpr doesn't push the expression parameter anymore.
I believe this is an unworkably complex, and almost certainly buggy
Rube Goldberg device. Even if it manages to work today, it's going to
be impossible to maintain those levelsup values correctly during
any sort of expression rearrangement or optimization.
Please take another look at just assigning a PARAM_EXEC parameter per
Case expression.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, heikki.linnakangas@enterprisedb.com
Subject: Re: Nested CASE-WHEN scoping
In-Reply-To: <25826.1308257790@sss.pgh.pa.us>
References: <4DDCEEB8.50602@enterprisedb.com> <5487.1306334876@sss.pgh.pa.us> <4DDD35B6.2050203@enterprisedb.com> <27772.1306359110@sss.pgh.pa.us> <4DE38CCD.80702@enterprisedb.com> <23055.1306765290@sss.pgh.pa.us> <4DE512FC.9070707@enterprisedb.com> <4DE93A08.90309@enterprisedb.com> <25826.1308257790@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox