pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedDynamic views/permissions
2+ messages / 2 participants
[nested] [flat]
* Dynamic views/permissions
@ 2003-05-30 19:31 Raj Mathur <raju@linux-delhi.org>
0 siblings, 1 reply; 2+ messages in thread
From: Raj Mathur @ 2003-05-30 19:31 UTC (permalink / raw)
To: pgsql-sql
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?
Regards,
-- Raju
--
Raj Mathur raju@kandalaya.org http://kandalaya.org/
GPG: 78D4 FC67 367F 40E2 0DD5 0FEF C968 D0EF CC68 D17F
It is the mind that moves
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Dynamic views/permissions
@ 2003-05-30 20:35 Ian Barwick <barwick@gmx.net>
parent: Raj Mathur <raju@linux-delhi.org>
0 siblings, 0 replies; 2+ messages in thread
From: Ian Barwick @ 2003-05-30 20:35 UTC (permalink / raw)
To: Raj Mathur <raju@linux-delhi.org>; 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@gmx.net
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-05-30 20:35 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-05-30 19:31 Dynamic views/permissions Raj Mathur <raju@linux-delhi.org>
2003-05-30 20:35 ` Ian Barwick <barwick@gmx.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox