Re: Operation on bit strings with different length

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: S P Arif Sahari Wibowo <arifsaha(at)yahoo(dot)com>, <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Operation on bit strings with different length
Date: 2001-12-18 16:37:46
Message-ID: web-531103@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice pgsql-sql

Arif,

For future notice, the NOVICE list is the appropriate place for this
type of question.

> Do you know how to operate (AND, OR, etc.) on bit strings with
> dynamically different length? It is dynamic, means the length won't
> be
> determined until run time.
> Is there any function to extend the length of a bit string to a
> certain
> length?

PostgreSQL is currently (as far as I know) lacking a good set of bitwise
data types and operators. If you really need to use them, I suggest
that you construct them -- Postgres allows you to build your own data
types, and operators for those data types. It's a somewhat
labor-intensive process.

Most of us don't have much use for bitwise operations in the database,
because the essential intent of a bitwise number is to store several
different pieces of data in the same number. This goes against
relational principles, which say that each field should be "atomic";
that is, containing one and only one piece of information.

If, however, you are interacting with the MS API, I can see why you
would need bitwise logic. So my suggestions are:

1. Create your own data types and operators per paragraph 1;
2. Just store the integer in Postgres, and do your bitwise logic in your
interface/middleware language.

-Josh Berkus

-Josh Berkus

______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh(at)agliodbs(dot)com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joe Koenig 2001-12-18 18:04:00 Way to use count() and LIMIT?
Previous Message Andrew Snow 2001-12-18 14:48:41 Re: PG sql string -> time_t

Browse pgsql-novice by date

  From Date Subject
Next Message Peter Eisentraut 2001-12-18 22:23:52 Re: Operation on bit strings with different length
Previous Message S P Arif Sahari Wibowo 2001-12-18 05:33:43 Operation on bit strings with different length

Browse pgsql-sql by date

  From Date Subject
Next Message Ivan Manuel Andrade Muñoz 2001-12-18 20:07:40 HELP PLEASE: Error executing the example esql.xml on cocoon1.8.2
Previous Message Archibald Zimonyi 2001-12-18 15:50:37 Re: Performance problem, what to do?