TRIGGER or RULE for SELECT

From: Melvin Davidson <mdavidson(at)trenstar(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: TRIGGER or RULE for SELECT
Date: 2008-06-19 22:18:14
Message-ID: 5CA4D07E8D52ED4AB5499CA4E0898581146303C3F9@star2.corp.trenstar.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Raney 2008-06-19 22:20:26 Re: Plan targetlists in EXPLAIN output
Previous Message Tom Lane 2008-06-19 17:23:36 Re: tsearch is non-multibyte-aware in a few places