git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cf131fa)
pg_dump: Add --sequence-data.
2025年3月25日 21:02:35 +0000 (16:02 -0500)
2025年3月25日 21:02:35 +0000 (16:02 -0500)
This new option instructs pg_dump to dump sequence data when the
--no-data, --schema-only, or --statistics-only option is specified.
This was originally considered for commit a7e5457db8, but it was
left out at that time because there was no known use-case. A
follow-up commit will use this to optimize pg_upgrade's file
transfer step.

Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Discussion: https://postgr.es/m/Zyvop-LxLXBLrZil%40nathan


diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index 0ae40f9be58d28beb33160d50f87ab4d49ee488b..63cca18711a4121baf68d2c6b33e17a6c781f97d 100644 (file)
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -1298,6 +1298,17 @@ PostgreSQL documentation
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--sequence-data</option></term>
+ <listitem>
+ <para>
+ Include sequence data in the dump. This is the default behavior except
+ when <option>--no-data</option>, <option>--schema-only</option>, or
+ <option>--statistics-only</option> is specified.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><option>--serializable-deferrable</option></term>
<listitem>
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 239664c459d1cef8ec76a31afb59eb88c7f7013d..4b2dfa5e0bd661480c70c30241b4615ce9a72867 100644 (file)
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -518,6 +518,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}
};
@@ -801,14 +802,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 (data_only && schema_only)
pg_fatal("options -s/--schema-only and -a/--data-only cannot be used together");
if (schema_only && statistics_only)
@@ -1275,6 +1268,7 @@ help(const char *progname)
printf(_(" --quote-all-identifiers quote all identifiers, even if not key words\n"));
printf(_(" --rows-per-insert=NROWS number of rows per INSERT; implies --inserts\n"));
printf(_(" --section=SECTION dump named section (pre-data, data, or post-data)\n"));
+ printf(_(" --sequence-data include sequence data in dump\n"));
printf(_(" --serializable-deferrable wait until the dump can run without anomalies\n"));
printf(_(" --snapshot=SNAPSHOT use given snapshot for the dump\n"));
printf(_(" --statistics-only dump only the statistics, not schema or data\n"));
diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index d3e84f44c6cf443d57bec4ff6e1192e75957a6e0..b6c2487c9750edb446cd5a2caaab281c30e93e98 100644 (file)
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -66,6 +66,7 @@ my %pgdump_runs = (
'--file' => "$tempdir/binary_upgrade.dump",
'--no-password',
'--no-data',
+ '--sequence-data',
'--binary-upgrade',
'--dbname' => 'postgres', # alternative way to specify database
],
diff --git a/src/bin/pg_upgrade/dump.c b/src/bin/pg_upgrade/dump.c
index 23fe7280a1610e05b1da165e209230fba33f65db..b8fd0d0acee30e72db60c5e2d95df3a7946ad7fb 100644 (file)
--- a/src/bin/pg_upgrade/dump.c
+++ b/src/bin/pg_upgrade/dump.c
@@ -52,7 +52,7 @@ 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 %s --quote-all-identifiers "
+ "\"%s/pg_dump\" %s --no-data %s --sequence-data --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" : "",
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 a9bcac4169d7a9722068f781e8a1743eaeab62c5..adcaa419616cdf6d7bb6f10b7ee5cc81de870bcb 100644 (file)
--- 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',
+ '--schema-only', '--sequence-data', '--binary-upgrade',
'--dbname' => 'postgres',
],
},
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /