From: Tom Lane <tgl@sss.pgh.pa.us>
To: 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: Wed, 29 Apr 2015 15:37:51 -0700
Message-ID: <35651.1430347071@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+Tgmoav4gswNkA39SYdb3SdSBfrcHmU08=nXLNbxMZFg7UYsw@mail.gmail.com>
References: <CAMp0ubdECGUJWpQKyUM36PxQWoKe0VfTbHGHgn+w2H_5q1Nmow@mail.gmail.com>
<1430.1428543112@sss.pgh.pa.us>
<CA+Tgmoav4gswNkA39SYdb3SdSBfrcHmU08=nXLNbxMZFg7UYsw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Robert Haas <robertmhaas@gmail.com> writes:
> On Wed, Apr 8, 2015 at 9:31 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Jeff Davis <pgsql@j-davis.com> writes:
>>> Original report and patch by Karl Schnaitter.
>>> create table a(u) as select '1';
>> We should, in fact, fail that to begin with. Unknown-type columns are
>> a spectactularly horrid idea.
> I agree. So why don't we throw an error when someone tries to create one?
We should IMO, but there's been push-back about backwards compatibility
when this has been proposed in the past. But I'd rather break backwards
compatibility to the extent of saying "you can't do that" than to try to
make unknown a full-fledged type, which is what this patch wants to do.
I have some recollection that we'd also put it off pending resolution of
debates about how to handle unknown-type literals in UNIONs and similar
contexts. But poking at such examples right now, the behavior seems
generally reasonable: it seems like we resolve "unknown" as text when
forced to make a decision, but otherwise put it off as long as possible.
So that consideration may be obsolete.
An alternative design that is also worthy of consideration is to force
the created view or table column to be type text rather than unknown.
But that would be more complex to implement, and it's not obviously
superior to saying "hey bud, you need to be more specific as to what
column type you intend here".
regards, tom lane
--
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: 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: <35651.1430347071@sss.pgh.pa.us>
References: <CAMp0ubdECGUJWpQKyUM36PxQWoKe0VfTbHGHgn+w2H_5q1Nmow@mail.gmail.com> <1430.1428543112@sss.pgh.pa.us> <CA+Tgmoav4gswNkA39SYdb3SdSBfrcHmU08=nXLNbxMZFg7UYsw@mail.gmail.com> <35651.1430347071@sss.pgh.pa.us>
* 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