Skip site navigation (1) Skip section navigation (2)

Re: Rules with Conditions: Bug, or Misunderstanding

From: "Joel Burton" <jburton(at)scw(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: Rules with Conditions: Bug, or Misunderstanding
Date: 2000-12-01 21:03:46
Message-ID: 3A27CBE2.20547.491631@localhost (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-sql
On 29 Nov 2000, at 19:42, Tom Lane wrote:

> "Joel Burton" <jburton(at)scw(dot)org> writes:
> > create rule dev_ins as on update to dev_col_comments where 
> > old.description isnull do instead insert into pg_description (
> > objoid, description) values (old.att_oid, new.description);
> 
> > create rule dev_upd as on update to dev_col_comments where 
> > old.description notnull do instead update pg_description set 
> > description=new.description where objoid=old.att_oid;
> 
> > This doesn't work: I get a "cannot update view w/o rule" error
> > message, both for fields where description was null, and for fields
> > where it wasn't null.
> 

> [... ] I think this will work:
> 
> create rule dev_upd as on update to dev_col_comments do instead
> (
>   insert into pg_description (objoid, description)
>     select old.att_oid, new.description WHERE old.description isnull;
>   update pg_description set description=new.description
>     where objoid = old.att_oid;
> )

Tom --

Thanks for the help. I had assumed (wrongly) that one could have 
conditional rules, and only if all the conditions fail, that it would go 
to the "cannot update view" end, and didn't realize that there 
*had* to be a single do instead.

In any event, though, the rule above crashes my backend, as do 
simpler versions I wrote that try your CREATE RULE DO INSTEAD ( 
INSERT; UPDATE; ) idea.

What information can I provide to the list to troubleshoot this?

Thanks!


--
Joel Burton, Director of Information Systems -*- jburton(at)scw(dot)org
Support Center of Washington (www.scw.org)

In response to

Responses

pgsql-hackers by date

Next:From: Don BaccusDate: 2000-12-01 21:28:10
Subject: Re: beta testing version
Previous:From: Nathan MyersDate: 2000-12-01 20:56:06
Subject: Re: beta testing version

pgsql-sql by date

Next:From: Tom LaneDate: 2000-12-01 22:07:42
Subject: Re: Rules with Conditions: Bug, or Misunderstanding
Previous:From: Tom LaneDate: 2000-12-01 15:21:44
Subject: Re: arhiving rule

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group