Re: cast of integer to bool doesn't work (anymore?) - Mailing list pgsql-sql

From Tom Lane
Subject Re: cast of integer to bool doesn't work (anymore?)
Date
Msg-id 12627.1048259267@sss.pgh.pa.us
Whole thread Raw
In response to cast of integer to bool doesn't work (anymore?)  (Eric Veldhuyzen <ericv@xs4all.net>)
List pgsql-sql
Eric Veldhuyzen <ericv@xs4all.net> writes:
> # select 0::boolean;
>  bool=20
> ------
>  f
> (1 row)

> Perfect.

Not so perfect as you think --- 7.2 does not allow casting from int to
bool any more than 7.3 does.  Try this:

regression=# select 1::int::boolean;
ERROR:  Cannot cast type 'integer' to 'boolean'

7.2 is interpreting your query like

regression=# select '1'::boolean;bool
------t
(1 row)

which still works in 7.3 --- but we tightened up the other case, for
reasons I don't recall at the moment but you can find in the mailing
list archives.
        regards, tom lane


pgsql-sql by date:

Previous
From: Eric Veldhuyzen
Date:
Subject: Re: cast of integer to bool doesn't work (anymore?)
Next
From: Achilleus Mantzios
Date:
Subject: Re: cast of integer to bool doesn't work (anymore?)