Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Yoz4j-0007kb-Po for pgsql-bugs@arkaria.postgresql.org; Sun, 03 May 2015 18:57:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Yoz4j-0007FP-5u for pgsql-bugs@arkaria.postgresql.org; Sun, 03 May 2015 18:57:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Yoz4h-0007Ed-7y for pgsql-bugs@postgresql.org; Sun, 03 May 2015 18:57:11 +0000 Received: from nm8-vm0.bullet.mail.ne1.yahoo.com ([98.138.91.23]) by magus.postgresql.org with esmtps (TLS1.0:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1Yoz4d-0002Ff-8p for pgsql-bugs@postgresql.org; Sun, 03 May 2015 18:57:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ymail.com; s=s2048; t=1430679423; bh=xX5805qnJ0fV6WKe9bQpLrp7FmfBQrzdPKui1vg32lw=; h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:From:Subject; b=ajFbIBy7IitPW/WqU+kuFoG+O2JRj6t74NxX6Np3L0Tk5bMnZp8D/2JdDrJbhos/fUHNusZOv21rCbIh5gtKjIEcwFDiMox+xonY38brIJzo+kUWVQhukeeo2tzdy0mwSpdwLknOYymR+R4COyttLD34Ah3RyNk8neQIwqQpTvQ/Oqvw/Qzd87HqJAEY0S3Genvz3QtYoBmhbj40TLQokNgpp7I20easBVGc7q8oZQLAeVXeLZFu6F18hFll5suacvs9GU1t3qMNAr4/qTZ2EeJexR/DZdVnrCar6NzDvE/O50+x84p/Qy9/GUnBlPVy7Q9rZ4mNpOznTvnslZ8c9g== Received: from [98.138.101.130] by nm8.bullet.mail.ne1.yahoo.com with NNFMP; 03 May 2015 18:57:03 -0000 Received: from [98.138.89.165] by tm18.bullet.mail.ne1.yahoo.com with NNFMP; 03 May 2015 18:56:39 -0000 Received: from [127.0.0.1] by omp1021.mail.ne1.yahoo.com with NNFMP; 03 May 2015 18:56:39 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 728448.99958.bm@omp1021.mail.ne1.yahoo.com X-YMail-OSG: V6o3W74VM1nbgO0if_Y9KCbD7AqkjG__1jTPDRmvvkdH1X2gq9WF4RaCvpCUyTH vaSZmo4iLyGB.4L64sukLU8RfBzmLEegsxXIeN25YvlZEnPaPEL1QmtXLHiu2PJfcehxqiYAUWly OxwdpNojAcPNsqZevL.AJtdUgFEn7UvOrHfixkpW5ULOV.3fZDRIkQYF35P6Lgf6u0pUpRSnk1NT 5eaHmYwIhi017c1bmQxReIHYk_PKzW154CmRLCG3EUEUfg5x1EOvhpyT9wleH1UG6OLJPp.osm2G 07SSaDdPNFyzJvUW_1zewHulu3HMaNFFh8Cj6XEq9VpfKC5ugE5CzMVgflA69VtdshLO70wwEWcy imvFBty0PP3fN1T3SurOmivZ8Jy3JEQvX9z0b0KgqHo0ESHRQyCUZXjE_A6k8DpZEwVthQrzmRyv AXzJyNRTTD3yU4AVJXUkemfg8O.3pD_Dy_6UqNXD7LrAYWVzK6oH9G2nBGOhKPUcUDSQGM7rzX65 byFtAD9OSYnpiizah Received: by 98.138.105.195; Sun, 03 May 2015 18:56:39 +0000 Date: Sun, 3 May 2015 18:56:14 +0000 (UTC) From: Kevin Grittner Reply-To: Kevin Grittner To: Tom Lane Cc: Robert Haas , Jeff Davis , Postgres-Bugs Message-ID: <1850649255.594603.1430679374313.JavaMail.yahoo@mail.yahoo.com> In-Reply-To: <16778.1430673231@sss.pgh.pa.us> References: <16778.1430673231@sss.pgh.pa.us> Subject: Re: Failure to coerce unknown type to specific type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Length: 1775 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 Tom Lane wrote: > Kevin Grittner writes: >> I recall two constructs that we had in production that caused some >> pain moving to PostgreSQL. > >> Here's one: > >> test=# insert into x values (coalesce(null, null)); >> ERROR: column "d" is of type date but expression is of type text > > I don't have a lot of sympathy for that one. coalesce(null, null) > isn't legal at all per SQL spec I don't get that from my reading of the SQL spec. A COALESCE clause is (and always has been) considered a short form of the CASE clause (not to be mistaken for a function, for example). The spec section 6.11 1) c) very explicitly requires COALESCE(NULL, NULL) be the exact equivalent of CASE WHEN NULL IS NOT NULL THEN NULL ELSE NULL END Yet in PostgreSQL the long form of the CASE clause returns the same thing as a bare NULL, while the short form (COALESCE) gives an error. Please indicate what in the spec makes you think that COALESCE(NULL, NULL) should ever be treated differently from a bare NULL, because I've looked at the spec and I'm not seeing anything to support what you said. > Otherwise the result type of coalesce() isn't well-defined, and there is > nothing at all in the spec that would suggest looking to surrounding > context to decide that. The definition of COALESCE says that when there are different types the result type should be determined according to section 9.3 (Result of data type combinations). Because the organization of our code doesn't lend itself well to conforming to the standard in that regard, I realize that we are dealing in practical compromises; but let's not pretend the spec is not clear about this. -- 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