From: Jim Nasby <Jim.Nasby@BlueTreble.com>
To: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
To: david.g.johnston@gmail.com
Cc: pgsql@j-davis.com
Cc: tgl@sss.pgh.pa.us
Cc: pgsql-hackers@postgresql.org
Subject: Re: [BUGS] Failure to coerce unknown type to specific type
Date: Thu, 23 Apr 2015 14:49:29 -0500
Message-ID: <55394CC9.5050703@BlueTreble.com> (raw)
In-Reply-To: <20150423.190749.87287279.horiguchi.kyotaro@lab.ntt.co.jp>
References: <20150423.173144.97709612.horiguchi.kyotaro@lab.ntt.co.jp>
<20150423.173535.202061455.horiguchi.kyotaro@lab.ntt.co.jp>
<CAKFQuwYZ2p2o1xgVgJF-6cQoWW1QmYr1oRUTUbU1AJ1XwdxSjQ@mail.gmail.com>
<20150423.190749.87287279.horiguchi.kyotaro@lab.ntt.co.jp>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
On 4/23/15 5:07 AM, Kyotaro HORIGUCHI wrote:
> This is because parsing of UNION immediately converts constants
> of unknown type in the UNION's both arms to text so the top level
> select won't be bothered by this problem. But the problematic
> query doesn't have appropriate timing to do that until the
> function I patched.
FWIW, I think that's more accidental than anything.
I'm no expert in our casting and type handling code but I spent a lot of
time stuck in it while working on the variant type, and it seems very
scattered. There's stuff in the actual casting code, there's some stuff
in other parts of parse/plan, there's stuff in individual types (array
and record at least).
Some stuff is handled by casting; some stuff is handled by mangling the
parse tree.
Something else I noticed is we're not consistent with handling typmod
either. I don't remember the exact example I found, but there's cases
involving casting of constants where we ignore it (I don't think it was
as simple as SELECT 1::int::variant(...), but it was something like that).
I don't know how much of this is just historical and how much is
intentional, but it'd be nice if we could consolidate it more.
--
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
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: Jim.Nasby@BlueTreble.com, horiguchi.kyotaro@lab.ntt.co.jp, david.g.johnston@gmail.com, pgsql@j-davis.com, tgl@sss.pgh.pa.us, pgsql-hackers@postgresql.org
Subject: Re: [BUGS] Failure to coerce unknown type to specific type
In-Reply-To: <55394CC9.5050703@BlueTreble.com>
References: <20150423.173144.97709612.horiguchi.kyotaro@lab.ntt.co.jp> <20150423.173535.202061455.horiguchi.kyotaro@lab.ntt.co.jp> <CAKFQuwYZ2p2o1xgVgJF-6cQoWW1QmYr1oRUTUbU1AJ1XwdxSjQ@mail.gmail.com> <20150423.190749.87287279.horiguchi.kyotaro@lab.ntt.co.jp> <55394CC9.5050703@BlueTreble.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