varchar/name casts

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: varchar/name casts
Date: 2008-08-15 13:00:47
Message-ID: 200808151600.47471.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2008-08-15 13:03:10 Re: proposal sql: labeled function params
Previous Message Peter Eisentraut 2008-08-15 12:54:40 Re: XML / XSL rendering in PostgreSQL server?