From: Jeff Wu <jwu@atlassian.com>
To: pgsql-bugs@postgresql.org
Subject: BUG #5974: UNION construct type cast gives poor error message
Date: Tue, 12 Apr 2011 20:18:47 GMT
Message-ID: <201104122018.p3CKIlWR042915@wwwmaster.postgresql.org> (raw)
The following bug has been logged online:
Bug reference: 5974
Logged by: Jeff Wu
Email address: jwu@atlassian.com
PostgreSQL version: 9.0
Operating system: Mac OS X
Description: UNION construct type cast gives poor error message
Details:
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.
For example:
SELECT 1,null,null
UNION
SELECT 2,3,null
UNION
SELECT 3,null,4
will fail while
SELECT 1,null,null::INTEGER
UNION
SELECT 2,3,null
UNION
SELECT 3,null,4
will succeed.
This is not a critical error, but I would say that the error message is
misleading because it is not obvious that Postgres casts unknown columns to
TEXT automatically.
The current error message is:
ERROR: UNION types text and integer cannot be matched
I would suggest something like:
ERROR: UNION types text and integer cannot be matched. HINT: Postgres casts
unknown types to TEXT by default.
Thanks,
Jeff
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: jwu@atlassian.com
Subject: Re: BUG #5974: UNION construct type cast gives poor error message
In-Reply-To: <201104122018.p3CKIlWR042915@wwwmaster.postgresql.org>
References: <201104122018.p3CKIlWR042915@wwwmaster.postgresql.org>
* 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