TRIGGER or RULE for SELECT - Mailing list pgsql-hackers

From Melvin Davidson
Subject TRIGGER or RULE for SELECT
Date
Msg-id 5CA4D07E8D52ED4AB5499CA4E0898581146303C3F9@star2.corp.trenstar.net
Whole thread Raw
List pgsql-hackers

Currently, there is a limitation in PostgreSQL that any ON SELECT RULE must be an unconditional SELECT action that is INSTEAD.

 

The reasoning is “This restriction was required to make rules safe enough to open them for ordinary users, and it restricts ON SELECT rules to act like views.”

 

I cannot understand the logic behind this, as RULES are created by DBA’s. Besides, going by that logic, a user could create a RULE like
 
CREATE RULE silly AS ON SELECT 
    TO table_a   DO INSTEAD  SELECT * FROM table_b. 
 
Not to mention, an INSERT, UPDATE, or DELETE rule is potentially much more dangerous.
eg: ON INSERT DO INSTEAD SELECT function_to_delete();
 
Is that safe? Furthermore, it would be more beneficial to allow DO ALSO, so that an audit function could be invoked.  
 
Likewise, the same applies to TRIGGERS. ON SELECT should also be an option there for the same reason.
 
Is there some way that modifying the CREATE RULE for SELECT, and/or TRIGGER could be presented to the developers?
 
Thanks in advance,
Melvin Davidson.

 

pgsql-hackers by date:

Previous
From: Tom Raney
Date:
Subject: Re: Plan targetlists in EXPLAIN output
Next
From: Decibel!
Date:
Subject: Re: Backend Stats Enhancement Request