Search Postgresql Archives

Re: converting E'C:\\something' to bytea

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Vlad Romascanu <vromascanu@xxxxxxxxxxx> writes:
> Hi, Tom,
> Why does:

>    CREATE CAST (text AS bytea) WITHOUT FUNCTION;
>    SELECT E'C:\\something'::text::bytea;

> work as expected, but (with the original text->bytea cast in place):

>    CREATE DOMAIN my_varlena AS text;
>    CREATE CAST (my_varlena AS bytea) WITHOUT FUNCTION;
>    SELECT E'C:\\something'::my_varlena::bytea;

> does not

Domains are not meant to support ad-hoc cast paths like that ---
generally, the parser smashes domains to their base types before even
looking into pg_cast.  The reason for this is that the defined pathway
is source_domain -> source_base_type -> dest_base_type -> dest_domain
and allowing user-defined cast paths to short-circuit that would create
all kinds of uncertainty, in particular whether or not constraints on
a destination domain had been verified.

Possibly we ought to disallow CREATE CAST involving a domain, since
you're not the first person to think that he can impose special cast
rules by using a domain.

			regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux