Re: Casting timestamp with time zone to varchar automatically

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Casting timestamp with time zone to varchar automatically
Дата
Msg-id 16887.1091594937@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Casting timestamp with time zone to varchar automatically  ("Jim C. Nasby" <decibel@decibel.org>)
Ответы Re: Casting timestamp with time zone to varchar automatically  ("Jim C. Nasby" <decibel@decibel.org>)
Список pgsql-general
"Jim C. Nasby" <decibel@decibel.org> writes:
> ... I'd like to know
> if there is a specific reason there's no default timestamp -> varchar
> cast.

There is an explicit cast from timestamp to varchar, at least in recent
releases:

regression=# select 'now'::timestamp::varchar;
          varchar
---------------------------
 2004-08-04 00:42:05.34875
(1 row)

Whether this should be invokable implicitly is somewhat of a theological
issue, but personally I'm agin it.  My experience is that implicit
cross-type-category casts are Bad News All Around because they tend to
happen when you weren't expecting it, resulting in quite surprising
behavior.  (An implicit cast from, say, timestamp to date is far less
dangerous.)  You can find lots of discussion about related issues in
the list archives.

            regards, tom lane

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

Предыдущее
От: Scott Ribe
Дата:
Сообщение: Re: trash talk
Следующее
От: Marius Andreiana
Дата:
Сообщение: Re: [PERFORM] NOT IN query takes forever