pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: Luis Sousa <llsousa@ualg.pt>
To: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: Permission on insert rules
Date: Mon, 11 Nov 2002 12:12:59 -0800
Message-ID: <200211111212.59912.josh@agliodbs.com> (raw)
In-Reply-To: <3DCBF47B.7080809@ualg.pt>
References: <3DCBF47B.7080809@ualg.pt>


Luis,

> Just a question.
> I'm writing some rules to insert/update some data in my database, and I 
> gave all the privileges on that view to the user, and only select on the 
> tables.
> When that user inserts data using the view, I thought that was user 
> postgres that will do the rest ! But I got  permission denied on those 
> tables.
> The idea was to create a layer, with the views, giving to that user 
> permission on views to insert and update, and not to tables.
> Is this possible ?

I just checked this.  It works fine in 7.2.3.

I think that you are missing a step.  If you want to have an updatable view, 
then you need to define a Rule for updating it, such as:

kitchen=# create rule update_password as on update to user_password
kitchen-# do instead update "user" set "password" = NEW."password"
kitchen-# where user_id = OLD.user_id;

See the online docs, under Server Programming, for how to use the RULES 
system.

-- 
-Josh Berkus
 Aglio Database Solutions
 San Francisco




view thread (16+ messages)  latest in thread

Message-ID: <200211111212.59912.josh@agliodbs.com>
Permalink:  ../200211111212.59912.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200211111212.59912.josh@agliodbs.com

 · 

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: josh@agliodbs.com, llsousa@ualg.pt
  Subject: Re: Permission on insert rules
  In-Reply-To: <200211111212.59912.josh@agliodbs.com>

* 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