> Your problem is that NULL's are typed in PostgreSQL.
>
> Try this:
>
> SELECT NULL;
> SELECT NULL::BOOL;
> SELECT NULL::BOOL::TEXT;
>
> to see what I mean. This is an exact illustration of your problem.
Note that in 8.1 he will be able to do:
SELECT NULL::TEXT::INT::BOOL
and get the conversion he wants as long as he sticks to using 0 and 1 to
code for false and true.