On Tue, 2025-07-29 at 11:24 -0700, Jeff Davis wrote:
> On Wed, 2025-06-18 at 10:21 -0700, Jeff Davis wrote:
> > On Wed, 2025-06-18 at 10:43 -0500, Nathan Bossart wrote:
> > > IIUC the current proposal is to:
> > > 
> > > * Dump/restore stats by default.
> 
> We don't have a consensus for that, so unless a few people make an
> abrupt turnaround, this will remain off for v18.
> 
> > > * Keep the --no-statistics, --no-schema, and --no-data options.
> > > * Keep the --statistics-only, --schema-only, and --data-only
> > > options.
> > > * Remove the --with-statistics, --with-schema, and --with-data
> > > options.
> 
> The other parts of the proposal are very similar with mine below:
> 
> >   * delete the --with-data and --with-schema options as unnecessary
> >   * (maybe?) rename --with-statistics to --statistics
> >   * keep --no-statistics, --no-data, --no-schema (or use "without"
> > instead?)
> >   * (maybe?) keep --statistics-only
> >   * reject the combination of an "only" option and a "with" option

Patch attached.

  * removes --with-data and --with-schema (redundant)
  * renames --with-statistics to just --statistics

I kept --statistics and --no-statistics for both pg_dump and
pg_restore, because: (a) I think it's good to have consistent options
between those two programs; and (b) it allows us to potentially change
the default to include statistics in the future. That leaves some
redundancy of the options, which some have expressed annoyance over,
but it doesn't seem like a major point of objection.

Regards,
        Jeff Davis

From 01eca8001f13af9684a211ccf5f61dfd825fdca9 Mon Sep 17 00:00:00 2001
From: Jeff Davis <j...@j-davis.com>
Date: Fri, 1 Aug 2025 12:27:53 -0700
Subject: [PATCH v3] Simplify options in pg_dump and pg_restore.

Remove redundant options --with-data and --with-schema, and rename
--with-statistics to just --statistics.

Discussion: https://postgr.es/m/f379d0aeefe8effe13302a436bc28f549f09e924.ca...@j-davis.com
Backpatch-through: 18
---
 doc/src/sgml/ref/pg_dump.sgml    |  22 +-----
 doc/src/sgml/ref/pg_dumpall.sgml |  22 +-----
 doc/src/sgml/ref/pg_restore.sgml |  22 +-----
 src/bin/pg_dump/pg_dump.c        |  43 +++--------
 src/bin/pg_dump/pg_dumpall.c     |  16 +---
 src/bin/pg_dump/pg_restore.c     |  35 +++------
 src/bin/pg_dump/t/002_pg_dump.pl | 124 +++++++++++++++----------------
 src/bin/pg_upgrade/dump.c        |   2 +-
 8 files changed, 93 insertions(+), 193 deletions(-)

diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index 2ae084b5fa6..d5f56d2f82f 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -1441,25 +1441,7 @@ PostgreSQL documentation
      </varlistentry>
 
      <varlistentry>
-      <term><option>--with-data</option></term>
-      <listitem>
-       <para>
-        Dump data. This is the default.
-       </para>
-      </listitem>
-     </varlistentry>
-
-     <varlistentry>
-      <term><option>--with-schema</option></term>
-      <listitem>
-       <para>
-        Dump schema (data definitions). This is the default.
-       </para>
-      </listitem>
-     </varlistentry>
-
-     <varlistentry>
-      <term><option>--with-statistics</option></term>
+      <term><option>--statistics</option></term>
       <listitem>
        <para>
         Dump statistics.
@@ -1682,7 +1664,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
   </para>
 
   <para>
-   If <option>--with-statistics</option> is specified,
+   If <option>--statistics</option> is specified,
    <command>pg_dump</command> will include most optimizer statistics in the
    resulting dump file.  However, some statistics may not be included, such as
    those created explicitly with <xref linkend="sql-createstatistics"/> or
diff --git a/doc/src/sgml/ref/pg_dumpall.sgml b/doc/src/sgml/ref/pg_dumpall.sgml
index f4cbc8288e3..87af482b4b2 100644
--- a/doc/src/sgml/ref/pg_dumpall.sgml
+++ b/doc/src/sgml/ref/pg_dumpall.sgml
@@ -641,25 +641,7 @@ exclude database <replaceable class="parameter">PATTERN</replaceable>
      </varlistentry>
 
      <varlistentry>
