Re: ALTER TABLE ( smallinto -> boolean ) ...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: ALTER TABLE ( smallinto -> boolean ) ...
Date: 2005-08-29 23:49:39
Message-ID: 15013.1125359379@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

"Marc G. Fournier" <scrappy(at)postgresql(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-08-30 00:18:50 SHMMAX seems entirely broken in OS X 10.4.2
Previous Message Rod Taylor 2005-08-29 23:33:31 Re: ALTER TABLE ( smallinto -> boolean ) ...

Browse pgsql-sql by date

  From Date Subject
Next Message Matt A. 2005-08-30 03:38:06 Re: [SQL] question
Previous Message Rod Taylor 2005-08-29 23:33:31 Re: ALTER TABLE ( smallinto -> boolean ) ...