Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id A74CA1337BED for ; Thu, 14 Apr 2011 19:14:00 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 55377-03 for ; Thu, 14 Apr 2011 22:13:54 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from gw.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by mail.postgresql.org (Postfix) with ESMTP id 1574E133616B for ; Thu, 14 Apr 2011 19:13:52 -0300 (ADT) Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Thu, 14 Apr 2011 17:13:52 -0500 Message-Id: <4DA72B4A020000250003C85D@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Thu, 14 Apr 2011 17:13:46 -0500 From: "Kevin Grittner" To: "Tom Lane" Cc: "Jeff Wu" ,"Mike Fowler" , Subject: Re: BUG #5974: UNION construct type cast gives poor error message References: <201104122018.p3CKIlWR042915@wwwmaster.postgresql.org> <9799.1302719551@sss.pgh.pa.us> <4DA711B6.4060306@mlfowler.com> <4DA6D50E020000250003C83A@gw.wicourts.gov> <4DA72529.7080505@mlfowler.com> <4DA720B8020000250003C856@gw.wicourts.gov><4DA720B8020000250003C856@gw.wicourts.gov> <21368.1302817680@sss.pgh.pa.us> In-Reply-To: <21368.1302817680@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201104/99 X-Sequence-Number: 30018 Tom Lane wrote: > "Kevin Grittner" writes: >> That means that all three of the databases you tested have >> extensions to the standard similar to what is being contemplated >> for PostgreSQL. > > Uh, no, it proves they all extend the standard to allow NULL to be > written without an immediate cast. Mike's test really fails to > prove anything about the point at hand, which is what data type is > being imputed to the inner UNION. The query run was: SELECT 1,null,null UNION SELECT 2,3,null UNION SELECT 3,null,4 It's a bit of a stretch to think that the columns returned from the final union weren't integer, or that integer is the default type of the union of two nulls. It's anyone's guess at this point whether the third column was unknown during the leftmost union and the type set in the next union, or the set of columns involved in the union were all evaluated as a group. If they don't have other literals of unknown type it may be hard to discern the implementation details, but either I've missed something or we're considering similar user visible behavior. > I don't know those other DBMSes well enough to suggest a test that > would be definitive on the point, though. We'd need something > where the choice of datatype is material to the final visible > result, and at least in PG that requires some knowledge of > not-very-standard behaviors. If the implementation details for the other databases are that hard to discern, how much do we care *how* they do it? It seems to me that the important point here is that they don't throw an error on that query and we do. What am I missing? -Kevin