Case statement ready? - Mailing list pgsql-hackers

From Thomas G. Lockhart
Subject Case statement ready?
Date
Msg-id 36678861.D47E703A@alumni.caltech.edu
Whole thread Raw
List pgsql-hackers
I seem to have a CASE statement implemented (examples at end). Is anyone
in the middle of preparing a big patch, or can I go ahead and commit my
changes? They touch roughly a dozen files.

Also, I added arbitrary code to keep the rewriter from complaining, and
have not made changes to calculate costs for the optimizer. Would the
resident experts (Jan and Bruce?) be willing to look at that once the
patches are in?
                     - Tom

Here is the table:

postgres=> select * from t2;
i|  f
-+---
1|2.2
3|2.2
4|  4
(3 rows)

And here is a CASE, including promoting ints to floats for the mixed
types in the WHERE clause:

postgres=> select case when i > f then f else i end from t2;
?column?
--------      1    2.2      4
(3 rows)

Shows filling with NULLs if no default clause is specified:

postgres=> select case when i > f then f end from t2;
?column?
--------
    2.2

(3 rows)

And this last one shows that CASE is allowed inside a qualification
clause, though I'm having a hard time picturing how that might be
useful:

postgres=> select * from t2 where case when i > f then f end is not
null;
i|  f
-+---
3|2.2
(1 row)


pgsql-hackers by date:

Previous
From: "Thomas G. Lockhart"
Date:
Subject: Re: [HACKERS] Date/time on glibc2 linux
Next
From: Vadim Mikheev
Date:
Subject: Re: [HACKERS] Case statement ready?