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

Re: Rules with Conditions: Bug, or Misunderstanding

From: Jan Wieck <janwieck(at)Yahoo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Joel Burton <jburton(at)scw(dot)org>, pgsql-hackers(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: Rules with Conditions: Bug, or Misunderstanding
Date: 2000-12-03 23:17:48
Message-ID: 200012032317.SAA08604@jupiter.jw.home (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-sql
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.
>
> Hm.  Perhaps the "cannot update view" test is too strict --- it's not
> bright enough to realize that the two rules together cover all cases,
> so it complains that you *might* be trying to update the view.  As the
> code stands, you must provide an unconditional DO INSTEAD rule to
> implement insertion or update of a view.

    Disagree.

    A  conditional rule splits the command into two, one with the
    rules action and  the  condition  added,  one  which  is  the
    original  statement  plus the negated condition. So there are
    cases left where an INSERT can happen to  the  view  relation
    and it's the job of this test to prevent it.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck(at)Yahoo(dot)com #



In response to

Responses

pgsql-hackers by date

Next:From: mlwDate: 2000-12-03 23:18:49
Subject: Re: beta testing version
Previous:From: Gary MacDougallDate: 2000-12-03 23:15:46
Subject: Re: beta testing version

pgsql-sql by date

Next:From: Tom LaneDate: 2000-12-04 00:04:36
Subject: Re: Rules with Conditions: Bug, or Misunderstanding
Previous:From: Jan WieckDate: 2000-12-03 16:06:34
Subject: Re: problem with keyword 'old'

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