From: Tom Lane <tgl@sss.pgh.pa.us>
To: Marc G. Fournier <scrappy@postgresql.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: [HACKERS] ALTER TABLE ( smallinto -> boolean ) ...
Date: Thu, 01 Sep 2005 17:25:28 -0400
Message-ID: <6752.1125609928@sss.pgh.pa.us> (raw)
In-Reply-To: <20050901180607.V1044@ganymede.hub.org>
References: <20050829201253.X1044@ganymede.hub.org>
<15013.1125359379@sss.pgh.pa.us>
<20050901174341.N1044@ganymede.hub.org>
<6399.1125608205@sss.pgh.pa.us>
<20050901180607.V1044@ganymede.hub.org>
"Marc G. Fournier" <scrappy@postgresql.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, scrappy@postgresql.org
Subject: Re: [HACKERS] ALTER TABLE ( smallinto -> boolean ) ...
In-Reply-To: <6752.1125609928@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox