Re: [GSoC2014] Patch ALTER TABLE ... SET LOGGED - Mailing list pgsql-hackers
From | Fabrízio de Royes Mello |
---|---|
Subject | Re: [GSoC2014] Patch ALTER TABLE ... SET LOGGED |
Date | |
Msg-id | CAFcNs+o_20mSQRjgQB7+rRU6W0wYPPYQjJQfdENT2HHnSznsew@mail.gmail.com Whole thread Raw |
In response to | Re: [GSoC2014] Patch ALTER TABLE ... SET LOGGED (Andres Freund <andres@2ndquadrant.com>) |
Responses |
Re: [GSoC2014] Patch ALTER TABLE ... SET LOGGED
|
List | pgsql-hackers |
<div dir="ltr"><div class="gmail_extra"><br /><br />On Thu, Jul 17, 2014 at 8:02 PM, Andres Freund <<a href="mailto:andres@2ndquadrant.com"target="_blank">andres@2ndquadrant.com</a>> wrote:<br />><br />> > That meansshould I "FlushRelationBuffers(rel)" before change the<br /> > > relpersistence?<br />><br />> I don't thinkthat'd help. I think what this means that you simply<br />> cannot change the relpersistence of the old relationbefore the heap<br />> swap is successful. So I guess it has to be something like (pseudocode):<br /> ><br/>> OIDNewHeap = make_new_heap(..);<br />> newrel = heap_open(OIDNewHeap, AEL);<br />><br />> /*<br />> * Change the temporary relation to be unlogged/logged. We have to do<br />> * that here so buffers for the newrelfilenode will have the right<br /> > * persistency set while the original filenode's buffers won't get read<br/>> * in with the wrong (i.e. new) persistency setting. Otherwise a<br />> * rollback after the rewrite wouldpossibly result with buffers for the<br /> > * original filenode having the wrong persistency setting.<br />> *<br />> * NB: This relies on swap_relation_files() also swapping the<br />> * persistency. That wouldn'twork for pg_class, but that can't be<br /> > * unlogged anyway.<br />> */<br />> AlterTableChangeCatalogToLoggedOrUnlogged(newrel);<br/>> FlushRelationBuffers(newrel);<br />> /* copy heap data intonewrel */<br />> finish_heap_swap();<br />><br />> And then in swap_relation_files() also copy the persistency.<br/> ><br />><br />> That's the best I can come up right now at least.<br />><br /><br /></div><divclass="gmail_extra">Isn't better if we can set the relpersistence as an argument to "make_new_heap" ?<br /><br/></div><div class="gmail_extra">I'm thinking to change the make_new_heap:<br /></div><div class="gmail_extra"><br /></div><divclass="gmail_extra">From: <br /></div><div class="gmail_extra"><br /> make_new_heap(Oid OIDOldHeap, Oid NewTableSpace,bool forcetemp,<br /> LOCKMODE lockmode)<br /><br /></div><div class="gmail_extra">To:<br /><br/> make_new_heap(Oid OIDOldHeap, Oid NewTableSpace, char relpersistence,<br /> LOCKMODE lockmode)<br /><br/></div><div class="gmail_extra"> That way we can create the new heap with the appropriate relpersistence, so in theswap_relation_files also copy the persistency, of course.<br /></div><div class="gmail_extra"><br /></div><div class="gmail_extra">Andafter copy the heap data to the new table (ATRewriteTable) change relpersistence of the OldHeap'sindexes, because in the "finish_heap_swap" they'll be rebuild.<br /></div><div class="gmail_extra"><br /></div><divclass="gmail_extra">Thoughts?<br /></div><div class="gmail_extra"><br /></div><div class="gmail_extra">Regards,<br/><br /></div><div class="gmail_extra">--<br />Fabrízio de Royes Mello<br /> Consultoria/CoachingPostgreSQL<br />>> Timbira: <a href="http://www.timbira.com.br" target="_blank">http://www.timbira.com.br</a><br/>>> Blog sobre TI: <a href="http://fabriziomello.blogspot.com" target="_blank">http://fabriziomello.blogspot.com</a><br/> >> Perfil Linkedin: <a href="http://br.linkedin.com/in/fabriziomello"target="_blank">http://br.linkedin.com/in/fabriziomello</a><br />>> Twitter:<a href="http://twitter.com/fabriziomello" target="_blank">http://twitter.com/fabriziomello</a></div></div>
pgsql-hackers by date: