pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ian Barwick <barwick@gmx.net>
To: Raj Mathur <raju@linux-delhi.org>
To: pgsql-sql@postgresql.org
Subject: Re: Dynamic views/permissions
Date: Fri, 30 May 2003 22:35:48 +0200
Message-ID: <200305302235.48653.barwick@gmx.net> (raw)
In-Reply-To: <16087.45449.309496.281238@mail.linux-delhi.org>
References: <16087.45449.309496.281238@mail.linux-delhi.org>

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




view thread (2+ messages)

Message-ID: <200305302235.48653.barwick@gmx.net>
Permalink:  ../200305302235.48653.barwick@gmx.net/
Also on:    postgresql.org/message-id/200305302235.48653.barwick@gmx.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: barwick@gmx.net, raju@linux-delhi.org
  Subject: Re: Dynamic views/permissions
  In-Reply-To: <200305302235.48653.barwick@gmx.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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