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

BUG #4808: Rules on system catalogs are allowed but not executed.

From: "Ian Turner" <ian(dot)turner(at)deshaw(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #4808: Rules on system catalogs are allowed but not executed.
Date: 2009-05-12 23:21:31
Message-ID: 200905122321.n4CNLVGx084870@wwwmaster.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      4808
Logged by:          Ian Turner
Email address:      ian(dot)turner(at)deshaw(dot)com
PostgreSQL version: 8.3.6
Operating system:   Ubuntu 8.10
Description:        Rules on system catalogs are allowed but not executed.
Details: 

It appears that (unlike with triggers), PostgreSQL will accept the creation
of rules on system catalogs, but these rules are not actually executed.
Consider this example:

testdb=# select rulename from pg_rules where rulename = 'badrule';
select rulename from pg_rules where rulename = 'badrule';
 rulename
----------
(0 rows)

testdb=# create rule badrule as on insert to pg_class do also notify
changemaster;
create rule badrule as on insert to pg_class do also notify changemaster;
CREATE RULE
testdb=# select rulename from pg_rules where rulename = 'badrule'; select
rulename from pg_rules where rulename = 'badrule';
 rulename
----------
 badrule
(1 row)

testdb=# listen changemaster;
listen changemaster;
LISTEN
testdb=# notify changemaster;
notify changemaster;
NOTIFY
Asynchronous notification "changemaster" received from server process with
PID 30010.
testdb=# select relname from pg_class where relname = 'testtable';
select relname from pg_class where relname = 'testtable';
 relname
---------
(0 rows)

testdb=# create table testtable ();
create table testtable ();
CREATE TABLE
testdb=# -- Note no notification received.
testdb=# select relname from pg_class where relname = 'testtable';
select relname from pg_class where relname = 'testtable';
  relname
-----------
 testtable
(1 row)

I would suggest blocking this kind of rule in the same way that triggers are
blocked:

testdb=# CREATE TRIGGER test_trigger
testdb-#        BEFORE INSERT OR UPDATE on pg_class
testdb-#        FOR EACH ROW EXECUTE PROCEDURE test_trigger();
CREATE TRIGGER test_trigger
       BEFORE INSERT OR UPDATE on pg_class
       FOR EACH ROW EXECUTE PROCEDURE test_trigger();
ERROR:  permission denied: "pg_class" is a system catalog

Responses

pgsql-bugs by date

Next:From: Jörg KiegelandDate: 2009-05-13 08:25:26
Subject: Re: BUG #4806: Bug with GiST index and empty integer array?
Previous:From: jesusDate: 2009-05-12 22:34:42
Subject: BUG #4807: problema para bd

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