Re: Question about casts

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Thomas Hallgren <thomas(at)tada(dot)se>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Question about casts
Date: 2006-05-18 15:52:59
Message-ID: 20060518155258.GC4359@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Treat 2006-05-18 16:01:24 Re: Google and the Beta Freeze
Previous Message Thomas Hallgren 2006-05-18 15:41:14 Question about casts