Case statement ready?

From: "Thomas G(dot) Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu>
To: Postgres Hackers List <hackers(at)postgresql(dot)org>, Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>, Jan Wieck <jwieck(at)debis(dot)com>
Subject: Case statement ready?
Date: 1998-12-04 06:59:45
Message-ID: 36678861.D47E703A@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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)

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Vadim Mikheev 1998-12-04 07:10:52 Re: [HACKERS] Case statement ready?
Previous Message Thomas G. Lockhart 1998-12-04 06:45:41 Re: [HACKERS] Date/time on glibc2 linux