Re: BUG #14999: pg_rewind corrupts control file global/pg_control - Mailing list pgsql-bugs

From Michael Paquier
Subject Re: BUG #14999: pg_rewind corrupts control file global/pg_control
Date
Msg-id 20180305075431.GH2266@paquier.xyz
Whole thread Raw
In response to Re: BUG #14999: pg_rewind corrupts control file global/pg_control  (Dmitry Dolgov <9erthalion6@gmail.com>)
Responses Re: BUG #14999: pg_rewind corrupts control file global/pg_control  (Masahiko Sawada <sawada.mshk@gmail.com>)
List pgsql-bugs
On Fri, Mar 02, 2018 at 04:35:07PM +0100, Dmitry Dolgov wrote:
> It maybe a stupid question, but why do you need to reset errno here? Is it to
> avoid its value being carried from previous calls of `open_target_file`? In
> this case if you put the code with `errno == EACCESS` under the if condition
> `if (dstfd < 0)`, then as far as I remember you should always get relevant
> errno. At the same time maybe it's valid to reset `errno` before `open`, like
> with `getpriority`:

[ ... reads and feels stupid ...]

Of course all the checks should be where dstno is negative...

I have done a second pass on the patch, and attached is a new version.
This fixes this handling of errno and addresses some typos.  I have also
fixed the test case where one of the read-only files was not properly
switched to do so.  I have also added a commit log message.
--
Michael

Attachment

pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: BUG #15096: Unable to CREATE TABLE LIKE with bigint identitycolumn
Next
From: Masahiko Sawada
Date:
Subject: Re: BUG #14999: pg_rewind corrupts control file global/pg_control