Re: [GENERAL] bitwise storage and operations

2016-09-27 Thread Jonathan Vanasco
On Sep 27, 2016, at 10:54 AM, Brian Dunavant wrote: > db=# select 'foo' where (9 & 1) > 0; A HA Thank you Brian and David -- I didn't realize that you needed to do the comparison to the result. (or convert the result as these work): select 'foo' where (9 & 1)::bool; select

Re: [GENERAL] bitwise storage and operations

2016-09-27 Thread Brian Dunavant
If it's in integer columns, bitwise logic works just like you would expect it to as well. https://www.postgresql.org/docs/current/static/functions-math.html db=# select 'foo' where (9 & 1) > 0; ?column? -- foo (1 row) db=# select 'foo' where (9 & 2) > 0; ?column? -- (0 rows)

Re: [GENERAL] bitwise storage and operations

2016-09-26 Thread David G. Johnston
​ ​Please include the list in all replies. On Mon, Sep 26, 2016 at 4:14 PM, Jonathan Vanasco wrote: > > On Sep 26, 2016, at 5:04 PM, David G. Johnston wrote: > > On Mon, Sep 26, 2016 at 1:44 PM, Jonathan Vanasco > wrote: > >> The documentation doesn't have

Re: [GENERAL] bitwise storage and operations

2016-09-26 Thread David G. Johnston
On Mon, Sep 26, 2016 at 1:44 PM, Jonathan Vanasco wrote: > The documentation doesn't have any examples for SELECT for the bitwise > operators, Um... ​https://www.postgresql.org/docs/9.5/static/functions-bitstring.html​ SELECT B'111'::varbit & B'101'::varbit =

[GENERAL] bitwise storage and operations

2016-09-26 Thread Jonathan Vanasco
We've been storing some "enumerated"/"set" data in postgresql as INT or BIT(32) for several years for some flags/toggles on records. This was preferable for storage to the ENUM type (or multiple columns), as we often changed the number of enumerated options or their labels -- and computing