Re: BUG #1676: Statment order in rules

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Olleg Samoylov" <olleg(at)mipt(dot)ru>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1676: Statment order in rules
Date: 2005-05-19 15:48:33
Message-ID: 3985.1116517713@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Olleg Samoylov" <olleg(at)mipt(dot)ru> writes:
> create rule delete_first as on delete to v do instead (delete from a where
> a=old.a;update c set c=c-1);

> delete from v where a=0;
> select * from a;
> -- 0 row, as expected :-)
> select * from c;
> -- 1, this is incorrect

This isn't a bug. The DELETE causes the a=0 row to disappear from the
view, so the subsequent statement (which is implicitly conditional on
there being an a=0 row) doesn't do anything. If it did do something,
then a "delete from v" that didn't delete any rows would still decrement
c, which is not what you want, eh?

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Fuhr 2005-05-19 22:33:05 Re: BUG #1675: very slow work
Previous Message Mohan, Ross 2005-05-19 13:45:36 Re: [PORTS] Bug Report with Postgres 7.4 on AIX 5.3