From: Mike Fowler <mike@mlfowler.com>
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Jeff Wu <jwu@atlassian.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #5974: UNION construct type cast gives poor error message
Date: Thu, 14 Apr 2011 17:47:37 +0100
Message-ID: <4DA72529.7080505@mlfowler.com> (raw)
In-Reply-To: <4DA6D50E020000250003C83A@gw.wicourts.gov>
References: <201104122018.p3CKIlWR042915@wwwmaster.postgresql.org>
<9799.1302719551@sss.pgh.pa.us>
<4DA711B6.4060306@mlfowler.com>
<4DA6D50E020000250003C83A@gw.wicourts.gov>
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 | <null> | <null>
2 | 3 | <null>
3 | <null> | 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
Attachments:bug-5974.patch (text/x-diff, 802B) download
*** 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)),
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: mike@mlfowler.com, Kevin.Grittner@wicourts.gov, tgl@sss.pgh.pa.us, jwu@atlassian.com
Subject: Re: BUG #5974: UNION construct type cast gives poor error message
In-Reply-To: <4DA72529.7080505@mlfowler.com>
References: <201104122018.p3CKIlWR042915@wwwmaster.postgresql.org> <9799.1302719551@sss.pgh.pa.us> <4DA711B6.4060306@mlfowler.com> <4DA6D50E020000250003C83A@gw.wicourts.gov> <4DA72529.7080505@mlfowler.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox