Re: ALTER TABLE ( smallinto -> boolean ) ... - Mailing list pgsql-hackers

From Tom Lane
Subject Re: ALTER TABLE ( smallinto -> boolean ) ...
Date
Msg-id 15013.1125359379@sss.pgh.pa.us
Whole thread Raw
In response to ALTER TABLE ( smallinto -> boolean ) ...  ("Marc G. Fournier" <scrappy@postgresql.org>)
Responses Re: ALTER TABLE ( smallinto -> boolean ) ...  (Greg Stark <gsstark@mit.edu>)
Re: ALTER TABLE ( smallinto -> boolean ) ...  ("Marc G. Fournier" <scrappy@postgresql.org>)
List pgsql-hackers
"Marc G. Fournier" <scrappy@postgresql.org> writes:
> # ALTER TABLE table ALTER COLUMN field1 type boolean;
> ERROR:  column "field1" cannot be cast to type "pg_catalog.bool"

> Should this not work?

No, because there's no built-in cast from smallint to bool.  You could
do something like

... type boolean using case when field1=0 then false else true end;
        regards, tom lane


pgsql-hackers by date:

Previous
From: Rod Taylor
Date:
Subject: Re: ALTER TABLE ( smallinto -> boolean ) ...
Next
From: Tom Lane
Date:
Subject: SHMMAX seems entirely broken in OS X 10.4.2