Friday, August 15, 2008

[HACKERS] varchar/name casts

With this query you can view all casts involving varchar:

SELECT castsource::regtype, casttarget::regtype, castfunc::regprocedure,
castcontext FROM pg_cast WHERE 'varchar'::regtype IN (castsource, casttarget)
ORDER BY 1, 2;

Note that varchar mostly "borrows" the cast functions from the text type. The
exception is that there is a separate set of SQL-level functions for casting
between name and varchar and vice versa. But these are actually matched to
the same C-level functions as the casts between text and name (name_text()
and text_name()).

Does anyone recall a reason for this special case or is it just another dark
area in the casting maze? If the latter, I would like to remove the extra
functions and redefine the casts between varchar and name to use the
SQL-level casting functions for the text type.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

No comments: