Domain casting still doesn't work right

Lists: pgsql-hackers
From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Domain casting still doesn't work right
Date: 2003-06-28 15:45:15
Message-ID: Pine.LNX.4.44.0306281547540.2178-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Here's another example of domain casting not working right:

create domain foo as varchar;
select cast(x.y as foo) from (select 'foo') as x(y);
ERROR: coerce_type: no conversion function from "unknown" to foo

--
Peter Eisentraut peter_e(at)gmx(dot)net


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Domain casting still doesn't work right
Date: 2003-06-28 16:02:00
Message-ID: 18176.1056816120@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> Here's another example of domain casting not working right:
> create domain foo as varchar;
> select cast(x.y as foo) from (select 'foo') as x(y);
> ERROR: coerce_type: no conversion function from "unknown" to foo

Not the domain's fault. You get the same error without it:

regression=# select cast(x.y as varchar) from (select 'foo') as x(y);
ERROR: coerce_type: no conversion function from "unknown" to character varying

The problem, if it is one, is that the subselect's output column is
irrevocably assigned the datatype "unknown" when we form the subselect
result list. We could make this particular problem go away by coercing
the subselect result to text, but that would create problems in other
areas, notably UNIONs. In a UNION you need to leave the individual
subselect's outputs typed as unknown as long as possible, so that they
don't screw up a type assignment derived from another subselect where
the column isn't an untyped literal.

regards, tom lane