On Thu, May 18, 2006 at 05:41:14PM +0200, Thomas Hallgren wrote:
> Just out of curiosity (and most likely, ignorance). Why can't I cast an
> array of strings into a string? I.e.
>
> thhal=# select ('{"a","b"}'::varchar[])::varchar;
> ERROR: cannot cast type character varying[] to character varying
Why would you need to? What would you expect to happen? Joined with a
seperator, no seperator, with parenthesis?
> or a cstring into a varchar, i.e.
>
> thhal=# select array_out('{"a","b"}'::varchar[])::varchar;
> ERROR: cannot cast type cstring to character varying
varchar_in will do the conversion, why would want to make it a cast?
What's the benefit of a cast over a function call?
> ISTM, the implementation of such casts should be fairly simple and
> straight forward and sometimes even useful. Every data type comes with
> string coercion routines anyway right?
Every cast costs space and lookup time. Any user can add their own
casts if they want, but the system generally only includes the ones
useful to many people or those required for standards complience.
Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.