Thread: binary operators on integers

binary operators on integers

From
Marko Kreen
Date:
I want to do simple and/or/xor/test operations on integers
but PostgreSQL seems not to support this.  I found in conrib
area the 'bit' package, which supports 'SQL-compliant bitstrings'
but this is too weird for me and anyway it crashes too.

So, my question 'How can I do this?'  Is there any plans to implement
those operators for integer types, or good reasons why they cannot
be implemented?  Should I try to implement those myself or start
debugging the 'bit' package?

My situation: I want to implement a 'capabilities' field for
application server, so different bits are for different
capabilities.

TIA.

--
marko


Re: binary operators on integers

From
Peter Eisentraut
Date:
Marko Kreen writes:

> I want to do simple and/or/xor/test operations on integers
> but PostgreSQL seems not to support this.  I found in conrib
> area the 'bit' package, which supports 'SQL-compliant bitstrings'
> but this is too weird for me and anyway it crashes too.

These were the remainders of a slightly too late implementation attempt
for 7.0. In 7.1 they should be fully functional.

> My situation: I want to implement a 'capabilities' field for
> application server, so different bits are for different
> capabilities.

Personally, I'd say using bit fields for that is pushing it a little too
hard. You could use shortint fields, or char(1)'s if you are not that
concerned about space.


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


Re: binary operators on integers

From
Marko Kreen
Date:
On Mon, Sep 18, 2000 at 10:17:55PM +0200, Peter Eisentraut wrote:
> Marko Kreen writes:
> > My situation: I want to implement a 'capabilities' field for
> > application server, so different bits are for different
> > capabilities.
>
> Personally, I'd say using bit fields for that is pushing it a little too
> hard. You could use shortint fields, or char(1)'s if you are not that
> concerned about space.
>
Hmm, probably you are right.

But now I am only curious: Will PostgreSQL support binary
arithmetics on ordinary integers someday or is the 'bit-string'
only way to go?

--
marko


Re: binary operators on integers

From
Peter Eisentraut
Date:
Marko Kreen writes:

> But now I am only curious: Will PostgreSQL support binary
> arithmetics on ordinary integers someday or is the 'bit-string'
> only way to go?

AFAIK, there's no one working on the former. Feel free to contribute. :-)

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