-      <term><option>--with-data</option></term>
-      <listitem>
-       <para>
-        Dump data. This is the default.
-       </para>
-      </listitem>
-     </varlistentry>
-
-     <varlistentry>
-      <term><option>--with-schema</option></term>
-      <listitem>
-       <para>
-        Dump schema (data definitions). This is the default.
-       </para>
-      </listitem>
-     </varlistentry>
-
-     <varlistentry>
-      <term><option>--with-statistics</option></term>
+      <term><option>--statistics</option></term>
       <listitem>
        <para>
         Dump statistics.
@@ -878,7 +860,7 @@ exclude database <replaceable class="parameter">PATTERN</replaceable>
   </para>
 
   <para>
-   If <option>--with-statistics</option> is specified,
+   If <option>--statistics</option> is specified,
    <command>pg_dumpall</command> will include most optimizer statistics in the
    resulting dump file.  However, some statistics may not be included, such as
    those created explicitly with <xref linkend="sql-createstatistics"/> or
diff --git a/doc/src/sgml/ref/pg_restore.sgml b/doc/src/sgml/ref/pg_restore.sgml
index 2abe05d47e9..8087400703a 100644
--- a/doc/src/sgml/ref/pg_restore.sgml
+++ b/doc/src/sgml/ref/pg_restore.sgml
@@ -874,27 +874,7 @@ PostgreSQL documentation
      </varlistentry>
 
      <varlistentry>
-      <term><option>--with-data</option></term>
-      <listitem>
-       <para>
-        Output commands to restore data, if the archive contains them.
-        This is the default.
-       </para>
-      </listitem>
-     </varlistentry>
-
-     <varlistentry>
-      <term><option>--with-schema</option></term>
-      <listitem>
-       <para>
-        Output commands to restore schema (data definitions), if the archive
-        contains them. This is the default.
-       </para>
-      </listitem>
-     </varlistentry>
-
-     <varlistentry>
-      <term><option>--with-statistics</option></term>
+      <term><option>--statistics</option></term>
       <listitem>
        <para>
         Output commands to restore statistics, if the archive contains them.
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index b1ac8d7b509..f3a353a61a5 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -449,8 +449,6 @@ main(int argc, char **argv)
 	bool		data_only = false;
 	bool		schema_only = false;
 	bool		statistics_only = false;
-	bool		with_data = false;
-	bool		with_schema = false;
 	bool		with_statistics = false;
 	bool		no_data = false;
 	bool		no_schema = false;
@@ -514,6 +512,7 @@ main(int argc, char **argv)
 		{"section", required_argument, NULL, 5},
 		{"serializable-deferrable", no_argument, &dopt.serializable_deferrable, 1},
 		{"snapshot", required_argument, NULL, 6},
+		{"statistics", no_argument, NULL, 22},
 		{"statistics-only", no_argument, NULL, 18},
 		{"strict-names", no_argument, &strict_names, 1},
 		{"use-set-session-authorization", no_argument, &dopt.use_setsessauth, 1},
@@ -528,9 +527,6 @@ main(int argc, char **argv)
 		{"no-toast-compression", no_argument, &dopt.no_toast_compression, 1},
 		{"no-unlogged-table-data", no_argument, &dopt.no_unlogged_table_data, 1},
 		{"no-sync", no_argument, NULL, 7},
-		{"with-data", no_argument, NULL, 22},
-		{"with-schema", no_argument, NULL, 23},
-		{"with-statistics", no_argument, NULL, 24},
 		{"on-conflict-do-nothing", no_argument, &dopt.do_nothing, 1},
 		{"rows-per-insert", required_argument, NULL, 10},
 		{"include-foreign-data", required_argument, NULL, 11},
@@ -798,14 +794,6 @@ main(int argc, char **argv)
 				break;
 
 			case 22:
-				with_data = true;
-				break;
-
-			case 23:
-				with_schema = true;
-				break;
-
-			case 24:
 				with_statistics = true;
 				break;
 
@@ -852,24 +840,17 @@ main(int argc, char **argv)
 	if (statistics_only && no_statistics)
 		pg_fatal("options --statistics-only and --no-statistics cannot be used together");
 
-	/* reject conflicting "with-" and "no-" options */
-	if (with_data && no_data)
-		pg_fatal("options --with-data and --no-data cannot be used together");
-	if (with_schema && no_schema)
-		pg_fatal("options --with-schema and --no-schema cannot be used together");
+	/* reject conflicting "no-" options */
 	if (with_statistics && no_statistics)
