questions about ON SELECT rules

Lists: pgsql-hackers
From: Zhaomo Yang <zhaomoya(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: questions about ON SELECT rules
Date: 2013-01-23 07:44:16
Message-ID: CAOG7Ad1vpexaeM7MNZ4sr-3A8MXf5jrsi42AX1uXaDg65pxJJw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi folks,

I'm working on a project where I need to run some commands/functions when
SELECT are executed on certain tables. I looked at the rule system and
found the following paragraph in the documentation:

"Currently, there can be only one action in an ON SELECT rule, and it
must be an unconditional SELECT action that is INSTEAD. 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."

These restrictions make it impossible to implement what I need using the
rule system. I'm think about tweaking how rule statement is executed to
lift some restrictions (more actions, other type actions, etc.) but not
sure what impacts this will introduce into the whole system. Why are rules
not safe when these restrictions are removed?

Thanks,
Zhaomo