From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: varchar/name casts |
Date: | 2008-08-15 13:59:14 |
Message-ID: | 20203.1218808754@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2008-08-15 14:01:36 | Re: proposal sql: labeled function params |
Previous Message | Pavel Stehule | 2008-08-15 13:31:09 | Re: proposal sql: labeled function params |