Skip site navigation (1) Skip section navigation (2)

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-15 22:46:34
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-patches
"Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> writes:
> I am sending little bit smarter version - without redundant parsing.

Applied with corrections --- you had some memory management problems
in particular.

One thing that I think might annoy people is that you've handled

	    WHEN a, b, c THEN ...

by producing the equivalent of "IF x IN (a, b, c)".  This means that
all three of the a, b, c expressions will be evaluated even if "a"
matches.  The SQL spec doesn't appear to promise short-circuit
evaluation in such a case, but I suspect somebody out there might
have a problem someday.  It didn't seem tremendously easy to fix though.
I suppose anyone who does have a problem can rewrite as

	    WHEN a THEN ...
	    WHEN b THEN ...
	    WHEN c THEN ...

at the cost of duplicating their THEN code.

			regards, tom lane

In response to

pgsql-patches by date

Next:From: Jan UrbaƄskiDate: 2008-05-15 22:48:16
Subject: Re: extend VacAttrStats to allow stavalues of different types
Previous:From: Gregory StarkDate: 2008-05-15 22:41:37
Subject: Re: Patch to change psql default banner v6

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group