confusing `case when` column name - Mailing list pgsql-hackers

From adjkldd@126.com
Subject confusing `case when` column name
Date
Msg-id 336abc39.8084.18e32ad7ffc.Coremail.winterloo@126.com
Whole thread Raw
Responses Re: confusing `case when` column name
List 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

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: A failure in t/038_save_logical_slots_shutdown.pl
Next
From: Peter Eisentraut
Date:
Subject: Re: Make attstattarget nullable