> 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?
I think the idea was to support the functional casting notation, viz
"varchar(name_col)". However it seems we've broken that already for
most of the other cases; and in any case it never worked very nicely
for varchar because "varchar" is a reserved word, so you have to
quote :-(
As a historical note, in 7.3 (the first release with a pg_cast catalog)
your query gives just
castsource | casttarget | castfunc | castcontext
-------------------+-------------------+-------------------------+-------------
name | character varying | "varchar"(name) | i
text | character varying | - | i
character | character varying | - | i
character varying | name | name(character varying) | i
character varying | text | - | i
character varying | character | - | i
(6 rows)
So it seems the cross-category casts for varchar got accreted on later,
rather than it being a case of things having disappeared.
regards, tom lane
--
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:
Post a Comment