Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 8BD591337B80 for ; Wed, 13 Apr 2011 17:39:30 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 64411-01 for ; Wed, 13 Apr 2011 20:39:23 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 51B9A1337B68 for ; Wed, 13 Apr 2011 17:39:21 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p3DKdGs7011921; Wed, 13 Apr 2011 16:39:16 -0400 (EDT) To: "Kevin Grittner" cc: "Jeff Wu" , pgsql-bugs@postgresql.org Subject: Re: BUG #5974: UNION construct type cast gives poor error message In-reply-to: <4DA5B8A4020000250003C7A9@gw.wicourts.gov> References: <201104122018.p3CKIlWR042915@wwwmaster.postgresql.org><201104122018.p3CKIlWR042915@wwwmaster.postgresql.org> <9799.1302719551@sss.pgh.pa.us> <4DA5B8A4020000250003C7A9@gw.wicourts.gov> Comments: In-reply-to "Kevin Grittner" message dated "Wed, 13 Apr 2011 14:52:20 -0500" Date: Wed, 13 Apr 2011 16:39:16 -0400 Message-ID: <11920.1302727156@sss.pgh.pa.us> From: Tom Lane 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/82 X-Sequence-Number: 30001 "Kevin Grittner" writes: > From my perspective the "right" answer is to be able to resolve two > unknown types to unknown rather than text in a few places where we > are currently compelled to assign a concrete type. Well, it's not so easy as that. Consider select '1' union select '1 '; How many rows does that produce? You cannot answer without imputing a data type to the columns. "text" will give a different answer than "integer" or "bpchar". It's possible that we could make UNION ALL act differently from all other set-operations, and refrain from resolving a type for the single case of UNION ALL; but I can't say that I care for that idea, or see any support for it in the standard. AFAICS the standard says that output data types are to be resolved in the same way for all set operations. regards, tom lane