pgsql: Fix incorrect ordering of operations in pg_resetwal and pg_rewin

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix incorrect ordering of operations in pg_resetwal and pg_rewin
Date: 2018-05-23 15:00:02
Message-ID: E1fLVFC-0003AG-WA@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix incorrect ordering of operations in pg_resetwal and pg_rewind.

Commit c37b3d08c dropped its added GetDataDirectoryCreatePerm call into
the wrong place in pg_resetwal.c, namely after the chdir to DataDir.
That broke invocations using a relative path, as reported by Tushar Ahuja.
We could have left it where it was and changed the argument to be ".",
but that'd result in a rather confusing error message in event of a
failure, so re-ordering seems like a better solution.

Similarly reorder operations in pg_rewind.c. The issue there is that
it doesn't seem like a good idea to do any actual operations before the
not-root check (on Unix) or the restricted token acquisition (on Windows).
I don't know that this is an actual bug, but I'm definitely not convinced
that it isn't, either.

Assorted other code review for c37b3d08c and da9b580d8: fix some
misspelled or otherwise badly worded comments, put the #include for
<sys/stat.h> where it actually belongs, etc.

Discussion: https://postgr.es/m/aeb9c3a7-3c3f-a57f-1a18-c8d4fcdc2a1f@enterprisedb.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1d96c1b91a4b7da6288ee63671a234b557ff5ccf

Modified Files
--------------
src/backend/storage/file/fd.c | 8 ++++----
src/backend/utils/init/globals.c | 4 +---
src/bin/pg_resetwal/pg_resetwal.c | 14 +++++++-------
src/bin/pg_rewind/pg_rewind.c | 20 ++++++++++----------
src/common/file_perm.c | 3 +--
src/include/common/file_perm.h | 4 +++-
6 files changed, 26 insertions(+), 27 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2018-05-23 18:20:16 pgsql: Remove configure's check for nonstandard "long long" printf modi
Previous Message Heikki Linnakangas 2018-05-23 07:24:32 pgsql: Accept "B" in all memory-unit GUCs, and improve error messages.