Re: [HACKERS] 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-sql(at)postgresql(dot)org
Subject: Re: [HACKERS] ALTER TABLE ( smallinto -> boolean ) ...
Date: 2005-09-01 21:25:28
Message-ID: 6752.1125609928@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:
> all I want to do is:

> CREATE CAST ( 0 AS boolean )
> WITH FUNCTION <I have to create this>
> AS ASSIGNMENT;

> And then each time I try to insert a '0' into a BOOLEAN field, it will
> auto convert that (based on my function) to 'f' ...

> And I'd need to do a second one for 1 -> 't' ...

No, you want one function from smallint to boolean, and the cast the
same way. (The cast is really just syntactic sugar for invoking the
function.)

Depending on what you want this to do, you might have to make the cast
IMPLICIT rather than ASSIGNMENT. I'd try ASSIGNMENT first, though,
since it's less likely to bite you when you weren't expecting it.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-09-01 21:30:42 Re: ALTER TABLE ( smallinto -> boolean ) ...
Previous Message Andrew Dunstan 2005-09-01 21:23:08 Re: ALTER TABLE ( smallinto -> boolean ) ...

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2005-09-01 21:30:42 Re: ALTER TABLE ( smallinto -> boolean ) ...
Previous Message Owen Jacobson 2005-09-01 21:24:59 Re: [HACKERS] ALTER TABLE ( smallinto -> boolean ) ...