Re: Incorrect initialization of sentPtr in walsender.c - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Incorrect initialization of sentPtr in walsender.c
Date
Msg-id 5412A6FF.6030008@vmware.com
Whole thread Raw
In response to Re: Incorrect initialization of sentPtr in walsender.c  (Michael Paquier <michael.paquier@gmail.com>)
Responses Re: Incorrect initialization of sentPtr in walsender.c  (Michael Paquier <michael.paquier@gmail.com>)
List pgsql-hackers
On 09/12/2014 03:17 AM, Michael Paquier wrote:
> On Fri, Sep 12, 2014 at 9:08 AM, Michael Paquier
> <michael.paquier@gmail.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




pgsql-hackers by date:

Previous
From: Etsuro Fujita
Date:
Subject: Re: inherit support for foreign tables
Next
From: Dilip kumar
Date:
Subject: Re: pg_basebackup vs. Windows and tablespaces