Rules not executed on child tables
Rules not executed on child tables
От:
<depstein@alliedtesting.com>
Дата:
Hi,
I noticed that when an action is executed on a parent table, rules for that=
action that are defined on its child tables are ignored.
Example:
create table A (ind integer);
create table B () inherits (A);
CREATE OR REPLACE RULE B_delete_rule AS
ON DELETE TO B DO INSTEAD NOTHING;
insert into B values(0);
delete from B;
-- Query returned successfully: 0 rows affected, 0 ms execution time.
-- This is what I expected
delete from A;
-- Query returned successfully: 1 row affected, 0 ms execution time.
-- This is NOT what I expected!
I am using PostgreSQL 8.4.1 on Windows XP ProRe: Rules not executed on child tables
От:
Robert Haas <robertmhaas@gmail.com>
Дата:
On Wed, Aug 18, 2010 at 5:36 AM, wrote: > I noticed that when an action is executed on a parent table, rules for that > action that are defined on its child tables are ignored. I think this is actually design behavior. It's really hard to use rules for anything useful (other than views); you might want to look at triggers instead. Rules are basically a crude query-rewrite system. The rule rewriting process doesn't understand anything about what your query is actually trying to do; it's just analyzing the syntax (where, of course, the child tables aren't mentioned). -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise Postgres Company