Re: XLByte* usage

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: XLByte* usage
Date: 2012-12-17 22:55:11
Message-ID: 20121217225511.GA8342@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2012-12-17 13:16:47 -0500, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > On 2012-12-17 12:47:41 -0500, Tom Lane wrote:
> >> But, if the day ever comes when 64 bits doesn't seem like enough, I bet
> >> we'd move to 128-bit integers, which will surely be available on all
> >> platforms by then. So +1 for using plain comparisons --- in fact, I'd
> >> vote for running around and ripping out the macros altogether. I had
> >> already been thinking of fixing the places that are still using memset
> >> to initialize XLRecPtrs to "invalid".
>
> > I thought about that and had guessed you would be against it because it
> > would cause useless diversion of the branches? Otherwise I am all for
> > it.
>
> That's the only argument I can see against doing it --- but Heikki's
> patch was already pretty invasive in the same areas this would touch,
> so I'm thinking this won't make back-patching much worse.

I thought a while about this for while and decided its worth trying to
this before the next review round of xlogreader. Even if it causes some
breakage there. Doing it this way round seems less likely to introduce
bugs, especially if somebody else would go round and do this after the
next xlogreader review round but before committing it.

Attached is
1) removal of MemSet(&ptr, 0, sizeof(XLogRecPtr)
2) removal of XLByte(EQ|LT|LE|Advance)
3) removal of the dead NextLogPage I noticed along the way

In 2) unfortunately one has to make decision in which way to simplify
negated XLByte(LT|LE) expressions. I tried to make that choice very
careful and when over every change several times after that, so I hope
there aren't any bad changes, but more eyeballs are needed.

> The notational simplification seems worth it.

After doing this: Definitely. Imo some of the conditions are way much
easier to read now. Perhaps I am just bad in reading negations though...

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment Content-Type Size
0001-Use-InvalidXLogRecPtr-instead-of-MemSet-ptr-0-sizeof.patch text/x-patch 2.3 KB
0002-Remove-XLByte-LT-LE-EQ-and-XLByteAdvance-macros-they.patch text/x-patch 53.7 KB
0003-Remove-unused-NextLogPage-macro-in-xlog_inernal.h.patch text/x-patch 1.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marc G. Fournier 2012-12-17 23:01:41 JPA + enum == Exception
Previous Message Simon Riggs 2012-12-17 22:44:08 Re: pg_basebackup from cascading standby after timeline switch