pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joel Burton <jburton@scw.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@postgresql.org
Cc: pgsql-sql@postgresql.org
Subject: Re: Rules with Conditions: Bug, or Misunderstanding
Date: Fri, 1 Dec 2000 16:03:46 -0500
Message-ID: <3A27CBE2.20547.491631@localhost> (raw)
In-Reply-To: <19579.975544973@sss.pgh.pa.us>
References: <3A255246.21430.688927F3@localhost>

On 29 Nov 2000, at 19:42, Tom Lane wrote:

> "Joel Burton" <jburton@scw.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@scw.org
Support Center of Washington (www.scw.org)



view thread (11+ messages)  latest in thread

Message-ID: <3A27CBE2.20547.491631@localhost>
Permalink:  ../3A27CBE2.20547.491631@localhost/
Also on:    postgresql.org/message-id/3A27CBE2.20547.491631@localhost

 · 

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 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-sql@postgresql.org
  Cc: jburton@scw.org, tgl@sss.pgh.pa.us, pgsql-hackers@postgresql.org
  Subject: Re: Rules with Conditions: Bug, or Misunderstanding
  In-Reply-To: <3A27CBE2.20547.491631@localhost>
  References: <3A255246.21430.688927F3@localhost> <3A27CBE2.20547.491631@localhost>

* 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