Re: How to quote the COALESCE function?

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: How to quote the COALESCE function?
Дата
Msg-id CACjxUsMJCHcYjEcg+sQ+HoidEWFgi4LTumMUsDiaSxOZ=AVM-Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: How to quote the COALESCE function?  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-general
On Tue, Mar 29, 2016 at 12:38 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:

> The coalesce is one few functions implemented by special rule in
> PostgreSQL parser.

In the SQL standard the COALESCE feature is not listed as a
function; it is listed as one of the short forms of CASE
expression.  While it has function-like syntax, thinking of it as a
function is semantically incorrect.

  COALESCE(a, b)

is supposed to be semantically equivalent to:

  CASE WHEN a is not null THEN a ELSE b END

Among other things, that means that this statement should not
generate a divide by zero error:

  SELECT COALESCE(1, 1/0);

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


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

Предыдущее
От: Rodney Lott
Дата:
Сообщение: Re: postgresql 9.3.10, FIPS mode and DRBG issues.
Следующее
От: Soni M
Дата:
Сообщение: Re: CORRUPTION on TOAST table