Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2eeb5eb

Browse files
committed
Fix PGDATAOLD and PGDATANEW to properly set pgconfig location, per
report from Tom. Backpatch to 9.2.
1 parent 8525419 commit 2eeb5eb

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

contrib/pg_upgrade/option.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222

2323
static void usage(void);
24-
static void check_required_directory(char **dirpath,
24+
static void check_required_directory(char **dirpath, char **configpath,
2525
char *envVarName, char *cmdLineOption, char *description);
2626

2727

@@ -203,14 +203,14 @@ parseCommandLine(int argc, char *argv[])
203203
}
204204

205205
/* Get values from env if not already set */
206-
check_required_directory(&old_cluster.bindir, "PGBINOLD", "-b",
206+
check_required_directory(&old_cluster.bindir, NULL, "PGBINOLD", "-b",
207207
"old cluster binaries reside");
208-
check_required_directory(&new_cluster.bindir, "PGBINNEW", "-B",
208+
check_required_directory(&new_cluster.bindir, NULL, "PGBINNEW", "-B",
209209
"new cluster binaries reside");
210-
check_required_directory(&old_cluster.pgdata, "PGDATAOLD", "-d",
211-
"old cluster data resides");
212-
check_required_directory(&new_cluster.pgdata, "PGDATANEW", "-D",
213-
"new cluster data resides");
210+
check_required_directory(&old_cluster.pgdata, &old_cluster.pgconfig,
211+
"PGDATAOLD", "-d", "old cluster data resides");
212+
check_required_directory(&new_cluster.pgdata, &new_cluster.pgconfig,
213+
"PGDATANEW", "-D", "new cluster data resides");
214214
}
215215

216216

@@ -284,15 +284,20 @@ or\n"), old_cluster.port, new_cluster.port, os_info.user);
284284
* user hasn't provided the required directory name.
285285
*/
286286
static void
287-
check_required_directory(char **dirpath, char *envVarName,
288-
char *cmdLineOption, char *description)
287+
check_required_directory(char **dirpath, char **configpath,
288+
char *envVarName, char *cmdLineOption,
289+
char *description)
289290
{
290291
if (*dirpath == NULL || strlen(*dirpath) == 0)
291292
{
292293
const char *envVar;
293294

294295
if ((envVar = getenv(envVarName)) && strlen(envVar))
296+
{
295297
*dirpath = pg_strdup(envVar);
298+
if (configpath)
299+
*configpath = pg_strdup(envVar);
300+
}
296301
else
297302
pg_log(PG_FATAL, "You must identify the directory where the %s.\n"
298303
"Please use the %s command-line option or the %s environment variable.\n",

0 commit comments

Comments
 (0)