From: Andrew Dunstan <andrew@dunslane.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Marc G. Fournier <scrappy@postgresql.org>
Cc: pgsql-hackers@postgresql.org
Subject: Re: ALTER TABLE ( smallinto -> boolean ) ...
Date: Thu, 01 Sep 2005 17:23:08 -0400
Message-ID: <4317713C.10808@dunslane.net> (raw)
In-Reply-To: <6399.1125608205@sss.pgh.pa.us>
References: <20050829201253.X1044@ganymede.hub.org>
<15013.1125359379@sss.pgh.pa.us>
<20050901174341.N1044@ganymede.hub.org>
<6399.1125608205@sss.pgh.pa.us>
Tom Lane wrote:
>"Marc G. Fournier" <scrappy@postgresql.org> writes:
>
>
>>On Mon, 29 Aug 2005, Tom Lane wrote:
>>
>>
>>>No, because there's no built-in cast from smallint to bool.
>>>
>>>
>
>
>
>>'k, I just took a read through the "CREATE CAST" man page, and don't think
>>I can use that for this,
>>
>>
>
>Sure you can. Make a SQL or PLPGSQL function that does the conversion
>you want and then create a cast using it.
>
>
That probably won't help him much with "values(0)":
andrew=# create function ibool(smallint) returns boolean language sql as
$$ select $1 <> 0 $$;
CREATE FUNCTION
andrew=# create cast (smallint as boolean) with function ibool(smallint)
as implicit;
CREATE CAST
andrew=# insert into foobool values(0);
ERROR: column "x" is of type boolean but expression is of type integer
HINT: You will need to rewrite or cast the expression.
Is there a way to make the builtin int to bool cast implicit?
cheers
andrew
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: andrew@dunslane.net, tgl@sss.pgh.pa.us, scrappy@postgresql.org, pgsql-hackers@postgresql.org
Subject: Re: ALTER TABLE ( smallinto -> boolean ) ...
In-Reply-To: <4317713C.10808@dunslane.net>
* 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