-		pg_fatal("options --with-statistics and --no-statistics cannot be used together");
+		pg_fatal("options --statistics and --no-statistics cannot be used together");
 
-	/* reject conflicting "-only" and "with-" options */
-	if (data_only && (with_schema || with_statistics))
-		pg_fatal("options %s and %s cannot be used together",
-				 "-a/--data-only", with_schema ? "--with-schema" : "--with-statistics");
-	if (schema_only && (with_data || with_statistics))
+	/* reject conflicting "-only" options */
+	if (data_only && with_statistics)
 		pg_fatal("options %s and %s cannot be used together",
-				 "-s/--schema-only", with_data ? "--with-data" : "--with-statistics");
-	if (statistics_only && (with_data || with_schema))
+				 "-a/--data-only", "--statistics");
+	if (schema_only && with_statistics)
 		pg_fatal("options %s and %s cannot be used together",
-				 "--statistics-only", with_data ? "--with-data" : "--with-schema");
+				 "-s/--schema-only", "--statistics");
 
 	if (schema_only && foreign_servers_include_patterns.head != NULL)
 		pg_fatal("options -s/--schema-only and --include-foreign-data cannot be used together");
@@ -889,9 +870,9 @@ main(int argc, char **argv)
 	 * of the checks above.
 	 */
 	dopt.dumpData = ((dopt.dumpData && !schema_only && !statistics_only) ||
-					 (data_only || with_data)) && !no_data;
+					 data_only) && !no_data;
 	dopt.dumpSchema = ((dopt.dumpSchema && !data_only && !statistics_only) ||
-					   (schema_only || with_schema)) && !no_schema;
+					   schema_only) && !no_schema;
 	dopt.dumpStatistics = ((dopt.dumpStatistics && !schema_only && !data_only) ||
 						   (statistics_only || with_statistics)) && !no_statistics;
 
@@ -1364,6 +1345,7 @@ help(const char *progname)
 	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                 dump the statistics\n"));
 	printf(_("  --statistics-only            dump only the statistics, not schema or data\n"));
 	printf(_("  --strict-names               require table and/or schema include patterns to\n"
 			 "                               match at least one entity each\n"));
@@ -1372,9 +1354,6 @@ help(const char *progname)
 	printf(_("  --use-set-session-authorization\n"
 			 "                               use SET SESSION AUTHORIZATION commands instead of\n"
 			 "                               ALTER OWNER commands to set ownership\n"));
-	printf(_("  --with-data                  dump the data\n"));
-	printf(_("  --with-schema                dump the schema\n"));
-	printf(_("  --with-statistics            dump the statistics\n"));
 
 	printf(_("\nConnection options:\n"));
 	printf(_("  -d, --dbname=DBNAME      database to dump\n"));
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 87d10df07c4..27aa1b65698 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -105,8 +105,6 @@ static int	no_subscriptions = 0;
 static int	no_toast_compression = 0;
 static int	no_unlogged_table_data = 0;
 static int	no_role_passwords = 0;
-static int	with_data = 0;
-static int	with_schema = 0;
 static int	with_statistics = 0;
 static int	server_version;
 static int	load_via_partition_root = 0;
@@ -180,11 +178,9 @@ main(int argc, char *argv[])
 		{"no-sync", no_argument, NULL, 4},
 		{"no-toast-compression", no_argument, &no_toast_compression, 1},
 		{"no-unlogged-table-data", no_argument, &no_unlogged_table_data, 1},
-		{"with-data", no_argument, &with_data, 1},
-		{"with-schema", no_argument, &with_schema, 1},
-		{"with-statistics", no_argument, &with_statistics, 1},
 		{"on-conflict-do-nothing", no_argument, &on_conflict_do_nothing, 1},
 		{"rows-per-insert", required_argument, NULL, 7},
+		{"statistics", no_argument, &with_statistics, 1},
 		{"statistics-only", no_argument, &statistics_only, 1},
 		{"filter", required_argument, NULL, 8},
 		{"sequence-data", no_argument, &sequence_data, 1},
@@ -475,12 +471,8 @@ main(int argc, char *argv[])
 		appendPQExpBufferStr(pgdumpopts, " --no-toast-compression");
 	if (no_unlogged_table_data)
 		appendPQExpBufferStr(pgdumpopts, " --no-unlogged-table-data");
