Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 3309F1336FA7 for ; Thu, 14 Apr 2011 13:48:21 -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 58011-02-8 for ; Thu, 14 Apr 2011 16:48:14 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from milan.hostgo.com (milan.hostgo.com [72.52.99.130]) by mail.postgresql.org (Postfix) with ESMTP id C4F651337C43 for ; Thu, 14 Apr 2011 13:47:47 -0300 (ADT) Received: from [217.10.134.34] (helo=[192.168.1.71]) by milan.hostgo.com with esmtpa (Exim 4.69) (envelope-from ) id 1QAPhk-0006FG-Nd; Thu, 14 Apr 2011 12:47:43 -0400 Message-ID: <4DA72529.7080505@mlfowler.com> Date: Thu, 14 Apr 2011 17:47:37 +0100 From: Mike Fowler User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: Kevin Grittner CC: Tom Lane , Jeff Wu , pgsql-bugs@postgresql.org 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> In-Reply-To: <4DA6D50E020000250003C83A@gw.wicourts.gov> Content-Type: multipart/mixed; boundary="------------010506070209080908070901" X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - milan.hostgo.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - mlfowler.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201104/95 X-Sequence-Number: 30014 This is a multi-part message in MIME format. --------------010506070209080908070901 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 14/04/11 17:05, Kevin Grittner wrote: > SELECT 1,null,null FROM DUAL > UNION > SELECT 2,3,null FROM DUAL > UNION > SELECT 3,null,4 FROM DUAL Sadly I can't profess to knowing Oracle, however if I run the query as suggested I get: -------------------- 1 | NULL | NULL -------------------- 1 | | 2 | 3 | 3 | | 4 So to summarise, Oracle and PostgreSQL need minor tweaks to run cleanly and SQLServer and MySQL do not. Given that the change for PostgreSQL is so minor, I vote for changing the error message as Jeff suggests in the interim to help users while the standards argument continues. Patch attached. Regards, -- Mike Fowler Registered Linux user: 379787 --------------010506070209080908070901 Content-Type: text/x-diff; name="bug-5974.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="bug-5974.patch" *** a/src/backend/parser/parse_coerce.c --- b/src/backend/parser/parse_coerce.c *************** *** 1161,1167 **** select_common_type(ParseState *pstate, List *exprs, const char *context, (errcode(ERRCODE_DATATYPE_MISMATCH), /*------ translator: first %s is name of a SQL construct, eg CASE */ ! errmsg("%s types %s and %s cannot be matched", context, format_type_be(ptype), format_type_be(ntype)), --- 1161,1167 ---- (errcode(ERRCODE_DATATYPE_MISMATCH), /*------ translator: first %s is name of a SQL construct, eg CASE */ ! errmsg("%s types %s and %s cannot be matched. HINT: Postgres casts unknown types to TEXT by default.", context, format_type_be(ptype), format_type_be(ntype)), --------------010506070209080908070901--