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

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: (view raw, whole thread or download thread mbox)
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


pgsql-bugs by date

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

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