-	if (with_data)
-		appendPQExpBufferStr(pgdumpopts, " --with-data");
-	if (with_schema)
-		appendPQExpBufferStr(pgdumpopts, " --with-schema");
 	if (with_statistics)
-		appendPQExpBufferStr(pgdumpopts, " --with-statistics");
+		appendPQExpBufferStr(pgdumpopts, " --statistics");
 	if (on_conflict_do_nothing)
 		appendPQExpBufferStr(pgdumpopts, " --on-conflict-do-nothing");
 	if (statistics_only)
@@ -712,13 +704,11 @@ help(void)
 	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(_("  --sequence-data              include sequence data in dump\n"));
+	printf(_("  --statistics                 dump the statistics\n"));
 	printf(_("  --statistics-only            dump only the statistics, not schema or data\n"));
 	printf(_("  --use-set-session-authorization\n"
 			 "                               use SET SESSION AUTHORIZATION commands instead of\n"
 			 "                               ALTER OWNER commands to set ownership\n"));
-	printf(_("  --with-data                  dump the data\n"));
-	printf(_("  --with-schema                dump the schema\n"));
-	printf(_("  --with-statistics            dump the statistics\n"));
 
 	printf(_("\nConnection options:\n"));
 	printf(_("  -d, --dbname=CONNSTR     connect using connection string\n"));
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index 2c727b9f156..6c129278bc5 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -82,8 +82,6 @@ main(int argc, char **argv)
 	static int	no_subscriptions = 0;
 	static int	strict_names = 0;
 	static int	statistics_only = 0;
-	static int	with_data = 0;
-	static int	with_schema = 0;
 	static int	with_statistics = 0;
 
 	struct option cmdopts[] = {
@@ -139,9 +137,7 @@ main(int argc, char **argv)
 		{"no-security-labels", no_argument, &no_security_labels, 1},
 		{"no-subscriptions", no_argument, &no_subscriptions, 1},
 		{"no-statistics", no_argument, &no_statistics, 1},
-		{"with-data", no_argument, &with_data, 1},
-		{"with-schema", no_argument, &with_schema, 1},
-		{"with-statistics", no_argument, &with_statistics, 1},
+		{"statistics", no_argument, &with_statistics, 1},
 		{"statistics-only", no_argument, &statistics_only, 1},
 		{"filter", required_argument, NULL, 4},
 
@@ -373,24 +369,17 @@ main(int argc, char **argv)
 	if (statistics_only && no_statistics)
 		pg_fatal("options --statistics-only and --no-statistics cannot be used together");
 
-	/* reject conflicting "with-" and "no-" options */
-	if (with_data && no_data)
-		pg_fatal("options --with-data and --no-data cannot be used together");
-	if (with_schema && no_schema)
-		pg_fatal("options --with-schema and --no-schema cannot be used together");
+	/* reject conflicting "no-" options */
 	if (with_statistics && no_statistics)
-		pg_fatal("options --with-statistics and --no-statistics cannot be used together");
+		pg_fatal("options --statistics and --no-statistics cannot be used together");
 
-	/* reject conflicting "only-" and "with-" options */
-	if (data_only && (with_schema || with_statistics))
+	/* reject conflicting "only-" options */
+	if (data_only && with_statistics)
 		pg_fatal("options %s and %s cannot be used together",
-				 "-a/--data-only", with_schema ? "--with-schema" : "--with-statistics");
-	if (schema_only && (with_data || with_statistics))
+				 "-a/--data-only", "--statistics");
+	if (schema_only && with_statistics)
 		pg_fatal("options %s and %s cannot be used together",
-				 "-s/--schema-only", with_data ? "--with-data" : "--with-statistics");
-	if (statistics_only && (with_data || with_schema))
-		pg_fatal("options %s and %s cannot be used together",
-				 "--statistics-only", with_data ? "--with-data" : "--with-schema");
+				 "-s/--schema-only", "--statistics");
 
 	if (data_only && opts->dropSchema)
 		pg_fatal("options -c/--clean and -a/--data-only cannot be used together");
@@ -415,9 +404,9 @@ main(int argc, char **argv)
 	 * of the checks above.
 	 */
 	opts->dumpData = ((opts->dumpData && !schema_only && !statistics_only) ||
-					  (data_only || with_data)) && !no_data;
+					  data_only) && !no_data;
 	opts->dumpSchema = ((opts->dumpSchema && !data_only && !statistics_only) ||
-						(schema_only || with_schema)) && !no_schema;
+						schema_only) && !no_schema;
 	opts->dumpStatistics = ((opts->dumpStatistics && !schema_only && !data_only) ||
 							(statistics_only || with_statistics)) && !no_statistics;
 
