From: Mike Fowler <mike@mlfowler.com>
To: 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 16:24:38 +0100
Message-ID: <4DA711B6.4060306@mlfowler.com> (raw)
In-Reply-To: <9799.1302719551@sss.pgh.pa.us>
References: <201104122018.p3CKIlWR042915@wwwmaster.postgresql.org>
<9799.1302719551@sss.pgh.pa.us>
On 13/04/11 19:32, Tom Lane wrote:
> "Jeff Wu"<jwu@atlassian.com> writes:
>> The UNION construct (as noted on this page:
>> http://www.postgresql.org/docs/9.0/static/typeconv-union-case.html) will
>> cast unknown types to TEXT, however, if you try to do three or more UNIONs
>> the order in which the UNIONs are executed will cause some columns to be
>> cast to TEXT prematurely. The result is a type mismatch error.
> <snip>
>
> Or maybe we could find out that some other products
> do it like that despite what the spec says?
>
> regards, tom lane
I happen to have a MS SQLServer 2008 instance at work as well as a MySQL
5.1 and an Oracle 10g. With the query:
SELECT 1,null,null
UNION
SELECT 2,3,null
UNION
SELECT 3,null,4
In MS SQLServer I get (NB: no column headings):
----------------------
----------------------
1 | <null> | <null>
2 | 3 | <null>
3 | <null> | 4
In MySQL I get:
--------------------
1 | NULL | NULL
--------------------
1 | <null> | <null>
2 | 3 | <null>
3 | <null> | 4
In Oracle I get a delicious error message:
Error: ORA-00923: FROM keyword not found where expected
SQLState: 42000
ErrorCode: 923
Position: 19
Regards,
--
Mike Fowler
Registered Linux user: 379787
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, tgl@sss.pgh.pa.us, jwu@atlassian.com
Subject: Re: BUG #5974: UNION construct type cast gives poor error message
In-Reply-To: <4DA711B6.4060306@mlfowler.com>
References: <201104122018.p3CKIlWR042915@wwwmaster.postgresql.org> <9799.1302719551@sss.pgh.pa.us> <4DA711B6.4060306@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