X-Original-To: pgsql-sql@postgresql.org Received: from localhost (developer.postgresql.org [64.117.224.193]) by developer.postgresql.org (Postfix) with ESMTP id 9B2529257D5 for ; Fri, 30 May 2003 16:36:56 -0400 (EDT) Received: from developer.postgresql.org ([64.117.224.193]) by localhost (developer.postgresql.org [64.117.224.193:10024]) (amavisd-new) with ESMTP id 07263-02 for ; Fri, 30 May 2003 16:36:53 -0400 (EDT) Received: from post.webmailer.de (natsmtp01.webmailer.de [192.67.198.81]) by developer.postgresql.org (Postfix) with ESMTP id 97206925D25 for ; Fri, 30 May 2003 16:36:52 -0400 (EDT) Received: from iwate.ianb.homelinux.net (pD95174B5.dip.t-dialin.net [217.81.116.181]) by post.webmailer.de (8.12.8/8.8.7) with ESMTP id h4UKafQJ012440; Fri, 30 May 2003 22:36:42 +0200 (MEST) From: Ian Barwick To: Raj Mathur , pgsql-sql@postgresql.org Subject: Re: Dynamic views/permissions Date: Fri, 30 May 2003 22:35:48 +0200 User-Agent: KMail/1.5.1 References: <16087.45449.309496.281238@mail.linux-delhi.org> In-Reply-To: <16087.45449.309496.281238@mail.linux-delhi.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200305302235.48653.barwick@gmx.net> X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/580 X-Sequence-Number: 13745 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 ...] > > 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