Bug #771: rewrite rules on update or insert do not report errors

From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: Bug #771: rewrite rules on update or insert do not report errors
Date: 2002-09-17 14:05:05
Message-ID: 20020917140505.81F0B475F53@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

marc persuy (marc(dot)persuy(at)wanadoo(dot)fr) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
rewrite rules on update or insert do not report errors

Long Description
If you try to use rules to implement update and insert on views, these
rules do not report any error neither on insert nor on update action.

therefore, they are far less usefull.

Sample Code
for instance:
here is a sample table to store customers or suppliers reference.
table is shared by many users, each one having his/her own datas, defined by a view: tiers

the tiers view shows all datas from user and his/her partners, is supposed to allow update of his/her
own datas.

regrettably enough, when you try to update the tiers view, you never get any error, even
if you try to insert a record with an already existing primary key, or any undoable or forbidden operation.

-- Table: tiers_sys

CREATE TABLE tiers_sys (
num_tiers int4 DEFAULT nextval('num_Tseq'::text) NOT NULL,
owner_tag int4,
valid bool DEFAULT 't'::bool,
name varchar(100),
is_customer bool,
is_supplier bool,
country varchar(2),
dunsid varchar(13),
iban varchar(35),
vat_number varchar(20),
status varchar(5),
creation_date timestamp without time zone,
creat_user int4,
update_date timestamp without time zone,
update_user int4,
CONSTRAINT tiers_pkey PRIMARY KEY (num_tiers)
) WITH OIDS;

CREATE VIEW "tiers" AS SELECT * FROM tiers_sys
WHERE (tiers_sys.owner_tag = ANY (SELECT partners.owner_tag FROM partners));

CREATE RULE tiers_ins as on insert to tiers
DO INSTEAD insert into tiers_sys(owner_tag,
name, is_customer,is_supplier,country,dunsid,iban,vat_number,status
) values (
NEW.owner_tag, NEW.name, NEW.is_customer,NEW.is_supplier,NEW.country,
NEW.dunsid, NEW.iban, NEW.vat_number, NEW.status
);

CREATE RULE tiers_upd as on update to tiers
DO INSTEAD update tiers_sys set
valid = NEW.valid ,name = NEW.name ,
is_customer = NEW.is_customer,is_supplier = NEW.is_supplier ,
country = NEW.country,dunsid = NEW.dunsid,iban = NEW.iban ,vat_number = NEW.vat_number,status=NEW.status ,
where num_tiers = OLD.num_tiers;

No file was uploaded with this report

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2002-09-17 14:32:03 Re: Bug #771: rewrite rules on update or insert do not report errors
Previous Message Tom Lane 2002-09-17 06:07:31 Re: Postgres storing time in strange manner