[PATCH] Generate column names for subquery expressions

Поиск
Список
Период
Сортировка
От Marti Raudsepp
Тема [PATCH] Generate column names for subquery expressions
Дата
Msg-id CABRT9RCGKfCwOLCQEgo7O+jnOTro-oZB=j7E_qiA0s=x4AgaYA@mail.gmail.com
обсуждение исходный текст
Ответы Re: [PATCH] Generate column names for subquery expressions  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: [PATCH] Generate column names for subquery expressions  (Marti Raudsepp <marti@juffo.org>)
Список pgsql-hackers
Hi list,

In current PostgreSQL versions, subquery expressions in the SELECT list always generate columns with name "?column?"

postgres=# select (select 1 as foo);
?column?
--------
       1

This patch improves on that:
  select (SELECT 1 AS foo) => foo
  select exists(SELECT 1)  => exists
  select array(SELECT 1)   => array

The "array" one is now consistent with an array literal: select array[1];

Other subquery types (=ALL(), =ANY() and row comparison) don't change because they act more like operators.

I guess it's fairly unlikely that users rely on column names being "?column?", but it does change the name of some expressions, for example:
  select (select 1 foo)::int;
  select case when true then 1 else (select 1 as foo) end;

Previously these returned column names "int4" and "case", now they would return "foo". Personally I prefer it this way, but if it is considered a compatibility problem, lowering the strength of subquery names in FigureColnameInternal would resort to the old behavior.

How this affects different queries can be seen from the regression diffs.

Does this sound like a good idea?
Should I submit this to the CommitFest?


Regards,
Marti Raudsepp

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Cédric Villemain
Дата:
Сообщение: Re: postgresql.conf archive_command example
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Bogus nestloop join estimate, ignores WHERE clause