Re: Dynamic views/permissions

From: Ian Barwick <barwick(at)gmx(dot)net>
To: Raj Mathur <raju(at)linux-delhi(dot)org>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Dynamic views/permissions
Date: 2003-05-30 20:35:48
Message-ID: 200305302235.48653.barwick@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Friday 30 May 2003 21:31, Raj Mathur wrote:
> I'm trying to permit users access to their own records in a database.
> A sample would be:
>
> create table logins
> (
> login char(8),
> name char(32),
> primary key (login)
> );
>
> When a login is added an SQL user is created simultaneously. Now I
> want the user to be able to view her own data:
>
> create function userid() returns text as 'select current_user::text;'
> language sql;
>
> create view loginview as select * from logins where logins.login=userid();
>
> grant select on loginview to public;
> [OR grant select on loginview to <userid>...]
>
> However, a select * from loginview; doesn't return any rows. Is what
> I'm trying not possible at all, or am I just trying to implement it
> wrong?

What happens if you define logins.login as VARCHAR instead of CHAR?

See also:
http://www.postgresql.org/docs/faqs/FAQ.html#4.14

Ian Barwick
barwick(at)gmx(dot)net

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Guy Fraser 2003-05-30 21:13:35 Re: Calculating with the time
Previous Message Raj Mathur 2003-05-30 19:31:21 Dynamic views/permissions