Re: bitwise again - Mailing list pgsql-general

From Peter Eisentraut
Subject Re: bitwise again
Date
Msg-id Pine.LNX.4.30.0104021839400.1287-100000@peter.localdomain
Whole thread Raw
In response to bitwise again  (Alexander Lohse <al@humantouch.de>)
List pgsql-general
Alexander Lohse writes:

> In MySQL I use following bitwise operation on an INT field:
>
> $q = "select id from my_tbl where aid & 2";
>
> In Postgres I tried the same, but I found no working solution.

Upgrade to 7.1.

> Is it better(or even possible) to use bitwise operator on an int4
> field or shall I prefer the varbit?

If you plan on bit fields larger than 32 bits and/or you need string-like
functions (substring, position), then BIT or BIT VARYING are for you.  If
you plan to use numeric operators (+, sqrt), then use an integer type.

> Using the above as in MySQL, I get an ERROR:
> WHERE clause must return type bool, not type int4

Indeed.  Maybe you meant something like (aid & 2) <> 0.

--
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/


pgsql-general by date:

Previous
From: teg@redhat.com (Trond Eivind Glomsrød)
Date:
Subject: Re: Need PostgreSQL startup scripts
Next
From: Peter Eisentraut
Date:
Subject: Re: Need PostgreSQL startup scripts