Re: Incorrect initialization of sentPtr in walsender.c

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Incorrect initialization of sentPtr in walsender.c
Date: 2014-09-12 07:55:43
Message-ID: 5412A6FF.6030008@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 09/12/2014 03:17 AM, Michael Paquier wrote:
> On Fri, Sep 12, 2014 at 9:08 AM, Michael Paquier
> <michael(dot)paquier(at)gmail(dot)com> wrote:
>> In walsender.c, sentPtr is initialized as follows:
>> static XLogRecPtr sentPtr = 0;
>> Isn't that incorrect and shouldn't we use InvalidXLogRecPtr instead?
> Actually by looking more around I found a couple of extra places where
> the same inconsistencies are present, mainly in xlog.c and
> walreceiver.c. Updated patch attached for all those things.

InvalidXLogRecPtr == 0, so it's just a style issue which one is more
correct.

I haven't looked at those places closely, but it seems possible that at
least some of those variables are supposed to be initialized to a value
smaller than any valid WAL position, rather than just Invalid. In other
words, if we defined InvalidXLogRecPtr as INT64_MAX rather than 0, we
would still want those variables to be initialized to zero. As I said, I
didn't check the code, but before we change those that ought to be checked.

- Heikki

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip kumar 2014-09-12 08:20:53 Re: pg_basebackup vs. Windows and tablespaces
Previous Message Etsuro Fujita 2014-09-12 07:30:26 Re: inherit support for foreign tables