@@ -558,6 +547,7 @@ usage(const char *progname)
 	printf(_("  --no-table-access-method     do not restore table access methods\n"));
 	printf(_("  --no-tablespaces             do not restore tablespace assignments\n"));
 	printf(_("  --section=SECTION            restore named section (pre-data, data, or post-data)\n"));
+	printf(_("  --statistics                 restore the statistics\n"));
 	printf(_("  --statistics-only            restore only the statistics, not schema or data\n"));
 	printf(_("  --strict-names               require table and/or schema include patterns to\n"
 			 "                               match at least one entity each\n"));
@@ -565,9 +555,6 @@ usage(const char *progname)
 	printf(_("  --use-set-session-authorization\n"
 			 "                               use SET SESSION AUTHORIZATION commands instead of\n"
 			 "                               ALTER OWNER commands to set ownership\n"));
-	printf(_("  --with-data                  restore the data\n"));
-	printf(_("  --with-schema                restore the schema\n"));
-	printf(_("  --with-statistics            restore the statistics\n"));
 
 	printf(_("\nConnection options:\n"));
 	printf(_("  -h, --host=HOSTNAME      database server host or socket directory\n"));
diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index d597842908e..a86b38466de 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -68,7 +68,7 @@ my %pgdump_runs = (
 			'--no-data',
 			'--sequence-data',
 			'--binary-upgrade',
-			'--with-statistics',
+			'--statistics',
 			'--dbname' => 'postgres',    # alternative way to specify database
 		],
 		restore_cmd => [
@@ -76,7 +76,7 @@ my %pgdump_runs = (
 			'--format' => 'custom',
 			'--verbose',
 			'--file' => "$tempdir/binary_upgrade.sql",
-			'--with-statistics',
+			'--statistics',
 			"$tempdir/binary_upgrade.dump",
 		],
 	},
