Re: Casting to varchar - Mailing list pgsql-general

From Michael Glaesemann
Subject Re: Casting to varchar
Date
Msg-id 7546E019-BAE0-4023-BCF3-04E99633CB1C@seespotcode.net
Whole thread Raw
In response to Casting to varchar  (Scott Ribe <scott_ribe@killerbytes.com>)
Responses Re: Casting to varchar
Re: Casting to varchar
List pgsql-general
On May 4, 2007, at 15:34 , Scott Ribe wrote:

> Are there any other standard types that can't be cast
> to varchar?

You already got an answer to the first part of your question, but I
thought you might be interested in the second as well. Here's what I
did:

SELECT DISTINCT cast_from
FROM pg_cast c
NATURAL JOIN (
     SELECT oid as castsource, typname as cast_from
     FROM pg_type
     ) s
WHERE NOT EXISTS (
     SELECT 1
     FROM pg_cast i
     NATURAL JOIN (
         SELECT oid as casttarget, typname as cast_target
         FROM pg_type
         ) t
     WHERE cast_target = 'text'
         AND i.castsource = c.castsource
     )
ORDER BY cast_from;

   cast_from
--------------
abstime
bit
bool
box
circle
lseg
path
polygon
regclass
regoper
regoperator
regproc
regprocedure
regtype
reltime
text
varbit
(17 rows)

I don't know which of those you'd consider standard, but I believe
that's a complete list from HEAD of a few minutes ago.

Michael Glaesemann
grzm seespotcode net



pgsql-general by date:

Previous
From: Dave Page
Date:
Subject: Re: R: Postgres 8.3-dev
Next
From: Martijn van Oosterhout
Date:
Subject: Re: varchar as primary key