From 234d40f4e45d56f40465037dcf83c8c980edf095 Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Wed, 6 Nov 2024 10:46:11 -0600 Subject: [PATCH v1 7/8] Add --sequence-data flag to pg_dump. THIS IS A PROOF OF CONCEPT AND IS NOT READY FOR SERIOUS REVIEW. This flag can be used to optionally dump the sequence data even when --schema-only is used. It is primarily intended for use in a follow-up commit that will cause sequence data files to be carried over from the old cluster in pg_upgrade's new catalog-swap mode. --- src/bin/pg_dump/pg_dump.c | 9 +-------- src/bin/pg_upgrade/dump.c | 2 +- src/test/modules/test_pg_dump/t/001_base.pl | 2 +- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index b2f4eb2c6d..2b57abd305 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -501,6 +501,7 @@ main(int argc, char **argv) {"sync-method", required_argument, NULL, 15}, {"filter", required_argument, NULL, 16}, {"exclude-extension", required_argument, NULL, 17}, + {"sequence-data", no_argument, &dopt.sequence_data, 1}, {NULL, 0, NULL, 0} }; @@ -768,14 +769,6 @@ main(int argc, char **argv) if (dopt.column_inserts && dopt.dump_inserts == 0) dopt.dump_inserts = DUMP_DEFAULT_ROWS_PER_INSERT; - /* - * Binary upgrade mode implies dumping sequence data even in schema-only - * mode. This is not exposed as a separate option, but kept separate - * internally for clarity. - */ - if (dopt.binary_upgrade) - dopt.sequence_data = 1; - if (dopt.dataOnly && dopt.schemaOnly) pg_fatal("options -s/--schema-only and -a/--data-only cannot be used together"); diff --git a/src/bin/pg_upgrade/dump.c b/src/bin/pg_upgrade/dump.c index 8345f55be8..8453722833 100644 --- a/src/bin/pg_upgrade/dump.c +++ b/src/bin/pg_upgrade/dump.c @@ -53,7 +53,7 @@ generate_old_dump(void) parallel_exec_prog(log_file_name, NULL, "\"%s/pg_dump\" %s --schema-only --quote-all-identifiers " - "--binary-upgrade --format=custom %s --no-sync --file=\"%s/%s\" %s", + "--binary-upgrade --sequence-data --format=custom %s --no-sync --file=\"%s/%s\" %s", new_cluster.bindir, cluster_conn_opts(&old_cluster), log_opts.verbose ? "--verbose" : "", log_opts.dumpdir, diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl index e2579e29cd..46231c93f1 100644 --- a/src/test/modules/test_pg_dump/t/001_base.pl +++ b/src/test/modules/test_pg_dump/t/001_base.pl @@ -48,7 +48,7 @@ my %pgdump_runs = ( dump_cmd => [ 'pg_dump', '--no-sync', "--file=$tempdir/binary_upgrade.sql", '--schema-only', - '--binary-upgrade', '--dbname=postgres', + '--binary-upgrade', '--sequence-data', '--dbname=postgres', ], }, clean => { -- 2.39.5 (Apple Git-154)