Re: Some issues about data type convert

Поиск
Список
Период
Сортировка
От Sam Mason
Тема Re: Some issues about data type convert
Дата
Msg-id 20100104151051.GW5407@samason.me.uk
обсуждение исходный текст
Ответ на Re: Some issues about data type convert  ("Albe Laurenz" <laurenz.albe@wien.gv.at>)
Ответы Re: Some issues about data type convert  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Mon, Jan 04, 2010 at 03:55:15PM +0100, Albe Laurenz wrote:
> donniehan wrote:
> > postgres=# create table test1(c1 OID, c2 BIGINT);
> > postgres=# create view v1 as select coalesce(c1,c2) from test1;
> > postgres=# \d v1
> >  SELECT COALESCE(test1.c1, test1.c2::oid) AS "coalesce"
> >    FROM test1;
> >
> > Although we can define the view v1 successfully, but we can
> > not get what we want.
> > If pg can convert  INT8 into OID implicitly, it seems there
> > would not be any problems.
>
> This has nothing to do with implicit or explicit casts.

Um, I think the OP is right.  Notice he does:

  create view v1 as select coalesce(c1,c2) from test1;

which PG interprets as:

  SELECT COALESCE(test1.c1, test1.c2::oid) AS "coalesce" FROM test1;

showing that PG is auto-magically inserting a cast from BIGINT to OID.
The OP is saying that this isn't right because the cast isn't a total
function, i.e. it fails for -1 and a large number of other inputs.

I think the OP is either expecting the CREATE VIEW to fail saying types
are invalid, or to result in "c1" being cast to BIGINT.

--
  Sam  http://samason.me.uk/

В списке pgsql-general по дате отправления:

Предыдущее
От: "Albe Laurenz"
Дата:
Сообщение: Re: Some issues about data type convert
Следующее
От: Chris Browne
Дата:
Сообщение: Re: Save MySQL? HA