Re: plpgsql CASE statement - last version

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
Cc: "Heikki Linnakangas" <heikki(at)enterprisedb(dot)com>, pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: plpgsql CASE statement - last version
Date: 2008-05-02 23:05:52
Message-ID: 26724.1209769552@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

"Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> writes:
> 2008/5/2 Heikki Linnakangas <heikki(at)enterprisedb(dot)com>:
>> How about taking a completely different strategy, and implement the
>> CASE-WHEN construct fully natively in plpgsql, instead of trying to convert
>> it to a single SQL CASE-WHEN expression? It's not a very good match anyway;

> It was first variant. It's simpler for parsing and slower for
> execution :(. It means more than once expression evaluation and for
> simple case value casting and comparation.

I agree with Heikki: this patch is seriously ugly, and "slower for
execution" isn't a good enough reason for saddling us with having
to maintain such a kluge in the parser.

I don't really see why you should need to have multiple expression
evaluations, anyhow. Can't you evaluate the test expression once
and inject its value into the comparisons using CaseTestExpr,
the same way the core CASE-expression code works?

regards, tom lane

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2008-05-02 23:23:34 Re: [COMMITTERS] pgsql: Sigh ...
Previous Message Andrew Dunstan 2008-05-02 23:05:05 Re: [COMMITTERS] pgsql: Sigh ...