Skip to content

Commit c381079

Browse files
committed
In pg_upgrade, fix the -l/log option to work on Windows.
Also, double-quote the log file name in all places, to allow (on all platforms) log file names with spaces. Back patch to 9.0 and 9.1.
1 parent 1879cf3 commit c381079

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

contrib/pg_upgrade/pg_upgrade.c

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,14 @@ prepare_new_cluster(void)
193193
prep_status("Analyzing all rows in the new cluster");
194194
exec_prog(true,
195195
SYSTEMQUOTE "\"%s/vacuumdb\" --port %d --username \"%s\" "
196-
"--all --analyze >> %s 2>&1" SYSTEMQUOTE,
197-
new_cluster.bindir, new_cluster.port, os_info.user, log_opts.filename);
196+
"--all --analyze >> \"%s\" 2>&1" SYSTEMQUOTE,
197+
new_cluster.bindir, new_cluster.port, os_info.user,
198+
#ifndef WIN32
199+
log_opts.filename
200+
#else
201+
DEVNULL
202+
#endif
203+
);
198204
check_ok();
199205

200206
/*
@@ -206,8 +212,14 @@ prepare_new_cluster(void)
206212
prep_status("Freezing all rows on the new cluster");
207213
exec_prog(true,
208214
SYSTEMQUOTE "\"%s/vacuumdb\" --port %d --username \"%s\" "
209-
"--all --freeze >> %s 2>&1" SYSTEMQUOTE,
210-
new_cluster.bindir, new_cluster.port, os_info.user, log_opts.filename);
215+
"--all --freeze >> \"%s\" 2>&1" SYSTEMQUOTE,
216+
new_cluster.bindir, new_cluster.port, os_info.user,
217+
#ifndef WIN32
218+
log_opts.filename
219+
#else
220+
DEVNULL
221+
#endif
222+
);
211223
check_ok();
212224

213225
get_pg_database_relfilenode(&new_cluster);
@@ -245,7 +257,13 @@ prepare_new_databases(void)
245257
"--no-psqlrc --port %d --username \"%s\" "
246258
"-f \"%s/%s\" --dbname template1 >> \"%s\"" SYSTEMQUOTE,
247259
new_cluster.bindir, new_cluster.port, os_info.user, os_info.cwd,
248-
GLOBALS_DUMP_FILE, log_opts.filename);
260+
GLOBALS_DUMP_FILE,
261+
#ifndef WIN32
262+
log_opts.filename
263+
#else
264+
DEVNULL
265+
#endif
266+
);
249267
check_ok();
250268

251269
/* we load this to get a current list of databases */
@@ -276,7 +294,13 @@ create_new_objects(void)
276294
"--no-psqlrc --port %d --username \"%s\" "
277295
"-f \"%s/%s\" --dbname template1 >> \"%s\"" SYSTEMQUOTE,
278296
new_cluster.bindir, new_cluster.port, os_info.user, os_info.cwd,
279-
DB_DUMP_FILE, log_opts.filename);
297+
DB_DUMP_FILE,
298+
#ifndef WIN32
299+
log_opts.filename
300+
#else
301+
DEVNULL
302+
#endif
303+
);
280304
check_ok();
281305

282306
/* regenerate now that we have objects in the databases */
@@ -324,7 +348,13 @@ copy_clog_xlog_xid(void)
324348
exec_prog(true, SYSTEMQUOTE "\"%s/pg_resetxlog\" -l %u,%u,%u \"%s\" >> \"%s\" 2>&1" SYSTEMQUOTE,
325349
new_cluster.bindir, old_cluster.controldata.chkpnt_tli,
326350
old_cluster.controldata.logid, old_cluster.controldata.nxtlogseg,
327-
new_cluster.pgdata, log_opts.filename);
351+
new_cluster.pgdata,
352+
#ifndef WIN32
353+
log_opts.filename
354+
#else
355+
DEVNULL
356+
#endif
357+
);
328358
check_ok();
329359
}
330360

contrib/pg_upgrade/server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ start_postmaster(ClusterInfo *cluster)
184184
(cluster->controldata.cat_ver >=
185185
BINARY_UPGRADE_SERVER_FLAG_CAT_VER) ? "-b" :
186186
"-c autovacuum=off -c autovacuum_freeze_max_age=2000000000",
187-
log_opts.filename);
187+
output_filename);
188188

189189
/*
190190
* Don't throw an error right away, let connecting throw the error because

0 commit comments

Comments
 (0)