Re: [HACKERS] domain casting?

2007-08-10 Thread Tom Lane
Pavel Stehule [EMAIL PROTECTED] writes:
 Is possible casting domain?

No, because find_coercion_pathway() expects that only base types are
listed in pg_cast, so it starts by stripping domains.  Function lookup
tends to do that too, so it's hard even to declare a function as taking
a domain.

Elein was going to look into devising a more domain-friendly set of
type coercion rules, but I dunno if she's made any progress.

regards, tom lane

---(end of broadcast)---
TIP 6: explain analyze is your friend

Re: [HACKERS] Domain casting still doesn't work right

2003-06-28 Thread Tom Lane
Peter Eisentraut [EMAIL PROTECTED] 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

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?