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

From: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: ALTER TABLE ( smallinto -> boolean ) ...
Date: 2005-09-01 20:49:02
Message-ID: 20050901174341.N1044@ganymede.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

On Mon, 29 Aug 2005, Tom Lane wrote:

> "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;

'k, I just took a read through the "CREATE CAST" man page, and don't think
I can use that for this, but is there some way I can create a cast for
this, so that we don't have to go through the complete application and
change "VALUES ( 0 );" to "VALUES ( '0' );" ...

Again, from reading the man page, I'm guessing not, but just want to make
sure that I haven't missed anything ...

----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email: scrappy(at)hub(dot)org Yahoo!: yscrappy ICQ: 7615664

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-09-01 20:56:45 Re: ALTER TABLE ( smallinto -> boolean ) ...
Previous Message Tom Lane 2005-09-01 20:47:42 GRANT/roles problem: grant is shown as from login role

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2005-09-01 20:56:45 Re: ALTER TABLE ( smallinto -> boolean ) ...
Previous Message Joÿffffffffffe3o Carvalho 2005-09-01 14:00:30 SQL queries