Skip to content

Commit

Permalink
Manually set LANG=C when running pg_controldata. (#27)
Browse files Browse the repository at this point in the history
We parse the output of pg_controldata and expect English output. Force the
environment to be in C locale when calling pg_controldata so that we do not
depend on the user locale settings here.

The other output parsing we do is on pg_ctl --version, where we only parse
the version string. As that's only digits and dots ([[:digit:].]+), we don't
need to set the LANG=C in that case. I think. At least this patch does
nothing for this case.

Fix #26.
  • Loading branch information
DimCitus committed Jun 20, 2019
1 parent 37a295a commit 3fd5432
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/bin/pg_autoctl/pgctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ pg_controldata(PostgresSetup *pgSetup, bool missing_ok)
path_in_same_directory(pgSetup->pg_ctl, "pg_controldata", pg_controldata);
log_debug("%s %s", pg_controldata, pgSetup->pgdata);

/* we parse the output of pg_controldata, make sure it's as expected */
setenv("LANG", "C", 1);
prog = run_program(pg_controldata, pgSetup->pgdata, NULL);

if (prog.returnCode == 0)
Expand Down

0 comments on commit 3fd5432

Please sign in to comment.