v34-0004-Add-statistics-flags-to-pg_upgrade.patch
text/x-patch
Filename: v34-0004-Add-statistics-flags-to-pg_upgrade.patch
Type: text/x-patch
Part: 3
Message:
Re: Statistics Import and Export
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v34-0004
Subject: Add statistics flags to pg_upgrade
| File | + | − |
|---|---|---|
| src/bin/pg_upgrade/dump.c | 4 | 2 |
| src/bin/pg_upgrade/option.c | 12 | 0 |
| src/bin/pg_upgrade/pg_upgrade.h | 1 | 0 |
From e9dd923a80b2486c24224acc654c47da926d6fe6 Mon Sep 17 00:00:00 2001
From: Corey Huinker <corey.huinker@gmail.com>
Date: Wed, 11 Dec 2024 22:38:00 -0500
Subject: [PATCH v34 04/11] Add statistics flags to pg_upgrade
---
src/bin/pg_upgrade/dump.c | 6 ++++--
src/bin/pg_upgrade/option.c | 12 ++++++++++++
src/bin/pg_upgrade/pg_upgrade.h | 1 +
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/bin/pg_upgrade/dump.c b/src/bin/pg_upgrade/dump.c
index ef2f14a79b..954e7bacf4 100644
--- a/src/bin/pg_upgrade/dump.c
+++ b/src/bin/pg_upgrade/dump.c
@@ -21,10 +21,11 @@ generate_old_dump(void)
/* run new pg_dumpall binary for globals */
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
- "\"%s/pg_dumpall\" %s --globals-only --quote-all-identifiers "
+ "\"%s/pg_dumpall\" %s %s --globals-only --quote-all-identifiers "
"--binary-upgrade %s --no-sync -f \"%s/%s\"",
new_cluster.bindir, cluster_conn_opts(&old_cluster),
log_opts.verbose ? "--verbose" : "",
+ user_opts.do_statistics ? "" : "--no-statistics",
log_opts.dumpdir,
GLOBALS_DUMP_FILE);
check_ok();
@@ -52,10 +53,11 @@ generate_old_dump(void)
snprintf(log_file_name, sizeof(log_file_name), DB_DUMP_LOG_FILE_MASK, old_db->db_oid);
parallel_exec_prog(log_file_name, NULL,
- "\"%s/pg_dump\" %s --no-data --quote-all-identifiers "
+ "\"%s/pg_dump\" %s --no-data %s --quote-all-identifiers "
"--binary-upgrade --format=custom %s --no-sync --file=\"%s/%s\" %s",
new_cluster.bindir, cluster_conn_opts(&old_cluster),
log_opts.verbose ? "--verbose" : "",
+ user_opts.do_statistics ? "" : "--no-statistics",
log_opts.dumpdir,
sql_file_name, escaped_connstr.data);
diff --git a/src/bin/pg_upgrade/option.c b/src/bin/pg_upgrade/option.c
index 6f41d63eed..76a0bb2991 100644
--- a/src/bin/pg_upgrade/option.c
+++ b/src/bin/pg_upgrade/option.c
@@ -60,6 +60,8 @@ parseCommandLine(int argc, char *argv[])
{"copy", no_argument, NULL, 2},
{"copy-file-range", no_argument, NULL, 3},
{"sync-method", required_argument, NULL, 4},
+ {"with-statistics", no_argument, NULL, 5},
+ {"no-statistics", no_argument, NULL, 6},
{NULL, 0, NULL, 0}
};
@@ -70,6 +72,7 @@ parseCommandLine(int argc, char *argv[])
user_opts.do_sync = true;
user_opts.transfer_mode = TRANSFER_MODE_COPY;
+ user_opts.do_statistics = true;
os_info.progname = get_progname(argv[0]);
@@ -212,6 +215,13 @@ parseCommandLine(int argc, char *argv[])
user_opts.sync_method = pg_strdup(optarg);
break;
+ case 5:
+ user_opts.do_statistics = true;
+ break;
+ case 6:
+ user_opts.do_statistics = false;
+ break;
+
default:
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
os_info.progname);
@@ -307,6 +317,8 @@ usage(void)
printf(_(" --copy copy files to new cluster (default)\n"));
printf(_(" --copy-file-range copy files to new cluster with copy_file_range\n"));
printf(_(" --sync-method=METHOD set method for syncing files to disk\n"));
+ printf(_(" --with-statisttics import statistics from old cluster (default)\n"));
+ printf(_(" --no-statisttics do not import statistics from old cluster\n"));
printf(_(" -?, --help show this help, then exit\n"));
printf(_("\n"
"Before running pg_upgrade you must:\n"
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 53f693c2d4..371f9a2d06 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -327,6 +327,7 @@ typedef struct
int jobs; /* number of processes/threads to use */
char *socketdir; /* directory to use for Unix sockets */
char *sync_method;
+ bool do_statistics; /* carry over statistics from old cluster */
} UserOpts;
typedef struct
--
2.47.1