Thread: Delete rules

Delete rules

From
"Little, Douglas"
Date:
<div class="WordSection1"><p class="MsoNormal">Hi,<p class="MsoNormal">We’d like to give our applications truncate
capability,but that would also give them drop table permission, which we don’t want them to have.<p
class="MsoNormal">So,we created a truncate function that uses the definers security context.<p class="MsoNormal"> <p
class="MsoNormal">Theissue is that we now have 1000’s of programs to change to use the function.  A task the developers
don’twant to do. <p class="MsoNormal"> <p class="MsoNormal">So,  we’re investigating using a DELETE rule.  I’d like to
beable to rewrite   an unqualified delete into a the call to the truncate function otherwise, leave it alone.<p
class="MsoNormal"> <pclass="MsoNormal">But I don’t know how to access the entire sql statement for interrogation.   <p
class="MsoNormal">Isthere a way I can see what the statement is that’s executing and triggering the rule?<p
class="MsoNormal"> <pclass="MsoNormal">Thanks<p class="MsoNormal"> <p class="MsoNormal"> <p class="MsoNormal"><b><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">DougLittle</span></b><p class="MsoNormal"><b><span
style="font-size:12.0pt"> </span></b><pclass="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif"">Sr.Data Warehouse Architect | Enterprise Data Management |
OrbitzWorldwide </span><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">500 W.
Madison,Suite 1000  Chicago IL 60661| Office 312.260.2588 | Fax 312.894.5164 | Cell 847-997-5741</span><span
style="font-size:12.0pt;
font-family:"Times New Roman","serif""></span><p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif""><ahref="mailto:Douglas.Little@orbitz.com"
title="mailto:dlittle@orbitz.com"><b><spanstyle="color:blue">Douglas.Little@orbitz.com</span></b></a></span><b><u><span
style="font-size:13.5pt;font-family:"TimesNew Roman","serif";color:blue"></span></u></b><p class="MsoNormal"> <img
alt="cid:image001.jpg@01CABEC8.D4980670"border="0" height="61" id="Picture_x0020_1"
src="cid:image001.jpg@01CB33E9.35FEAAF0"width="83" />  <a href="http://www.orbitz.com/"
title="http://www.orbitz.com/"><spanstyle="font-size:8.0pt;font-family:"Arial","sans-serif"; 
color:blue">orbitz.com</span></a> <span style="color:blue">|</span> <a href="http://www.ebookers.com/"
title="http://www.ebookers.com/"><span
style="font-size:8.0pt;font-family:"Arial","sans-serif";color:blue">ebookers.com</span></a><span
style="color:blue">|</span><a href="http://www.hotelclub.com/" title="http://www.hotelclub.com/"><span
style="font-size:8.0pt;font-family:
"Arial","sans-serif";color:blue">hotelclub.com</span></a> <span style="color:blue">|</span> <a
href="http://www.cheaptickets.com/"title="http://www.cheaptickets.com/"><span style="font-size:8.0pt;font-family: 
"Arial","sans-serif";color:blue">cheaptickets.com</span></a> <span style="color:blue">|</span> <a
href="http://www.ratestogo.com/"title="http://www.ratestogo.com/"><span style="font-size:8.0pt;font-family: 
"Arial","sans-serif";color:blue">ratestogo.com</span></a><span style="color:blue"> |</span> <a
href="http://www.asiahotels.com/"title="http://www.asiahotels.com/"><span style="font-size:8.0pt;font-family: 
"Arial","sans-serif";color:blue">asiahotels.com</span></a><p class="MsoNormal"> </div>

Re: Delete rules

From
Richard Broersma
Date:
On Wed, Aug 4, 2010 at 1:25 PM, Little, Douglas <DOUGLAS.LITTLE@orbitz.com> wrote:
 

But I don’t know how to access the entire sql statement for interrogation.   Is there a way I can see what the statement is that’s executing and triggering the rule?


I've found complex and simple rules pretty hard to get correct.  They sometimes do unexpected things.

It looks like the CREATE Trigger  FOR EACH STATEMENT is better suited to do what you want:

"In addition, triggers may be defined to fire for a TRUNCATE, though only FOR EACH STATEMENT."

--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug