From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
---|---|
To: | Dennis Gearon <gearond(at)cvc(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: operators and bit field |
Date: | 2003-02-14 21:37:03 |
Message-ID: | 20030214213703.GA28014@wolff.to |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, Feb 14, 2003 at 11:12:15 -0800,
Dennis Gearon <gearond(at)cvc(dot)net> wrote:
> I haven't seen what operators can be applied to bit masks.
It looks like & works:
area=> select 3&6;
?column?
----------
2
(1 row)
>
> In particular, I am looking to use binary AND:
>
> I want to AND two bitmasks together and see:
>
> A/ if the result has ANY bits set
> B/ what bits are set in the results.
>
> SELECT other_fields
> FROM some_table
> WHERE
> ( bitmask_8_columnA & bitmask_8_column B) = bitmask_8_patternONE
> OR ( bitmask_8_columnA & bitmask_8_column B) = bitmask_8_patternTWO
> ;
>
> I may try to use a single char for one of the bit masks I need,
> is it possible to store all 256 values into a varchar(1) using
> escaped input?
>
> Is it possible to AND two varchars within a select and compare the result?
>
> SELECT other_fields
> FROM some_table
> WHERE ( varchar_1_columnA & varchar_1_columnB ) = 'single_escaped_char_string';
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Eckermann | 2003-02-14 21:38:27 | Re: "iscachable" functions |
Previous Message | Bruce Momjian | 2003-02-14 21:35:59 | Re: In 7.3.1, will I be able to reindex toast? |