Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y9GE6-0001wa-W4 for pgsql-bugs@arkaria.postgresql.org; Thu, 08 Jan 2015 16:46:27 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y9GE5-0004Y7-Qc for pgsql-bugs@arkaria.postgresql.org; Thu, 08 Jan 2015 16:46:25 +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 1Y9GE3-0004Xy-IR for pgsql-bugs@postgresql.org; Thu, 08 Jan 2015 16:46:23 +0000 Received: from nm30-vm3.bullet.mail.ne1.yahoo.com ([98.138.91.160]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1Y9GDx-0008OL-Vc for pgsql-bugs@postgresql.org; Thu, 08 Jan 2015 16:46:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ymail.com; s=s2048; t=1420735574; bh=gpV4wnVthRkzBjUYEnaOqgv+bHt/e8evFQ49MhdEQmo=; h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=jX7CDx14Ncd0qNwym2pKg01gDZM/PQfVMvHEKku5SMlQ4uas+H9s7gUkWrLkJj2ZBOxmJUsh0jM/85RnjMu4HUxM5C9yOnbHA9sTe/GJtZKMvo3ZA69HMUhyPyFCNCsj4e6GqehGMGwp/ixBSP5col5B9QvRAfWkjMAJ7wEvPQFrkbqTVJJmniHvzEqAQn5vUna9roN0wpjdP6gbeAoeUyaef/SYlOGglivu7G3M4njOWERKxxx/B8BlK2AKjBroqT3YWTo67i8WTpyf33VLY8hZO8tEy5BBHAhZlPRz5RwB/9sr6AXAxHSC8ovVNOSL1t3K/tR2Rf0XUrUhXkQNGw== DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s2048; d=ymail.com; b=qs3ThHLxoH3Uq/p6hZrgkADLA9IsCtiDn4VgGTE4AP3WDE/kQkSvohARF3GguwiDnFLGnNbY+PP2E0aUv7svXoj2qQ1DXmaqll00VW7mRlMFBrzWeMIJJHxEC1ekh3FsVAT/OfdXmi2CfWfGIBT0zvSq4u9DU9r17uT2lv686be5M89aXD0gmXPBzMrZ+X+VZPXUB4+/JeqoMqOMQ0ZJ4//W81oMILlkewiesEJrHTSKuGzJ8gvf3K4T4j0wqgtIlULKZdBsUxeTN1tdhZeUwQAwbPf3C3wNo6baNcu4am1a5R6BCzhk2UK4HB6vkWR4W2VMmUy51BPqDSqCh4B86g==; Received: from [98.138.100.113] by nm30.bullet.mail.ne1.yahoo.com with NNFMP; 08 Jan 2015 16:46:14 -0000 Received: from [98.138.89.249] by tm104.bullet.mail.ne1.yahoo.com with NNFMP; 08 Jan 2015 16:46:14 -0000 Received: from [127.0.0.1] by omp1041.mail.ne1.yahoo.com with NNFMP; 08 Jan 2015 16:46:14 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 739595.29714.bm@omp1041.mail.ne1.yahoo.com X-YMail-OSG: kaSqNaIVM1koMs3ftTWB7hLNRwVqOySW._6EuH709LhaZO9WNGeuwvD3ksX4MVA qeKKdoKlTVi.0uwWML0S3Ow_qsfF5nVdzDp_jfwOPUg88lf2U1geC0NDBMc24jr_QlG0.yZDwe2i IiHaPxdqzumK9E74rCyhhvS.uEwOnk9V5tviVF3lF5F22DozH_7VdQTZht.foyONYjvn0zKBkf2O yS4crcoFWaTx90N0JhFAxZAq1T22gg4JO47b__Ucld2k3yoZEG.eVNPPcpEoN8lC0KuFCTq_n_d1 9pgTf_yITtkbv_eytRqzClmXPerwWu4_IjLcZztaafDzrLTqctJs7haAsXGjz_dBJYoEqIpO_CJa JKVD_MqNfe16PlmwRYLEYcXK70htiAIuLvkp7REXqolGhykWV8YyjO6wW05KFFTb9S9Kp_a9yYvk 1.s_N0K_4Nqu8l5784eCI5Q8zoBK73iuRXxq9cF11Xt_mEKqRpc.GGrdXNYRNpqqmIjBLAKhFBIs T2.2fIUIX61vmLyYaMDnh.rF.24WmOBpe60nMtIyZU3H9PxI4n22SoSae0NIA3Apcyoj5eL929oRc Received: by 98.138.105.206; Thu, 08 Jan 2015 16:46:14 +0000 Date: Thu, 8 Jan 2015 16:45:45 +0000 (UTC) From: Kevin Grittner Reply-To: Kevin Grittner To: "tneumann@users.sourceforge.net" , "pgsql-bugs@postgresql.org" Message-ID: <311243186.3874557.1420735545628.JavaMail.yahoo@jws100104.mail.ne1.yahoo.com> In-Reply-To: <20150108161155.11500.32736@wrigleys.postgresql.org> References: <20150108161155.11500.32736@wrigleys.postgresql.org> Subject: Re: BUG #12462: NULLIF changes the argument type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Length: 952 X-Pg-Spam-Score: -2.0 (--) 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 "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 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