@@ -90,13 +90,13 @@ my %pgdump_runs = (
 			'--format' => 'custom',
 			'--compress' => '1',
 			'--file' => "$tempdir/compression_gzip_custom.dump",
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 		restore_cmd => [
 			'pg_restore',
 			'--file' => "$tempdir/compression_gzip_custom.sql",
-			'--with-statistics',
+			'--statistics',
 			"$tempdir/compression_gzip_custom.dump",
 		],
 		command_like => {
@@ -119,7 +119,7 @@ my %pgdump_runs = (
 			'--format' => 'directory',
 			'--compress' => 'gzip:1',
 			'--file' => "$tempdir/compression_gzip_dir",
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 		# Give coverage for manually compressed blobs.toc files during
@@ -137,7 +137,7 @@ my %pgdump_runs = (
 			'pg_restore',
 			'--jobs' => '2',
 			'--file' => "$tempdir/compression_gzip_dir.sql",
-			'--with-statistics',
+			'--statistics',
 			"$tempdir/compression_gzip_dir",
 		],
 	},
@@ -150,7 +150,7 @@ my %pgdump_runs = (
 			'--format' => 'plain',
 			'--compress' => '1',
 			'--file' => "$tempdir/compression_gzip_plain.sql.gz",
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 		# Decompress the generated file to run through the tests.
@@ -169,13 +169,13 @@ my %pgdump_runs = (
 			'--format' => 'custom',
 			'--compress' => 'lz4',
 			'--file' => "$tempdir/compression_lz4_custom.dump",
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 		restore_cmd => [
 			'pg_restore',
 			'--file' => "$tempdir/compression_lz4_custom.sql",
-			'--with-statistics',
+			'--statistics',
 			"$tempdir/compression_lz4_custom.dump",
 		],
 		command_like => {
@@ -198,7 +198,7 @@ my %pgdump_runs = (
 			'--format' => 'directory',
 			'--compress' => 'lz4:1',
 			'--file' => "$tempdir/compression_lz4_dir",
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 		# Verify that data files were compressed
@@ -210,7 +210,7 @@ my %pgdump_runs = (
 			'pg_restore',
 			'--jobs' => '2',
 			'--file' => "$tempdir/compression_lz4_dir.sql",
-			'--with-statistics',
+			'--statistics',
 			"$tempdir/compression_lz4_dir",
 		],
 	},
@@ -223,7 +223,7 @@ my %pgdump_runs = (
 			'--format' => 'plain',
 			'--compress' => 'lz4',
 			'--file' => "$tempdir/compression_lz4_plain.sql.lz4",
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 		# Decompress the generated file to run through the tests.
@@ -245,13 +245,13 @@ my %pgdump_runs = (
 			'--format' => 'custom',
 			'--compress' => 'zstd',
 			'--file' => "$tempdir/compression_zstd_custom.dump",
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 		restore_cmd => [
 			'pg_restore',
 			'--file' => "$tempdir/compression_zstd_custom.sql",
-			'--with-statistics',
+			'--statistics',
 			"$tempdir/compression_zstd_custom.dump",
 		],
 		command_like => {
@@ -273,7 +273,7 @@ my %pgdump_runs = (
 			'--format' => 'directory',
 			'--compress' => 'zstd:1',
 			'--file' => "$tempdir/compression_zstd_dir",
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 		# Give coverage for manually compressed blobs.toc files during
@@ -294,7 +294,7 @@ my %pgdump_runs = (
 			'pg_restore',
 			'--jobs' => '2',
 			'--file' => "$tempdir/compression_zstd_dir.sql",
-			'--with-statistics',
+			'--statistics',
 			"$tempdir/compression_zstd_dir",
 		],
 	},
@@ -308,7 +308,7 @@ my %pgdump_runs = (
 			'--format' => 'plain',
 			'--compress' => 'zstd:long',
 			'--file' => "$tempdir/compression_zstd_plain.sql.zst",
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 		# Decompress the generated file to run through the tests.
@@ -327,7 +327,7 @@ my %pgdump_runs = (
 			'pg_dump', '--no-sync',
 			'--file' => "$tempdir/clean.sql",
 			'--clean',
-			'--with-statistics',
+			'--statistics',
 			'--dbname' => 'postgres',    # alternative way to specify database
 		],
 	},
@@ -338,7 +338,7 @@ my %pgdump_runs = (
 			'--clean',
 			'--if-exists',
 			'--encoding' => 'UTF8',      # no-op, just for testing
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -357,7 +357,7 @@ my %pgdump_runs = (
 			'--create',
 			'--no-reconnect',    # no-op, just for testing
 			'--verbose',
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -376,7 +376,7 @@ my %pgdump_runs = (
 		dump_cmd => [
 			'pg_dump', '--no-sync',
 			'--file' => "$tempdir/defaults.sql",
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -385,7 +385,7 @@ my %pgdump_runs = (
 		dump_cmd => [
 			'pg_dump', '--no-sync',
 			'--file' => "$tempdir/defaults_no_public.sql",
-			'--with-statistics',
+			'--statistics',
 			'regress_pg_dump_test',
 		],
 	},
@@ -395,7 +395,7 @@ my %pgdump_runs = (
 			'pg_dump', '--no-sync',
 			'--clean',
 			'--file' => "$tempdir/defaults_no_public_clean.sql",
-			'--with-statistics',
+			'--statistics',
 			'regress_pg_dump_test',
 		],
 	},
@@ -404,7 +404,7 @@ my %pgdump_runs = (
 		dump_cmd => [
 			'pg_dump', '--no-sync',
 			'--file' => "$tempdir/defaults_public_owner.sql",
-			'--with-statistics',
+			'--statistics',
 			'regress_public_owner',
 		],
 	},
@@ -419,14 +419,14 @@ my %pgdump_runs = (
 			'pg_dump',
 			'--format' => 'custom',
 			'--file' => "$tempdir/defaults_custom_format.dump",
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 		restore_cmd => [
 			'pg_restore',
 			'--format' => 'custom',
 			'--file' => "$tempdir/defaults_custom_format.sql",
-			'--with-statistics',
+			'--statistics',
 			"$tempdir/defaults_custom_format.dump",
 		],
 		command_like => {
@@ -451,14 +451,14 @@ my %pgdump_runs = (
 			'pg_dump',
 			'--format' => 'directory',
 			'--file' => "$tempdir/defaults_dir_format",
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 		restore_cmd => [
 			'pg_restore',
 			'--format' => 'directory',
 			'--file' => "$tempdir/defaults_dir_format.sql",
-			'--with-statistics',
+			'--statistics',
 			"$tempdir/defaults_dir_format",
 		],
 		command_like => {
@@ -484,13 +484,13 @@ my %pgdump_runs = (
 			'--format' => 'directory',
 			'--jobs' => 2,
 			'--file' => "$tempdir/defaults_parallel",
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 		restore_cmd => [
 			'pg_restore',
 			'--file' => "$tempdir/defaults_parallel.sql",
-			'--with-statistics',
+			'--statistics',
 			"$tempdir/defaults_parallel",
 		],
 	},
@@ -502,14 +502,14 @@ my %pgdump_runs = (
 			'pg_dump',
 			'--format' => 'tar',
 			'--file' => "$tempdir/defaults_tar_format.tar",
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 		restore_cmd => [
 			'pg_restore',
 			'--format' => 'tar',
 			'--file' => "$tempdir/defaults_tar_format.sql",
-			'--with-statistics',
+			'--statistics',
 			"$tempdir/defaults_tar_format.tar",
 		],
 	},
@@ -518,7 +518,7 @@ my %pgdump_runs = (
 			'pg_dump', '--no-sync',
 			'--file' => "$tempdir/exclude_dump_test_schema.sql",
 			'--exclude-schema' => 'dump_test',
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -527,7 +527,7 @@ my %pgdump_runs = (
 			'pg_dump', '--no-sync',
 			'--file' => "$tempdir/exclude_test_table.sql",
 			'--exclude-table' => 'dump_test.test_table',
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -536,7 +536,7 @@ my %pgdump_runs = (
 			'pg_dump', '--no-sync',
 			'--file' => "$tempdir/exclude_measurement.sql",
 			'--exclude-table-and-children' => 'dump_test.measurement',
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -546,7 +546,7 @@ my %pgdump_runs = (
 			'--file' => "$tempdir/exclude_measurement_data.sql",
 			'--exclude-table-data-and-children' => 'dump_test.measurement',
 			'--no-unlogged-table-data',
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -556,7 +556,7 @@ my %pgdump_runs = (
 			'--file' => "$tempdir/exclude_test_table_data.sql",
 			'--exclude-table-data' => 'dump_test.test_table',
 			'--no-unlogged-table-data',
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -575,7 +575,7 @@ my %pgdump_runs = (
 			'--file' => "$tempdir/pg_dumpall_globals.sql",
 			'--globals-only',
 			'--no-sync',
-			'--with-statistics',
+			'--statistics',
 		],
 	},
 	pg_dumpall_globals_clean => {
@@ -585,14 +585,14 @@ my %pgdump_runs = (
 			'--globals-only',
 			'--clean',
 			'--no-sync',
-			'--with-statistics',
+			'--statistics',
 		],
 	},
 	pg_dumpall_dbprivs => {
 		dump_cmd => [
 			'pg_dumpall', '--no-sync',
 			'--file' => "$tempdir/pg_dumpall_dbprivs.sql",
-			'--with-statistics',
+			'--statistics',
 		],
 	},
 	pg_dumpall_exclude => {
@@ -602,7 +602,7 @@ my %pgdump_runs = (
 			'--file' => "$tempdir/pg_dumpall_exclude.sql",
 			'--exclude-database' => '*dump_test*',
 			'--no-sync',
-			'--with-statistics',
+			'--statistics',
 		],
 	},
 	no_toast_compression => {
@@ -610,7 +610,7 @@ my %pgdump_runs = (
 			'pg_dump', '--no-sync',
 			'--file' => "$tempdir/no_toast_compression.sql",
 			'--no-toast-compression',
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -619,7 +619,7 @@ my %pgdump_runs = (
 			'pg_dump', '--no-sync',
 			'--file' => "$tempdir/no_large_objects.sql",
 			'--no-large-objects',
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -628,7 +628,7 @@ my %pgdump_runs = (
 			'pg_dump', '--no-sync',
 			'--file' => "$tempdir/no_policies.sql",
 			'--no-policies',
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -637,7 +637,7 @@ my %pgdump_runs = (
 			'pg_dump', '--no-sync',
 			'--file' => "$tempdir/no_privs.sql",
 			'--no-privileges',
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -646,7 +646,7 @@ my %pgdump_runs = (
 			'pg_dump', '--no-sync',
 			'--file' => "$tempdir/no_owner.sql",
 			'--no-owner',
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -655,7 +655,7 @@ my %pgdump_runs = (
 			'pg_dump', '--no-sync',
 			'--file' => "$tempdir/no_table_access_method.sql",
 			'--no-table-access-method',
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -664,7 +664,7 @@ my %pgdump_runs = (
 			'pg_dump', '--no-sync',
 			'--file' => "$tempdir/only_dump_test_schema.sql",
 			'--schema' => 'dump_test',
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -675,7 +675,7 @@ my %pgdump_runs = (
 			'--table' => 'dump_test.test_table',
 			'--lock-wait-timeout' =>
 			  (1000 * $PostgreSQL::Test::Utils::timeout_default),
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -686,7 +686,7 @@ my %pgdump_runs = (
 			'--table-and-children' => 'dump_test.measurement',
 			'--lock-wait-timeout' =>
 			  (1000 * $PostgreSQL::Test::Utils::timeout_default),
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -696,7 +696,7 @@ my %pgdump_runs = (
 			'--file' => "$tempdir/role.sql",
 			'--role' => 'regress_dump_test_role',
 			'--schema' => 'dump_test_second_schema',
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -709,13 +709,13 @@ my %pgdump_runs = (
 			'--file' => "$tempdir/role_parallel",
 			'--role' => 'regress_dump_test_role',
 			'--schema' => 'dump_test_second_schema',
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 		restore_cmd => [
 			'pg_restore',
 			'--file' => "$tempdir/role_parallel.sql",
-			'--with-statistics',
+			'--statistics',
 			"$tempdir/role_parallel",
 		],
 	},
@@ -744,7 +744,7 @@ my %pgdump_runs = (
 			'pg_dump', '--no-sync',
 			'--file' => "$tempdir/section_pre_data.sql",
 			'--section' => 'pre-data',
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -753,7 +753,7 @@ my %pgdump_runs = (
 			'pg_dump', '--no-sync',
 			'--file' => "$tempdir/section_data.sql",
 			'--section' => 'data',
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -762,7 +762,7 @@ my %pgdump_runs = (
 			'pg_dump', '--no-sync',
 			'--file' => "$tempdir/section_post_data.sql",
 			'--section' => 'post-data',
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -773,7 +773,7 @@ my %pgdump_runs = (
 			'--schema' => 'dump_test',
 			'--large-objects',
 			'--no-large-objects',
-			'--with-statistics',
+			'--statistics',
 			'postgres',
 		],
 	},
@@ -789,7 +789,7 @@ my %pgdump_runs = (
 			'pg_dump', '--no-sync',
 			"--file=$tempdir/no_data_no_schema.sql", '--no-data',
 			'--no-schema', 'postgres',
-			'--with-statistics',
+			'--statistics',
 		],
 	},
 	statistics_only => {
@@ -803,7 +803,7 @@ my %pgdump_runs = (
 		dump_cmd => [
 			'pg_dump', '--no-sync',
 			"--file=$tempdir/no_schema.sql", '--no-schema',
-			'--with-statistics', 'postgres',
+			'--statistics', 'postgres',
 		],
 	},);
 
@@ -5206,10 +5206,10 @@ command_fails_like(
 		'--port' => $port,
 		'--strict-names',
 		'--schema-only',
-		'--with-statistics',
+		'--statistics',
 	],
-	qr/\Qpg_dump: error: options -s\/--schema-only and --with-statistics cannot be used together\E/,
-	'cannot use --schema-only and --with-statistics together');
+	qr/\Qpg_dump: error: options -s\/--schema-only and --statistics cannot be used together\E/,
+	'cannot use --schema-only and --statistics together');
 
 command_fails_like(
 	[
diff --git a/src/bin/pg_upgrade/dump.c b/src/bin/pg_upgrade/dump.c
index 183f08ce1e8..55f6e7b4d9c 100644
--- a/src/bin/pg_upgrade/dump.c
+++ b/src/bin/pg_upgrade/dump.c
@@ -58,7 +58,7 @@ generate_old_dump(void)
 						   (user_opts.transfer_mode == TRANSFER_MODE_SWAP) ?
 						   "" : "--sequence-data",
 						   log_opts.verbose ? "--verbose" : "",
-						   user_opts.do_statistics ? "--with-statistics" : "--no-statistics",
+						   user_opts.do_statistics ? "--statistics" : "--no-statistics",
 						   log_opts.dumpdir,
 						   sql_file_name, escaped_connstr.data);
 
-- 
2.43.0

Reply via email to