Re: small typo in src/backend/access/transam/xlog.c - Mailing list pgsql-hackers

From Andres Freund
Subject Re: small typo in src/backend/access/transam/xlog.c
Date
Msg-id 20130722200159.GD752@alap2.anarazel.de
Whole thread Raw
In response to Re: small typo in src/backend/access/transam/xlog.c  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: small typo in src/backend/access/transam/xlog.c
List pgsql-hackers
On 2013-07-22 15:55:46 -0400, Robert Haas wrote:
> On Mon, Jul 22, 2013 at 6:45 AM, didier <did447@gmail.com> wrote:
> > Hi
> >
> > in void
> > BootStrapXLOG(void)
> >
> >       * to seed it other than the system clock value...)  The upper half of
> > the
> >          * uint64 value is just the tv_sec part, while the lower half is the
> > XOR
> >          * of tv_sec and tv_usec.  This is to ensure that we don't lose
> > uniqueness
> >          * unnecessarily if "uint64" is really only 32 bits wide.  A person
> >          * knowing this encoding can determine the initialization time of
> > the
> >          * installation, which could perhaps be useful sometimes.
> >          */
> >         gettimeofday(&tv, NULL);
> >         sysidentifier = ((uint64) tv.tv_sec) << 32;
> >         sysidentifier |= (uint32) (tv.tv_sec | tv.tv_usec);
> >
> > should be
> >         sysidentifier |= (uint32) (tv.tv_sec ^ tv.tv_usec);
> 
> And why is that?

The comment above tells: "while the lower half is the XOR of tv_sec and
tv_usec."

I don't think it really matters. the bitwise OR has the tenency to
collect too many set bits, but ... who cares?
On the other hand, changing it is easy and shouldn't cause any problems.

Greetings,

Andres Freund

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



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: small typo in src/backend/access/transam/xlog.c
Next
From: Peter Eisentraut
Date:
Subject: Re: enum-ify resource manager's xl_info values