Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y9Fgy-0000KR-E7 for pgsql-bugs@arkaria.postgresql.org; Thu, 08 Jan 2015 16:12:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y9Fgx-0001ke-UM for pgsql-bugs@arkaria.postgresql.org; Thu, 08 Jan 2015 16:12:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y9Fgw-0001js-KH for pgsql-bugs@postgresql.org; Thu, 08 Jan 2015 16:12:10 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y9Fgo-0007kt-PN for pgsql-bugs@postgresql.org; Thu, 08 Jan 2015 16:12:09 +0000 MIME-Version: 1.0 Subject: BUG #12462: NULLIF changes the argument type To: pgsql-bugs@postgresql.org From: tneumann@users.sourceforge.net Date: Thu, 08 Jan 2015 16:11:55 +0000 Message-ID: <20150108161155.11500.32736@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 12462 Logged by: Thomas Neumann Email address: tneumann@users.sourceforge.net PostgreSQL version: 9.4.0 Operating system: Linux 3.16.0 Description: The SQL standard in Section 6.11, Syntax rule 1 c) says that "" NULLIF (V1, V2) is equivalent to the following : 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 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs