TRIGGER or RULE for SELECT
От | Melvin Davidson |
---|---|
Тема | TRIGGER or RULE for SELECT |
Дата | |
Msg-id | 5CA4D07E8D52ED4AB5499CA4E0898581146303C3F9@star2.corp.trenstar.net обсуждение исходный текст |
Список | pgsql-hackers |
<div class="Section1"><p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Currently, there is a limitationin PostgreSQL that any ON SELECT RULE</span><span style="font-family:"Arial","sans-serif""> must be an unconditional<tt><span style="font-family:"Arial","sans-serif"">SELECT</span></tt> action that is <tt><span style="font-family:"Arial","sans-serif"">INSTEAD.</span></tt></span><pclass="MsoNormal"><tt><span style="font-family:"Arial","sans-serif""> </span></tt><pclass="MsoNormal"><tt><span style="font-family:"Arial","sans-serif"">Thereasoning is “</span></tt><span style="font-family:"Arial","sans-serif"">Thisrestriction was required to make rules safe enough to open them for ordinaryusers, and it restricts <tt><span style="font-family:"Arial","sans-serif"">ON SELECT</span></tt> rules to act likeviews.”</span><p class="MsoNormal"><tt><span style="font-family:"Arial","sans-serif""> </span></tt><pre><tt><span style="font-size:11.0pt;font-family:"Arial","sans-serif"">Icannot understand the logic behind this, as RULES are createdby DBA’s. Besides, going by that logic, a user could create a RULE like</span></tt></pre><pre><tt><span style="font-size:11.0pt;font-family:"Arial","sans-serif""> </span></tt></pre><pre><tt><span style="font-size:11.0pt;font-family:"Arial","sans-serif"">CREATERULE silly </span></tt><span style="font-size:11.0pt;font-family:"Arial","sans-serif"">ASON <tt><i><span style="font-family:"Arial","sans-serif"">SE</span></i></tt><tt><spanstyle="font-family:"Arial","sans-serif"">LECT </span></tt></span></pre><pre><spanstyle="font-size:11.0pt;font-family:"Arial","sans-serif""> TO <tt><span style="font-family:"Arial","sans-serif"">table_a</span></tt> DO INSTEAD SELECT * FROM table_b. </span></pre><pre><spanstyle="font-size:11.0pt;font-family:"Arial","sans-serif""> </span></pre><pre><span style="font-size:11.0pt;font-family:"Arial","sans-serif"">Notto mention, an INSERT, UPDATE, or DELETE rule is potentiallymuch more dangerous.</span></pre><pre><span style="font-size:11.0pt;font-family:"Arial","sans-serif"">eg: ON INSERTDO INSTEAD SELECT function_to_delete();</span></pre><pre><span style="font-size:11.0pt;font-family:"Arial","sans-serif""> </span></pre><pre><span style="font-size:11.0pt;font-family:"Arial","sans-serif"">Isthat safe? </span><tt><span style="font-size:11.0pt;font-family:"Arial","sans-serif"">Furthermore,it would be more beneficial to allow DO ALSO, so thatan audit function could be invoked. </span></tt></pre><pre><tt><span style="font-size:11.0pt;font-family:"Arial","sans-serif""> </span></tt></pre><pre><tt><span style="font-size:11.0pt;font-family:"Arial","sans-serif"">Likewise,the same applies to TRIGGERS. ON SELECT should also bean option there for the same reason.</span></tt></pre><pre><tt><span style="font-size:11.0pt;font-family:"Arial","sans-serif""> </span></tt></pre><pre><tt><span style="font-size:11.0pt;font-family:"Arial","sans-serif"">Isthere some way that modifying the CREATE RULE for SELECT, and/orTRIGGER could be presented to the developers?</span></tt></pre><pre><tt><span style="font-size:11.0pt;font-family:"Arial","sans-serif""> </span></tt></pre><pre><tt><span style="font-size:11.0pt;font-family:"Arial","sans-serif"">Thanksin advance,</span></tt></pre><pre><tt><span style="font-size:11.0pt;font-family:"Arial","sans-serif"">MelvinDavidson.</span></tt></pre><p class="MsoNormal"><span style="font-family:"Arial","sans-serif""> </span></div>
В списке pgsql-hackers по дате отправления: