From: miss <miss@flex.com.au>
To: pgsql-admin@postgresql.org
Subject: Rule - Delete or Upgrade will not work with primary key
Date: Sun, 14 Jan 2001 13:44:09 +1100
Message-ID: <3A611279.C46E2DE5@flex.com.au> (raw)
Hello there
I am using Postgres 6.5.3 on SuSE Linux 6.4
The problem is that on using rules on a view it will only work for
insert and delete - not update. Even for insert and delete to work,
read and write permission must be given the user on the parent file.
This does somewhat negate the purpose of using the view in the first
place. It is my suspicion that this is due to the primary index on the
first three fields.
CREATE TABLE plan (
date date,
period int2 DEFAULT 0,
artisan int2 DEFAULT 0,
jobnum int4,
available char(3),
PRIMARY KEY (date,period,artisan));
CREATE VIEW view_plan
AS SELECT * FROM plan;
CREATE RULE view_plan_insert AS
ON INSERT TO view_plan
DO INSTEAD
INSERT INTO plan
VALUES (
date = new.date,
period = new.period,
artisan = new.artisan,
jobnum = new.artisan,
available = new.available,);
CREATE RULE view_plan_delete AS
ON DELETE TO view_plan
DO INSTEAD
DELETE FROM plan
WHERE date = old.date
AND period = old.period
AND artisan = old.artisan;
Similarly for UPDATE
As already stated, INSERT and DELETE works OK if permission ALL is given
the user for the file "plan", but UPDATE will not. Again I make the
point of giving such permissions on the parent file negates the purpose
of using a view. Is this outcome caused by the PRIMARY KEY.
On spending further time on it I find that any primary index will give
the same result.
Yes, I have given the user permissions "arw" on the view.
Can anyone comment or advise
Regards
Max Wood
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: miss@flex.com.au
Subject: Re: Rule - Delete or Upgrade will not work with primary key
In-Reply-To: <3A611279.C46E2DE5@flex.com.au>
References: <3A611279.C46E2DE5@flex.com.au>
* 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