Proposal: ON UPDATE REMOVE foreign key action - Mailing list pgsql-hackers
From | Kirill Berezin |
---|---|
Subject | Proposal: ON UPDATE REMOVE foreign key action |
Date | |
Msg-id | CAAObgf-A5=5NOjwvHsOS0SuWb+QLg2O=oF6oa3RfZ8QANd9ArQ@mail.gmail.com Whole thread Raw |
Responses |
Re: Proposal: ON UPDATE REMOVE foreign key action
(Vitaly Burovoy <vitaly.burovoy@gmail.com>)
|
List | pgsql-hackers |
<div dir="ltr"><p style="margin:0.4em 0px 0.5em;line-height:1.5em;color:rgb(0,0,0);font-family:sans-serif;font-size:12.7px"><b>One-lineSummary:</b> On foreign keyupdate we unable to remove all depended records. <span style="font-size:12.7px">Currently we have "ON REMOVE CASCADE DELETE",but no "ON UPDATE CASCADE DELETE". </span><span style="font-size:12.7px">We can only update field to NULL or DEFAULT.</span><pstyle="margin:0.4em 0px 0.5em;line-height:1.5em;color:rgb(0,0,0);font-family:sans-serif;font-size:12.7px"><spanstyle="font-size:12.7px"><br /></span><pstyle="margin:0.4em 0px 0.5em;line-height:1.5em;color:rgb(0,0,0);font-family:sans-serif;font-size:12.7px"><b>BusinessUse-case:</b> Cache expirationon hash/version update. Revoke all access on account id update.<p style="margin:0.4em 0px 0.5em;line-height:1.5em"><fontcolor="#000000" face="sans-serif"><span style="font-size:12.7px">In my case i met this situation: Iam using access links to share user account. Account owner can give private link to somebody, and its sessionbecome mirrored. (Owner access to account granted). You cant imagine facebook desktop and mobile sessions. It's justshortcut for entering credentials. Now i am implementing "revoke all </span></font><span style="font-size:12.7px;color:rgb(0,0,0);font-family:sans-serif">butme". Its done simple, since each user is uuid indexed,i am just generate new uuid for current account. Old uuid become invalid to other sessions - since no record is foundin base.<br />I want to remove any pending access links, prevent bad guy restore access.<br />I can possibly set linkedaccount to NULL, and then clear record on expiration, but i feel that automatically removing on update event is morerational.</span><p style="margin:0.4em 0px 0.5em;line-height:1.5em"><span style="font-size:12.7px;color:rgb(0,0,0);font-family:sans-serif"><br/></span><p style="margin:0.4em 0px 0.5em;line-height:1.5em;color:rgb(0,0,0);font-family:sans-serif;font-size:12.7px"><b>Userimpact with the change:</b> Insteadof writing "on update" triggers for each depended table, wished action is done by single line.<p style="margin:0.4em0px 0.5em;line-height:1.5em;color:rgb(0,0,0);font-family:sans-serif;font-size:12.7px"><b>Implementationdetails:</b> On cascadeswitch "update" action to "delete".<p style="margin:0.4em 0px 0.5em;line-height:1.5em;color:rgb(0,0,0);font-family:sans-serif;font-size:12.7px"><b>EstimatedDevelopment Time:</b> Few hoursor less.<p style="margin:0.4em 0px 0.5em;line-height:1.5em;color:rgb(0,0,0);font-family:sans-serif;font-size:12.7px"><b>OpportunityWindow Period:</b> Non applicable,minor feature<p style="margin:0.4em 0px 0.5em;line-height:1.5em;color:rgb(0,0,0);font-family:sans-serif;font-size:12.7px"><b>BudgetMoney:</b> I am ready to implementmyself, if approved.<p style="margin:0.4em 0px 0.5em;line-height:1.5em;color:rgb(0,0,0);font-family:sans-serif;font-size:12.7px"><b>ContactInformation:</b> <a href="mailto:enelar@exsul.net">enelar@exsul.net</a></div>
pgsql-hackers by date: