confusing `case when` column name

From: "adjkldd(at)126(dot)com" <winterloo(at)126(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: confusing `case when` column name
Date: 2024-03-12 12:40:15
Message-ID: 336abc39.8084.18e32ad7ffc.Coremail.winterloo@126.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

Below is a `case when` demo,

```sql
create table foo(a int, b int);
insert into foo values (1, 2);
select case 1 when 1 then a else b end from foo;
```

Currently, psql output is,

```text
b
---
1
(1 row)
```

At the first glance at the output column title, I assume the result of the sql is wrong. It should be `a`.
After some investigation, I discovered that the result's value is accurate. However, PostgreSQL utilizes b as the title for the output column.
Nee we change the title of the case-when output column? If you hackers think it's worth the effort, I'm willing to invest time in working on it.
Best Regards,
Winter Loo

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2024-03-12 12:47:43 Re: Make attstattarget nullable
Previous Message Amit Kapila 2024-03-12 12:35:15 Re: A failure in t/038_save_logical_slots_shutdown.pl