Re: Casting timestamp with time zone to varchar automatically - Mailing list pgsql-general

From Tom Lane
Subject Re: Casting timestamp with time zone to varchar automatically
Date
Msg-id 16887.1091594937@sss.pgh.pa.us
Whole thread Raw
In response to Re: Casting timestamp with time zone to varchar automatically  ("Jim C. Nasby" <decibel@decibel.org>)
Responses Re: Casting timestamp with time zone to varchar automatically  ("Jim C. Nasby" <decibel@decibel.org>)
List 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 by date:

Previous
From: Scott Ribe
Date:
Subject: Re: trash talk
Next
From: Marius Andreiana
Date:
Subject: Re: [PERFORM] NOT IN query takes forever