confusing `case when` column name

Поиск
Список
Период
Сортировка
От adjkldd@126.com
Тема confusing `case when` column name
Дата
Msg-id 336abc39.8084.18e32ad7ffc.Coremail.winterloo@126.com
обсуждение исходный текст
Ответы Re: confusing `case when` column name  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Amit Kapila
Дата:
Сообщение: Re: A failure in t/038_save_logical_slots_shutdown.pl
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: Make attstattarget nullable