From: | Kevin Grittner <kgrittn(at)gmail(dot)com> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | Roman Scherer <roman(at)burningswell(dot)com>, Jerry Sievers <gsievers19(at)comcast(dot)net>, "pgsql-general(at)postgresql(dot)org >> PG-General Mailing List" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: How to quote the COALESCE function? |
Date: | 2016-04-04 21:49:06 |
Message-ID: | CACjxUsMJCHcYjEcg+sQ+HoidEWFgi4LTumMUsDiaSxOZ=AVM-Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, Mar 29, 2016 at 12:38 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Soni M | 2016-04-05 02:15:55 | Re: CORRUPTION on TOAST table |
Previous Message | Rodney Lott | 2016-04-04 20:22:41 | Re: postgresql 9.3.10, FIPS mode and DRBG issues. |