aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2012-07-05 11:38:42 -0400
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2012-07-05 11:38:42 -0400
commit666d494d19dbd5dc7a177709a2f7069913f8ab89 (patch)
tree2b259e5eba889da26ed576bdc3ddfcff3de7f670
parent3644a63984cbdba2c78c22fd9a0cdb0f4701b600 (diff)
downloadpostgresql-666d494d19dbd5dc7a177709a2f7069913f8ab89.tar.gz
postgresql-666d494d19dbd5dc7a177709a2f7069913f8ab89.zip
pg_upgrade: abstract out copying of files from old cluster to new
Currently only pg_clog is copied, but some other directories could need the same treatment as well, so create a subroutine to do it. Extracted from my (somewhat larger) FOR KEY SHARE patch.
-rw-r--r--contrib/pg_upgrade/pg_upgrade.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/contrib/pg_upgrade/pg_upgrade.c b/contrib/pg_upgrade/pg_upgrade.c
index 07006aed96f..9d26b8cf023 100644
--- a/contrib/pg_upgrade/pg_upgrade.c
+++ b/contrib/pg_upgrade/pg_upgrade.c
@@ -311,23 +311,26 @@ create_new_objects(void)
uninstall_support_functions_from_new_cluster();
}
-
+/*
+ * Delete the given subdirectory contents from the new cluster, and copy the
+ * files from the old cluster into it.
+ */
static void
-copy_clog_xlog_xid(void)
+copy_subdir_files(char *subdir)
{
- char old_clog_path[MAXPGPATH];
- char new_clog_path[MAXPGPATH];
+ char old_path[MAXPGPATH];
+ char new_path[MAXPGPATH];
- /* copy old commit logs to new data dir */
- prep_status("Deleting new commit clogs");
+ prep_status("Deleting files from new %s", subdir);
- snprintf(old_clog_path, sizeof(old_clog_path), "%s/pg_clog", old_cluster.pgdata);
- snprintf(new_clog_path, sizeof(new_clog_path), "%s/pg_clog", new_cluster.pgdata);
- if (!rmtree(new_clog_path, true))
- pg_log(PG_FATAL, "could not delete directory \"%s\"\n", new_clog_path);
+ snprintf(old_path, sizeof(old_path), "%s/%s", old_cluster.pgdata, subdir);
+ snprintf(new_path, sizeof(new_path), "%s/%s", new_cluster.pgdata, subdir);
+ if (!rmtree(new_path, true))
+ pg_log(PG_FATAL, "could not delete directory \"%s\"\n", new_path);
check_ok();
- prep_status("Copying old commit clogs to new server");
+ prep_status("Copying old %s to new server", subdir);
+
exec_prog(true, false, UTILITY_LOG_FILE,
#ifndef WIN32
SYSTEMQUOTE "%s \"%s\" \"%s\" >> \"%s\" 2>&1" SYSTEMQUOTE,
@@ -337,8 +340,16 @@ copy_clog_xlog_xid(void)
SYSTEMQUOTE "%s \"%s\" \"%s\\\" >> \"%s\" 2>&1" SYSTEMQUOTE,
"xcopy /e /y /q /r",
#endif
- old_clog_path, new_clog_path, UTILITY_LOG_FILE);
+ old_path, new_path, UTILITY_LOG_FILE);
+
check_ok();
+}
+
+static void
+copy_clog_xlog_xid(void)
+{
+ /* copy old commit logs to new data dir */
+ copy_subdir_files("pg_clog");
/* set the next transaction id of the new cluster */
prep_status("Setting next transaction ID for new cluster");