From: Kevin Grittner <kgrittn@ymail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Jeff Davis <pgsql@j-davis.com>
Cc: Postgres-Bugs <pgsql-bugs@postgresql.org>
Subject: Re: Failure to coerce unknown type to specific type
Date: Sun, 3 May 2015 20:07:13 +0000 (UTC)
Message-ID: <1648216624.644283.1430683633940.JavaMail.yahoo@mail.yahoo.com> (raw)
In-Reply-To: <23845.1430681631@sss.pgh.pa.us>
References: <23845.1430681631@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Tom Lane <tgl@sss.pgh.pa.us> wrote:
> This is irrelevant, because such a construct fails the syntax rules
> and thus we never get to the question of what type should be inferred,
> at least not without going outside the spec. See my other reply.
Yeah, our posts have been crossing a bit. The point about <value
expression> not allowing a NULL literal is valid. I yield on that
regarding COALESCE within the spec. It is an extension to the spec
to allow a NULL literal within a COALESCE clause at all. We would
surely break a lot of working code to forbid it, though. If we
*are* going to allow it, it would be pretty confusing to have it
behave differently that what I previously outlined (regarding the
equivalent long form CASE clause).
The <result> from a long form of the CASE clause explicitly does
explicitly allow an untyped NULL literal, and forcing it to text is
wrong per section 9.3.
To save an extra post -- I did modify the statements in SQL Fiddle
to get to the point where the subquery returned a column without a
type and a column with an int type in the dialect supported. I'm
not sure how that's relevant to the issue about how they resolve
that in the outer query, but I can post the form of the query used
for each product if you think it is germane.
To restate it, this hardly seems like the most important issue to
address; I just don't think the standard gives us much cover here.
What we do for the CASE clause is clearly wrong per spec, and if we
allow a bare NULL in a COALESCE clause it would be crazy not to
have the behavior match CASE. But it is clearly good form to
always cast a NULL literal to some type, and that is a workaround
which should not be too painful for most people. We shouldn't rush
to do anything big here, but we should recognize where we stand.
--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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: kgrittn@ymail.com, tgl@sss.pgh.pa.us, robertmhaas@gmail.com, pgsql@j-davis.com
Subject: Re: Failure to coerce unknown type to specific type
In-Reply-To: <1648216624.644283.1430683633940.JavaMail.yahoo@mail.yahoo.com>
References: <23845.1430681631@sss.pgh.pa.us> <1648216624.644283.1430683633940.JavaMail.yahoo@mail.yahoo.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