Thread: Defining dedicated macro to grab a relation's persistence
Hi all, After looking at a patch of this commit fest using rd_rel->relpersistence, I got a look at how many times this expression was being used directly in the backend code and wondered if it would not be useful to add a dedicated macro in rel.h to get the persistence of a relation like in the patch attached. (Note: it is actually used 39 times). Thoughts? -- Michael
Attachment
Hi, On 2014-11-07 22:08:33 +0900, Michael Paquier wrote: > After looking at a patch of this commit fest using > rd_rel->relpersistence, I got a look at how many times this expression > was being used directly in the backend code and wondered if it would > not be useful to add a dedicated macro in rel.h to get the persistence > of a relation like in the patch attached. (Note: it is actually used > 39 times). I personally find the direct access actually more readable, so I'm not a fan of further extending the scheme. Consistency with some other common accessors is an argument though. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services
<div dir="ltr"><div class="gmail_extra">On Fri, Nov 7, 2014 at 11:12 AM, Andres Freund <<a href="mailto:andres@2ndquadrant.com">andres@2ndquadrant.com</a>>wrote:<br />><br />> Hi,<br />><br />> On2014-11-07 22:08:33 +0900, Michael Paquier wrote:<br />> > After looking at a patch of this commit fest using<br/>> > rd_rel->relpersistence, I got a look at how many times this expression<br />> > was being useddirectly in the backend code and wondered if it would<br />> > not be useful to add a dedicated macro in rel.hto get the persistence<br />> > of a relation like in the patch attached. (Note: it is actually used<br />>> 39 times).<br />><br />> I personally find the direct access actually more readable, so I'm not a<br />>fan of further extending the scheme. Consistency with some other common<br />> accessors is an argument though.<br/>><br /><br /></div><div class="gmail_extra">What you meant is "relation->rd_rel->relpersistence" ismore readable than "RelationGetPersistence(relation)" ??<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">http://www.timbira.com.br</a><br/>>> Blog: <a href="http://fabriziomello.github.io">http://fabriziomello.github.io</a><br/>>> Linkedin: <a href="http://br.linkedin.com/in/fabriziomello">http://br.linkedin.com/in/fabriziomello</a><br/>>> Twitter: <a href="http://twitter.com/fabriziomello">http://twitter.com/fabriziomello</a><br/>>> Github: <a href="http://github.com/fabriziomello">http://github.com/fabriziomello</a></div></div>
Fabrízio de Royes Mello wrote: > On Fri, Nov 7, 2014 at 11:12 AM, Andres Freund <andres@2ndquadrant.com> > wrote: > > I personally find the direct access actually more readable, so I'm not a > > fan of further extending the scheme. Consistency with some other common > > accessors is an argument though. > > What you meant is "relation->rd_rel->relpersistence" is more readable than > "RelationGetPersistence(relation)" ?? I too have a hard time getting excited about this change. I'd just leave it alone. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services