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