Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1d863c2

Browse files
committed
pg_resetwal: Improve error with wrong/missing data directory
Run chdir() before permission check to get a less confusing error message if the specified data directory does not exist. Reviewed-by: Aleksander Alekseev <aleksander@timescale.com> Discussion: https://www.postgresql.org/message-id/flat/0f3ab4a1-ae80-56e8-3426-6b4a02507687@eisentraut.org
1 parent 7273945 commit 1d863c2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/bin/pg_resetwal/pg_resetwal.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -345,17 +345,17 @@ main(int argc, char *argv[])
345345

346346
get_restricted_token();
347347

348+
if (chdir(DataDir) < 0)
349+
pg_fatal("could not change directory to \"%s\": %m",
350+
DataDir);
351+
348352
/* Set mask based on PGDATA permissions */
349353
if (!GetDataDirectoryCreatePerm(DataDir))
350354
pg_fatal("could not read permissions of directory \"%s\": %m",
351355
DataDir);
352356

353357
umask(pg_mode_mask);
354358

355-
if (chdir(DataDir) < 0)
356-
pg_fatal("could not change directory to \"%s\": %m",
357-
DataDir);
358-
359359
/* Check that data directory matches our server version */
360360
CheckDataVersion();
361361

0 commit comments

Comments
 (0)