pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Grittner <kgrittn@ymail.com>
To: tneumann@users.sourceforge.net <tneumann@users.sourceforge.net>
To: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #12462: NULLIF changes the argument type
Date: Thu, 8 Jan 2015 16:45:45 +0000 (UTC)
Message-ID: <311243186.3874557.1420735545628.JavaMail.yahoo@jws100104.mail.ne1.yahoo.com> (raw)
In-Reply-To: <20150108161155.11500.32736@wrigleys.postgresql.org>
References: <20150108161155.11500.32736@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

"tneumann@users.sourceforge.net" <tneumann@users.sourceforge.net> wrote:

> The SQL standard in Section 6.11, Syntax rule 1 c) says that
>
> ""
> NULLIF (V1, V2) is equivalent to the following <case specification>:
> CASE WHEN
> V1=V2 THEN
> NULL ELSE V1
> END
> ""
>
> which is currently not the case in Postgres. Postgres promotes V1 to the
> type of V2, which can lead to behavior changes.
>
> Example query as illustration: It should produce 0,0,0 (and does on SQL
> Server and DB2), but PostgreSQL promotes the type and produces 0,0.5,0
>
> select 1/2,nullif(1,2.3)/2,case when 1=2.3 then NULL else 1 end/2

I agree that this fails to conform to the standard and should be
considered a bug.  FWIW, Oracle, SQL Lite, and MySQL also return
matching values for the three columns in your sample query;
although Oracle and MySQL return 0.5,0.5,0.5 instead of 0,0,0.

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


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (4+ messages)  latest in thread

Message-ID: <311243186.3874557.1420735545628.JavaMail.yahoo@jws100104.mail.ne1.yahoo.com>
Permalink:  ../311243186.3874557.1420735545628.JavaMail.yahoo@jws100104.mail.ne1.yahoo.com/
Also on:    postgresql.org/message-id/311243186.3874557.1420735545628.JavaMail.yahoo@jws100104.mail.ne1.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: kgrittn@ymail.com, tneumann@users.sourceforge.net
  Subject: Re: BUG #12462: NULLIF changes the argument type
  In-Reply-To: <311243186.3874557.1420735545628.JavaMail.yahoo@jws100104.mail.ne1.yahoo.com>
  References: <20150108161155.11500.32736@wrigleys.postgresql.org> <311243186.3874557.1420735545628.JavaMail.yahoo@jws100104.mail.ne1.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox