bit/integer operations in postgres

From: Marc Munro <marc(at)bloodnok(dot)com>
To: littlebutty(at)gmail(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: bit/integer operations in postgres
Date: 2006-01-03 16:55:16
Message-ID: 1136307317.8751.15.camel@bloodnok.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

If I understand this correctly, I think you want to implement the sort
of security that Veil provides. Take a look at
http://pgfoundry.org/projects/veil/

The documentation is at
http://veil.projects.postgresql.org/curdocs/index.html

__
Marc

On Sun, 2006-01-01 at 17:02 -0400, littlebutty wrote:
> Date: 22 Dec 2005 17:04:30 -0800
> From: "littlebutty" <littlebutty(at)gmail(dot)com>
> To: pgsql-general(at)postgresql(dot)org
> Subject: bit/integer operations in postgres
> Message-ID: <1135299870(dot)165441(dot)317110(at)f14g2000cwb(dot)googlegroups(dot)com>
>
> Does anyone know how I can solve this problem in Postgres:
>
> I am creating a table of user permissions. I want to represent each
> permission as a bit location. Each new permission I add to my system
> would be assigned to the next available bit (or column if you will)
> That way I can simply turn on a particular bit location for a
> particular user and then AND their permission level with a particular
> permission bit.
> Just as an example:
> Access to financial data is the first bit and would be represented by
> 1.
> Access to the admin section would be the 2nd bit, represented by 01.
> Access to the reporting section would be the 3rd bit, represented by
> 001.
>
> Thus a user with access to the admin section but nothing else would
> have 010
> and a user with access to everything would have 111.
>
>
> All possible permissions are stored in one table and a users
> permission
> level is stored in the user table, but both fields are integer data
> types.
>
> HERE IS WHAT I WANT TO DO:
> How do I setup a postgres constraint that will not allow an insert on
> the permission table with an integer value that has more than one bit
> set. In other words you could insert 1, 2, 4, 8, 16, 32, etc. because
> there is only a single bit on in all of those integers, but not insert
> 3, 5, 6, 7, 9, 15, 19, etc. because they have multiple???
>
>

Browse pgsql-general by date

  From Date Subject
Next Message SCassidy 2006-01-03 17:06:38 Re: pg_dump error codes
Previous Message Alejandro D. Burne 2006-01-03 16:45:45 Re: Visual FoxPro 9 ODBC errors