Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit666d494

Browse files
committed
pg_upgrade: abstract out copying of files from old cluster to new
Currently only pg_clog is copied, but some other directories could needthe same treatment as well, so create a subroutine to do it.Extracted from my (somewhat larger) FOR KEY SHARE patch.
1 parent3644a63 commit666d494

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

‎contrib/pg_upgrade/pg_upgrade.c

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -311,23 +311,26 @@ create_new_objects(void)
311311
uninstall_support_functions_from_new_cluster();
312312
}
313313

314-
314+
/*
315+
* Delete the given subdirectory contents from the new cluster, and copy the
316+
* files from the old cluster into it.
317+
*/
315318
staticvoid
316-
copy_clog_xlog_xid(void)
319+
copy_subdir_files(char*subdir)
317320
{
318-
charold_clog_path[MAXPGPATH];
319-
charnew_clog_path[MAXPGPATH];
321+
charold_path[MAXPGPATH];
322+
charnew_path[MAXPGPATH];
320323

321-
/* copy old commit logs to new data dir */
322-
prep_status("Deleting new commit clogs");
324+
prep_status("Deleting files from new %s",subdir);
323325

324-
snprintf(old_clog_path,sizeof(old_clog_path),"%s/pg_clog",old_cluster.pgdata);
325-
snprintf(new_clog_path,sizeof(new_clog_path),"%s/pg_clog",new_cluster.pgdata);
326-
if (!rmtree(new_clog_path, true))
327-
pg_log(PG_FATAL,"could not delete directory \"%s\"\n",new_clog_path);
326+
snprintf(old_path,sizeof(old_path),"%s/%s",old_cluster.pgdata,subdir);
327+
snprintf(new_path,sizeof(new_path),"%s/%s",new_cluster.pgdata,subdir);
328+
if (!rmtree(new_path, true))
329+
pg_log(PG_FATAL,"could not delete directory \"%s\"\n",new_path);
328330
check_ok();
329331

330-
prep_status("Copying old commit clogs to new server");
332+
prep_status("Copying old %s to new server",subdir);
333+
331334
exec_prog(true, false,UTILITY_LOG_FILE,
332335
#ifndefWIN32
333336
SYSTEMQUOTE"%s \"%s\" \"%s\" >> \"%s\" 2>&1"SYSTEMQUOTE,
@@ -337,8 +340,16 @@ copy_clog_xlog_xid(void)
337340
SYSTEMQUOTE"%s \"%s\" \"%s\\\" >> \"%s\" 2>&1"SYSTEMQUOTE,
338341
"xcopy /e /y /q /r",
339342
#endif
340-
old_clog_path,new_clog_path,UTILITY_LOG_FILE);
343+
old_path,new_path,UTILITY_LOG_FILE);
344+
341345
check_ok();
346+
}
347+
348+
staticvoid
349+
copy_clog_xlog_xid(void)
350+
{
351+
/* copy old commit logs to new data dir */
352+
copy_subdir_files("pg_clog");
342353

343354
/* set the next transaction id of the new cluster */
344355
prep_status("Setting next transaction ID for new cluster");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp