X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 79F0FD8797; Thu, 1 Sep 2005 18:25:29 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 28137-01; Thu, 1 Sep 2005 21:25:27 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 92146D8433; Thu, 1 Sep 2005 18:25:26 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j81LPSKE006753; Thu, 1 Sep 2005 17:25:28 -0400 (EDT) To: "Marc G. Fournier" Cc: pgsql-sql@postgresql.org Subject: Re: [HACKERS] ALTER TABLE ( smallinto -> boolean ) ... 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> Comments: In-reply-to "Marc G. Fournier" message dated "Thu, 01 Sep 2005 18:15:25 -0300" Date: Thu, 01 Sep 2005 17:25:28 -0400 Message-ID: <6752.1125609928@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200509/3 X-Sequence-Number: 22550 "Marc G. Fournier" writes: > all I want to do is: > CREATE CAST ( 0 AS boolean ) > WITH FUNCTION > 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