Re: conditional rule not applied - Mailing list pgsql-general

From Seb
Subject Re: conditional rule not applied
Date
Msg-id 87iqbfnpzv.fsf@kolob.sebmags.homelinux.org
Whole thread Raw
In response to conditional rule not applied  (Seb <spluque@gmail.com>)
List pgsql-general
On Wed, 06 Jan 2010 09:39:45 -0600,
Seb <spluque@gmail.com> wrote:

> Would this express the intention any better?

> CREATE RULE footwear_nothing_upd AS
>     ON UPDATE TO footwear DO INSTEAD NOTHING;
> CREATE RULE footwear_newshoelaces_upd AS
>     ON UPDATE TO footwear
>     WHERE NOT EXISTS (SELECT sh_id FROM shoelaces WHERE NEW.sh_id=shoelaces.sh_id)
>     DO
> INSERT INTO shoelaces (sh_id, sl_name)
>     VALUES(NEW.sh_id, NEW.sl_name);

Adding to my confusion here, is the fact that the rule above seems to
work well, even though the docs say:

---<--------------------cut here---------------start------------------->---
condition

 Any SQL conditional expression (returning boolean). The condition
 expression cannot refer to any tables except NEW and OLD, and cannot
 contain aggregate functions.
---<--------------------cut here---------------end--------------------->---

So the WHERE condition in the rule above should not be allowed since it
does reference a table other than NEW and OLD in the EXISTS statement.
Any enlightening comments appreciated.


--
Seb

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Minimizing disk space
Next
From: "Joshua D. Drake"
Date:
Subject: Re: Minimizing disk space