Re: cast of integer to bool doesn't work (anymore?)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Eric Veldhuyzen <ericv(at)xs4all(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: cast of integer to bool doesn't work (anymore?)
Date: 2003-03-21 15:07:47
Message-ID: 12627.1048259267@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Eric Veldhuyzen <ericv(at)xs4all(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Dan Winslow 2003-03-21 15:51:40 Seeking help with a query....
Previous Message Eric Veldhuyzen 2003-03-21 15:01:38 Re: cast of integer to bool doesn't work (anymore?)