<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#333333">
<font face="Tahoma">Scratch that... I have been at this too long and am
entirely confused about what server I'm working on (and consequently
what version).</font><br>
<br>
Mark S wrote:
<blockquote cite="mid:47B21DA1(dot)5030208(at)gravitycollege(dot)com" type="cite"><font
face="Tahoma">Hello all,<br>
<br>
I am new to PostgreSQL, coming from MySQL. I have a question that
strikes me as simple but Google has failed to turn up any simple
answers. I utilize bit masking in my code. In MySQL I used this:<br>
<br>
SELECT * WHERE col & 3;<br>
<br>
When I ported my code I was using an 8.1 PostgreSQL staging server, and
this worked:<br>
<br>
SELECT * WHERE (col & 3)::bool;<br>
<br>
Now that I'm testing it in the 8.2 production server, it's telling me I
can't cast integer to bool. I know I can just use (col & 3)
<> 0, and it's what I'm doing, but I feel like I'm missing
something that you can't convert an integer to a boolean. What
surprised me even more was:<br>
<br>
SELECT 1::bit::bool; -- ERROR: cannot cast type bit to boolean<br>
<br>
It also seems strange that you can't cast a bit to boolean. So I guess
my question is one of curiosity, since I have a perfectly workable
solution (comparing against 0), but am I missing something here? I know
I can create my own casts but I feel like altering casting rules for
such a low-level type as integer and bool would be a bad idea.<br>
<br>
Thanks,</font><br>
<div class="moz-signature">
<title></title>
<small><font face="Verdana"><b>Mark</b></font><br>
</small>
</div>
</blockquote>
</body>
</html>