1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-09 17:03:00 +03:00

Simplify options in pg_dump and pg_restore.

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

Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/f379d0aeefe8effe13302a436bc28f549f09e924.camel@j-davis.com
Backpatch-through: 18
This commit is contained in:
Jeff Davis
2025-08-02 07:51:35 -07:00
parent d0c12b98f2
commit a3e8dc1438
8 changed files with 118 additions and 218 deletions

View File

@@ -1354,6 +1354,15 @@ PostgreSQL documentation
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>--statistics</option></term>
<listitem>
<para>
Dump statistics.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>--statistics-only</option></term> <term><option>--statistics-only</option></term>
<listitem> <listitem>
@@ -1440,33 +1449,6 @@ PostgreSQL documentation
</listitem> </listitem>
</varlistentry> </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>
<listitem>
<para>
Dump statistics.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>-?</option></term> <term><option>-?</option></term>
<term><option>--help</option></term> <term><option>--help</option></term>
@@ -1682,7 +1664,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
</para> </para>
<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 <command>pg_dump</command> will include most optimizer statistics in the
resulting dump file. However, some statistics may not be included, such as resulting dump file. However, some statistics may not be included, such as
those created explicitly with <xref linkend="sql-createstatistics"/> or those created explicitly with <xref linkend="sql-createstatistics"/> or

View File

@@ -605,6 +605,15 @@ exclude database <replaceable class="parameter">PATTERN</replaceable>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>--statistics</option></term>
<listitem>
<para>
Dump statistics.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>--statistics-only</option></term> <term><option>--statistics-only</option></term>
<listitem> <listitem>
@@ -640,33 +649,6 @@ exclude database <replaceable class="parameter">PATTERN</replaceable>
</listitem> </listitem>
</varlistentry> </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>
<listitem>
<para>
Dump statistics.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>-?</option></term> <term><option>-?</option></term>
<term><option>--help</option></term> <term><option>--help</option></term>
@@ -878,7 +860,7 @@ exclude database <replaceable class="parameter">PATTERN</replaceable>
</para> </para>
<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 <command>pg_dumpall</command> will include most optimizer statistics in the
resulting dump file. However, some statistics may not be included, such as resulting dump file. However, some statistics may not be included, such as
those created explicitly with <xref linkend="sql-createstatistics"/> or those created explicitly with <xref linkend="sql-createstatistics"/> or

View File

@@ -815,6 +815,16 @@ PostgreSQL documentation
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>--statistics</option></term>
<listitem>
<para>
Output commands to restore statistics, if the archive contains them.
This is the default.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>--statistics-only</option></term> <term><option>--statistics-only</option></term>
<listitem> <listitem>
@@ -873,36 +883,6 @@ PostgreSQL documentation
</listitem> </listitem>
</varlistentry> </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>
<listitem>
<para>
Output commands to restore statistics, if the archive contains them.
This is the default.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>-?</option></term> <term><option>-?</option></term>
<term><option>--help</option></term> <term><option>--help</option></term>

View File

@@ -441,8 +441,6 @@ main(int argc, char **argv)
bool data_only = false; bool data_only = false;
bool schema_only = false; bool schema_only = false;
bool statistics_only = false; bool statistics_only = false;
bool with_data = false;
bool with_schema = false;
bool with_statistics = false; bool with_statistics = false;
bool no_data = false; bool no_data = false;
bool no_schema = false; bool no_schema = false;
@@ -506,6 +504,7 @@ main(int argc, char **argv)
{"section", required_argument, NULL, 5}, {"section", required_argument, NULL, 5},
{"serializable-deferrable", no_argument, &dopt.serializable_deferrable, 1}, {"serializable-deferrable", no_argument, &dopt.serializable_deferrable, 1},
{"snapshot", required_argument, NULL, 6}, {"snapshot", required_argument, NULL, 6},
{"statistics", no_argument, NULL, 22},
{"statistics-only", no_argument, NULL, 18}, {"statistics-only", no_argument, NULL, 18},
{"strict-names", no_argument, &strict_names, 1}, {"strict-names", no_argument, &strict_names, 1},
{"use-set-session-authorization", no_argument, &dopt.use_setsessauth, 1}, {"use-set-session-authorization", no_argument, &dopt.use_setsessauth, 1},
@@ -520,9 +519,6 @@ main(int argc, char **argv)
{"no-toast-compression", no_argument, &dopt.no_toast_compression, 1}, {"no-toast-compression", no_argument, &dopt.no_toast_compression, 1},
{"no-unlogged-table-data", no_argument, &dopt.no_unlogged_table_data, 1}, {"no-unlogged-table-data", no_argument, &dopt.no_unlogged_table_data, 1},
{"no-sync", no_argument, NULL, 7}, {"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}, {"on-conflict-do-nothing", no_argument, &dopt.do_nothing, 1},
{"rows-per-insert", required_argument, NULL, 10}, {"rows-per-insert", required_argument, NULL, 10},
{"include-foreign-data", required_argument, NULL, 11}, {"include-foreign-data", required_argument, NULL, 11},
@@ -790,14 +786,6 @@ main(int argc, char **argv)
break; break;
case 22: case 22:
with_data = true;
break;
case 23:
with_schema = true;
break;
case 24:
with_statistics = true; with_statistics = true;
break; break;
@@ -844,24 +832,17 @@ main(int argc, char **argv)
if (statistics_only && no_statistics) if (statistics_only && no_statistics)
pg_fatal("options --statistics-only and --no-statistics cannot be used together"); pg_fatal("options --statistics-only and --no-statistics cannot be used together");
/* reject conflicting "with-" and "no-" options */ /* reject conflicting "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");
if (with_statistics && no_statistics) 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 */ /* reject conflicting "-only" options */
if (data_only && (with_schema || with_statistics)) if (data_only && with_statistics)
pg_fatal("options %s and %s cannot be used together", pg_fatal("options %s and %s cannot be used together",
"-a/--data-only", with_schema ? "--with-schema" : "--with-statistics"); "-a/--data-only", "--statistics");
if (schema_only && (with_data || with_statistics)) if (schema_only && with_statistics)
pg_fatal("options %s and %s cannot be used together", pg_fatal("options %s and %s cannot be used together",
"-s/--schema-only", with_data ? "--with-data" : "--with-statistics"); "-s/--schema-only", "--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");
if (schema_only && foreign_servers_include_patterns.head != NULL) if (schema_only && foreign_servers_include_patterns.head != NULL)
pg_fatal("options -s/--schema-only and --include-foreign-data cannot be used together"); pg_fatal("options -s/--schema-only and --include-foreign-data cannot be used together");
@@ -881,9 +862,9 @@ main(int argc, char **argv)
* of the checks above. * of the checks above.
*/ */
dopt.dumpData = ((dopt.dumpData && !schema_only && !statistics_only) || 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) || 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) || dopt.dumpStatistics = ((dopt.dumpStatistics && !schema_only && !data_only) ||
(statistics_only || with_statistics)) && !no_statistics; (statistics_only || with_statistics)) && !no_statistics;
@@ -1326,6 +1307,7 @@ help(const char *progname)
printf(_(" --sequence-data include sequence data in dump\n")); printf(_(" --sequence-data include sequence data in dump\n"));
printf(_(" --serializable-deferrable wait until the dump can run without anomalies\n")); printf(_(" --serializable-deferrable wait until the dump can run without anomalies\n"));
printf(_(" --snapshot=SNAPSHOT use given snapshot for the dump\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(_(" --statistics-only dump only the statistics, not schema or data\n"));
printf(_(" --strict-names require table and/or schema include patterns to\n" printf(_(" --strict-names require table and/or schema include patterns to\n"
" match at least one entity each\n")); " match at least one entity each\n"));
@@ -1334,9 +1316,6 @@ help(const char *progname)
printf(_(" --use-set-session-authorization\n" printf(_(" --use-set-session-authorization\n"
" use SET SESSION AUTHORIZATION commands instead of\n" " use SET SESSION AUTHORIZATION commands instead of\n"
" ALTER OWNER commands to set ownership\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(_("\nConnection options:\n"));
printf(_(" -d, --dbname=DBNAME database to dump\n")); printf(_(" -d, --dbname=DBNAME database to dump\n"));

View File

@@ -105,8 +105,6 @@ static int no_subscriptions = 0;
static int no_toast_compression = 0; static int no_toast_compression = 0;
static int no_unlogged_table_data = 0; static int no_unlogged_table_data = 0;
static int no_role_passwords = 0; static int no_role_passwords = 0;
static int with_data = 0;
static int with_schema = 0;
static int with_statistics = 0; static int with_statistics = 0;
static int server_version; static int server_version;
static int load_via_partition_root = 0; static int load_via_partition_root = 0;
@@ -180,11 +178,9 @@ main(int argc, char *argv[])
{"no-sync", no_argument, NULL, 4}, {"no-sync", no_argument, NULL, 4},
{"no-toast-compression", no_argument, &no_toast_compression, 1}, {"no-toast-compression", no_argument, &no_toast_compression, 1},
{"no-unlogged-table-data", no_argument, &no_unlogged_table_data, 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}, {"on-conflict-do-nothing", no_argument, &on_conflict_do_nothing, 1},
{"rows-per-insert", required_argument, NULL, 7}, {"rows-per-insert", required_argument, NULL, 7},
{"statistics", no_argument, &with_statistics, 1},
{"statistics-only", no_argument, &statistics_only, 1}, {"statistics-only", no_argument, &statistics_only, 1},
{"filter", required_argument, NULL, 8}, {"filter", required_argument, NULL, 8},
{"sequence-data", no_argument, &sequence_data, 1}, {"sequence-data", no_argument, &sequence_data, 1},
@@ -475,12 +471,8 @@ main(int argc, char *argv[])
appendPQExpBufferStr(pgdumpopts, " --no-toast-compression"); appendPQExpBufferStr(pgdumpopts, " --no-toast-compression");
if (no_unlogged_table_data) if (no_unlogged_table_data)
appendPQExpBufferStr(pgdumpopts, " --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) if (with_statistics)
appendPQExpBufferStr(pgdumpopts, " --with-statistics"); appendPQExpBufferStr(pgdumpopts, " --statistics");
if (on_conflict_do_nothing) if (on_conflict_do_nothing)
appendPQExpBufferStr(pgdumpopts, " --on-conflict-do-nothing"); appendPQExpBufferStr(pgdumpopts, " --on-conflict-do-nothing");
if (statistics_only) if (statistics_only)
@@ -712,13 +704,11 @@ help(void)
printf(_(" --quote-all-identifiers quote all identifiers, even if not key words\n")); 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(_(" --rows-per-insert=NROWS number of rows per INSERT; implies --inserts\n"));
printf(_(" --sequence-data include sequence data in dump\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(_(" --statistics-only dump only the statistics, not schema or data\n"));
printf(_(" --use-set-session-authorization\n" printf(_(" --use-set-session-authorization\n"
" use SET SESSION AUTHORIZATION commands instead of\n" " use SET SESSION AUTHORIZATION commands instead of\n"
" ALTER OWNER commands to set ownership\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(_("\nConnection options:\n"));
printf(_(" -d, --dbname=CONNSTR connect using connection string\n")); printf(_(" -d, --dbname=CONNSTR connect using connection string\n"));

View File

@@ -82,8 +82,6 @@ main(int argc, char **argv)
static int no_subscriptions = 0; static int no_subscriptions = 0;
static int strict_names = 0; static int strict_names = 0;
static int statistics_only = 0; static int statistics_only = 0;
static int with_data = 0;
static int with_schema = 0;
static int with_statistics = 0; static int with_statistics = 0;
struct option cmdopts[] = { struct option cmdopts[] = {
@@ -139,9 +137,7 @@ main(int argc, char **argv)
{"no-security-labels", no_argument, &no_security_labels, 1}, {"no-security-labels", no_argument, &no_security_labels, 1},
{"no-subscriptions", no_argument, &no_subscriptions, 1}, {"no-subscriptions", no_argument, &no_subscriptions, 1},
{"no-statistics", no_argument, &no_statistics, 1}, {"no-statistics", no_argument, &no_statistics, 1},
{"with-data", no_argument, &with_data, 1}, {"statistics", no_argument, &with_statistics, 1},
{"with-schema", no_argument, &with_schema, 1},
{"with-statistics", no_argument, &with_statistics, 1},
{"statistics-only", no_argument, &statistics_only, 1}, {"statistics-only", no_argument, &statistics_only, 1},
{"filter", required_argument, NULL, 4}, {"filter", required_argument, NULL, 4},
@@ -373,24 +369,17 @@ main(int argc, char **argv)
if (statistics_only && no_statistics) if (statistics_only && no_statistics)
pg_fatal("options --statistics-only and --no-statistics cannot be used together"); pg_fatal("options --statistics-only and --no-statistics cannot be used together");
/* reject conflicting "with-" and "no-" options */ /* reject conflicting "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");
if (with_statistics && no_statistics) 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 */ /* reject conflicting "only-" options */
if (data_only && (with_schema || with_statistics)) if (data_only && with_statistics)
pg_fatal("options %s and %s cannot be used together", pg_fatal("options %s and %s cannot be used together",
"-a/--data-only", with_schema ? "--with-schema" : "--with-statistics"); "-a/--data-only", "--statistics");
if (schema_only && (with_data || with_statistics)) if (schema_only && with_statistics)
pg_fatal("options %s and %s cannot be used together", pg_fatal("options %s and %s cannot be used together",
"-s/--schema-only", with_data ? "--with-data" : "--with-statistics"); "-s/--schema-only", "--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");
if (data_only && opts->dropSchema) if (data_only && opts->dropSchema)
pg_fatal("options -c/--clean and -a/--data-only cannot be used together"); 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. * of the checks above.
*/ */
opts->dumpData = ((opts->dumpData && !schema_only && !statistics_only) || 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) || 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) || opts->dumpStatistics = ((opts->dumpStatistics && !schema_only && !data_only) ||
(statistics_only || with_statistics)) && !no_statistics; (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-table-access-method do not restore table access methods\n"));
printf(_(" --no-tablespaces do not restore tablespace assignments\n")); printf(_(" --no-tablespaces do not restore tablespace assignments\n"));
printf(_(" --section=SECTION restore named section (pre-data, data, or post-data)\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(_(" --statistics-only restore only the statistics, not schema or data\n"));
printf(_(" --strict-names require table and/or schema include patterns to\n" printf(_(" --strict-names require table and/or schema include patterns to\n"
" match at least one entity each\n")); " match at least one entity each\n"));
@@ -565,9 +555,6 @@ usage(const char *progname)
printf(_(" --use-set-session-authorization\n" printf(_(" --use-set-session-authorization\n"
" use SET SESSION AUTHORIZATION commands instead of\n" " use SET SESSION AUTHORIZATION commands instead of\n"
" ALTER OWNER commands to set ownership\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(_("\nConnection options:\n"));
printf(_(" -h, --host=HOSTNAME database server host or socket directory\n")); printf(_(" -h, --host=HOSTNAME database server host or socket directory\n"));

View File

@@ -68,7 +68,7 @@ my %pgdump_runs = (
'--no-data', '--no-data',
'--sequence-data', '--sequence-data',
'--binary-upgrade', '--binary-upgrade',
'--with-statistics', '--statistics',
'--dbname' => 'postgres', # alternative way to specify database '--dbname' => 'postgres', # alternative way to specify database
], ],
restore_cmd => [ restore_cmd => [
@@ -76,7 +76,7 @@ my %pgdump_runs = (
'--format' => 'custom', '--format' => 'custom',
'--verbose', '--verbose',
'--file' => "$tempdir/binary_upgrade.sql", '--file' => "$tempdir/binary_upgrade.sql",
'--with-statistics', '--statistics',
"$tempdir/binary_upgrade.dump", "$tempdir/binary_upgrade.dump",
], ],
}, },
@@ -90,13 +90,13 @@ my %pgdump_runs = (
'--format' => 'custom', '--format' => 'custom',
'--compress' => '1', '--compress' => '1',
'--file' => "$tempdir/compression_gzip_custom.dump", '--file' => "$tempdir/compression_gzip_custom.dump",
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
restore_cmd => [ restore_cmd => [
'pg_restore', 'pg_restore',
'--file' => "$tempdir/compression_gzip_custom.sql", '--file' => "$tempdir/compression_gzip_custom.sql",
'--with-statistics', '--statistics',
"$tempdir/compression_gzip_custom.dump", "$tempdir/compression_gzip_custom.dump",
], ],
command_like => { command_like => {
@@ -119,7 +119,7 @@ my %pgdump_runs = (
'--format' => 'directory', '--format' => 'directory',
'--compress' => 'gzip:1', '--compress' => 'gzip:1',
'--file' => "$tempdir/compression_gzip_dir", '--file' => "$tempdir/compression_gzip_dir",
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
# Give coverage for manually compressed blobs.toc files during # Give coverage for manually compressed blobs.toc files during
@@ -137,7 +137,7 @@ my %pgdump_runs = (
'pg_restore', 'pg_restore',
'--jobs' => '2', '--jobs' => '2',
'--file' => "$tempdir/compression_gzip_dir.sql", '--file' => "$tempdir/compression_gzip_dir.sql",
'--with-statistics', '--statistics',
"$tempdir/compression_gzip_dir", "$tempdir/compression_gzip_dir",
], ],
}, },
@@ -150,7 +150,7 @@ my %pgdump_runs = (
'--format' => 'plain', '--format' => 'plain',
'--compress' => '1', '--compress' => '1',
'--file' => "$tempdir/compression_gzip_plain.sql.gz", '--file' => "$tempdir/compression_gzip_plain.sql.gz",
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
# Decompress the generated file to run through the tests. # Decompress the generated file to run through the tests.
@@ -169,13 +169,13 @@ my %pgdump_runs = (
'--format' => 'custom', '--format' => 'custom',
'--compress' => 'lz4', '--compress' => 'lz4',
'--file' => "$tempdir/compression_lz4_custom.dump", '--file' => "$tempdir/compression_lz4_custom.dump",
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
restore_cmd => [ restore_cmd => [
'pg_restore', 'pg_restore',
'--file' => "$tempdir/compression_lz4_custom.sql", '--file' => "$tempdir/compression_lz4_custom.sql",
'--with-statistics', '--statistics',
"$tempdir/compression_lz4_custom.dump", "$tempdir/compression_lz4_custom.dump",
], ],
command_like => { command_like => {
@@ -198,7 +198,7 @@ my %pgdump_runs = (
'--format' => 'directory', '--format' => 'directory',
'--compress' => 'lz4:1', '--compress' => 'lz4:1',
'--file' => "$tempdir/compression_lz4_dir", '--file' => "$tempdir/compression_lz4_dir",
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
# Verify that data files were compressed # Verify that data files were compressed
@@ -210,7 +210,7 @@ my %pgdump_runs = (
'pg_restore', 'pg_restore',
'--jobs' => '2', '--jobs' => '2',
'--file' => "$tempdir/compression_lz4_dir.sql", '--file' => "$tempdir/compression_lz4_dir.sql",
'--with-statistics', '--statistics',
"$tempdir/compression_lz4_dir", "$tempdir/compression_lz4_dir",
], ],
}, },
@@ -223,7 +223,7 @@ my %pgdump_runs = (
'--format' => 'plain', '--format' => 'plain',
'--compress' => 'lz4', '--compress' => 'lz4',
'--file' => "$tempdir/compression_lz4_plain.sql.lz4", '--file' => "$tempdir/compression_lz4_plain.sql.lz4",
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
# Decompress the generated file to run through the tests. # Decompress the generated file to run through the tests.
@@ -245,13 +245,13 @@ my %pgdump_runs = (
'--format' => 'custom', '--format' => 'custom',
'--compress' => 'zstd', '--compress' => 'zstd',
'--file' => "$tempdir/compression_zstd_custom.dump", '--file' => "$tempdir/compression_zstd_custom.dump",
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
restore_cmd => [ restore_cmd => [
'pg_restore', 'pg_restore',
'--file' => "$tempdir/compression_zstd_custom.sql", '--file' => "$tempdir/compression_zstd_custom.sql",
'--with-statistics', '--statistics',
"$tempdir/compression_zstd_custom.dump", "$tempdir/compression_zstd_custom.dump",
], ],
command_like => { command_like => {
@@ -273,7 +273,7 @@ my %pgdump_runs = (
'--format' => 'directory', '--format' => 'directory',
'--compress' => 'zstd:1', '--compress' => 'zstd:1',
'--file' => "$tempdir/compression_zstd_dir", '--file' => "$tempdir/compression_zstd_dir",
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
# Give coverage for manually compressed blobs.toc files during # Give coverage for manually compressed blobs.toc files during
@@ -294,7 +294,7 @@ my %pgdump_runs = (
'pg_restore', 'pg_restore',
'--jobs' => '2', '--jobs' => '2',
'--file' => "$tempdir/compression_zstd_dir.sql", '--file' => "$tempdir/compression_zstd_dir.sql",
'--with-statistics', '--statistics',
"$tempdir/compression_zstd_dir", "$tempdir/compression_zstd_dir",
], ],
}, },
@@ -308,7 +308,7 @@ my %pgdump_runs = (
'--format' => 'plain', '--format' => 'plain',
'--compress' => 'zstd:long', '--compress' => 'zstd:long',
'--file' => "$tempdir/compression_zstd_plain.sql.zst", '--file' => "$tempdir/compression_zstd_plain.sql.zst",
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
# Decompress the generated file to run through the tests. # Decompress the generated file to run through the tests.
@@ -327,7 +327,7 @@ my %pgdump_runs = (
'pg_dump', '--no-sync', 'pg_dump', '--no-sync',
'--file' => "$tempdir/clean.sql", '--file' => "$tempdir/clean.sql",
'--clean', '--clean',
'--with-statistics', '--statistics',
'--dbname' => 'postgres', # alternative way to specify database '--dbname' => 'postgres', # alternative way to specify database
], ],
}, },
@@ -338,7 +338,7 @@ my %pgdump_runs = (
'--clean', '--clean',
'--if-exists', '--if-exists',
'--encoding' => 'UTF8', # no-op, just for testing '--encoding' => 'UTF8', # no-op, just for testing
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -357,7 +357,7 @@ my %pgdump_runs = (
'--create', '--create',
'--no-reconnect', # no-op, just for testing '--no-reconnect', # no-op, just for testing
'--verbose', '--verbose',
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -376,7 +376,7 @@ my %pgdump_runs = (
dump_cmd => [ dump_cmd => [
'pg_dump', '--no-sync', 'pg_dump', '--no-sync',
'--file' => "$tempdir/defaults.sql", '--file' => "$tempdir/defaults.sql",
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -385,7 +385,7 @@ my %pgdump_runs = (
dump_cmd => [ dump_cmd => [
'pg_dump', '--no-sync', 'pg_dump', '--no-sync',
'--file' => "$tempdir/defaults_no_public.sql", '--file' => "$tempdir/defaults_no_public.sql",
'--with-statistics', '--statistics',
'regress_pg_dump_test', 'regress_pg_dump_test',
], ],
}, },
@@ -395,7 +395,7 @@ my %pgdump_runs = (
'pg_dump', '--no-sync', 'pg_dump', '--no-sync',
'--clean', '--clean',
'--file' => "$tempdir/defaults_no_public_clean.sql", '--file' => "$tempdir/defaults_no_public_clean.sql",
'--with-statistics', '--statistics',
'regress_pg_dump_test', 'regress_pg_dump_test',
], ],
}, },
@@ -404,7 +404,7 @@ my %pgdump_runs = (
dump_cmd => [ dump_cmd => [
'pg_dump', '--no-sync', 'pg_dump', '--no-sync',
'--file' => "$tempdir/defaults_public_owner.sql", '--file' => "$tempdir/defaults_public_owner.sql",
'--with-statistics', '--statistics',
'regress_public_owner', 'regress_public_owner',
], ],
}, },
@@ -419,14 +419,14 @@ my %pgdump_runs = (
'pg_dump', 'pg_dump',
'--format' => 'custom', '--format' => 'custom',
'--file' => "$tempdir/defaults_custom_format.dump", '--file' => "$tempdir/defaults_custom_format.dump",
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
restore_cmd => [ restore_cmd => [
'pg_restore', 'pg_restore',
'--format' => 'custom', '--format' => 'custom',
'--file' => "$tempdir/defaults_custom_format.sql", '--file' => "$tempdir/defaults_custom_format.sql",
'--with-statistics', '--statistics',
"$tempdir/defaults_custom_format.dump", "$tempdir/defaults_custom_format.dump",
], ],
command_like => { command_like => {
@@ -451,14 +451,14 @@ my %pgdump_runs = (
'pg_dump', 'pg_dump',
'--format' => 'directory', '--format' => 'directory',
'--file' => "$tempdir/defaults_dir_format", '--file' => "$tempdir/defaults_dir_format",
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
restore_cmd => [ restore_cmd => [
'pg_restore', 'pg_restore',
'--format' => 'directory', '--format' => 'directory',
'--file' => "$tempdir/defaults_dir_format.sql", '--file' => "$tempdir/defaults_dir_format.sql",
'--with-statistics', '--statistics',
"$tempdir/defaults_dir_format", "$tempdir/defaults_dir_format",
], ],
command_like => { command_like => {
@@ -484,13 +484,13 @@ my %pgdump_runs = (
'--format' => 'directory', '--format' => 'directory',
'--jobs' => 2, '--jobs' => 2,
'--file' => "$tempdir/defaults_parallel", '--file' => "$tempdir/defaults_parallel",
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
restore_cmd => [ restore_cmd => [
'pg_restore', 'pg_restore',
'--file' => "$tempdir/defaults_parallel.sql", '--file' => "$tempdir/defaults_parallel.sql",
'--with-statistics', '--statistics',
"$tempdir/defaults_parallel", "$tempdir/defaults_parallel",
], ],
}, },
@@ -502,14 +502,14 @@ my %pgdump_runs = (
'pg_dump', 'pg_dump',
'--format' => 'tar', '--format' => 'tar',
'--file' => "$tempdir/defaults_tar_format.tar", '--file' => "$tempdir/defaults_tar_format.tar",
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
restore_cmd => [ restore_cmd => [
'pg_restore', 'pg_restore',
'--format' => 'tar', '--format' => 'tar',
'--file' => "$tempdir/defaults_tar_format.sql", '--file' => "$tempdir/defaults_tar_format.sql",
'--with-statistics', '--statistics',
"$tempdir/defaults_tar_format.tar", "$tempdir/defaults_tar_format.tar",
], ],
}, },
@@ -518,7 +518,7 @@ my %pgdump_runs = (
'pg_dump', '--no-sync', 'pg_dump', '--no-sync',
'--file' => "$tempdir/exclude_dump_test_schema.sql", '--file' => "$tempdir/exclude_dump_test_schema.sql",
'--exclude-schema' => 'dump_test', '--exclude-schema' => 'dump_test',
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -527,7 +527,7 @@ my %pgdump_runs = (
'pg_dump', '--no-sync', 'pg_dump', '--no-sync',
'--file' => "$tempdir/exclude_test_table.sql", '--file' => "$tempdir/exclude_test_table.sql",
'--exclude-table' => 'dump_test.test_table', '--exclude-table' => 'dump_test.test_table',
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -536,7 +536,7 @@ my %pgdump_runs = (
'pg_dump', '--no-sync', 'pg_dump', '--no-sync',
'--file' => "$tempdir/exclude_measurement.sql", '--file' => "$tempdir/exclude_measurement.sql",
'--exclude-table-and-children' => 'dump_test.measurement', '--exclude-table-and-children' => 'dump_test.measurement',
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -546,7 +546,7 @@ my %pgdump_runs = (
'--file' => "$tempdir/exclude_measurement_data.sql", '--file' => "$tempdir/exclude_measurement_data.sql",
'--exclude-table-data-and-children' => 'dump_test.measurement', '--exclude-table-data-and-children' => 'dump_test.measurement',
'--no-unlogged-table-data', '--no-unlogged-table-data',
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -556,7 +556,7 @@ my %pgdump_runs = (
'--file' => "$tempdir/exclude_test_table_data.sql", '--file' => "$tempdir/exclude_test_table_data.sql",
'--exclude-table-data' => 'dump_test.test_table', '--exclude-table-data' => 'dump_test.test_table',
'--no-unlogged-table-data', '--no-unlogged-table-data',
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -575,7 +575,7 @@ my %pgdump_runs = (
'--file' => "$tempdir/pg_dumpall_globals.sql", '--file' => "$tempdir/pg_dumpall_globals.sql",
'--globals-only', '--globals-only',
'--no-sync', '--no-sync',
'--with-statistics', '--statistics',
], ],
}, },
pg_dumpall_globals_clean => { pg_dumpall_globals_clean => {
@@ -585,14 +585,14 @@ my %pgdump_runs = (
'--globals-only', '--globals-only',
'--clean', '--clean',
'--no-sync', '--no-sync',
'--with-statistics', '--statistics',
], ],
}, },
pg_dumpall_dbprivs => { pg_dumpall_dbprivs => {
dump_cmd => [ dump_cmd => [
'pg_dumpall', '--no-sync', 'pg_dumpall', '--no-sync',
'--file' => "$tempdir/pg_dumpall_dbprivs.sql", '--file' => "$tempdir/pg_dumpall_dbprivs.sql",
'--with-statistics', '--statistics',
], ],
}, },
pg_dumpall_exclude => { pg_dumpall_exclude => {
@@ -602,7 +602,7 @@ my %pgdump_runs = (
'--file' => "$tempdir/pg_dumpall_exclude.sql", '--file' => "$tempdir/pg_dumpall_exclude.sql",
'--exclude-database' => '*dump_test*', '--exclude-database' => '*dump_test*',
'--no-sync', '--no-sync',
'--with-statistics', '--statistics',
], ],
}, },
no_toast_compression => { no_toast_compression => {
@@ -610,7 +610,7 @@ my %pgdump_runs = (
'pg_dump', '--no-sync', 'pg_dump', '--no-sync',
'--file' => "$tempdir/no_toast_compression.sql", '--file' => "$tempdir/no_toast_compression.sql",
'--no-toast-compression', '--no-toast-compression',
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -619,7 +619,7 @@ my %pgdump_runs = (
'pg_dump', '--no-sync', 'pg_dump', '--no-sync',
'--file' => "$tempdir/no_large_objects.sql", '--file' => "$tempdir/no_large_objects.sql",
'--no-large-objects', '--no-large-objects',
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -628,7 +628,7 @@ my %pgdump_runs = (
'pg_dump', '--no-sync', 'pg_dump', '--no-sync',
'--file' => "$tempdir/no_policies.sql", '--file' => "$tempdir/no_policies.sql",
'--no-policies', '--no-policies',
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -637,7 +637,7 @@ my %pgdump_runs = (
'pg_dump', '--no-sync', 'pg_dump', '--no-sync',
'--file' => "$tempdir/no_privs.sql", '--file' => "$tempdir/no_privs.sql",
'--no-privileges', '--no-privileges',
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -646,7 +646,7 @@ my %pgdump_runs = (
'pg_dump', '--no-sync', 'pg_dump', '--no-sync',
'--file' => "$tempdir/no_owner.sql", '--file' => "$tempdir/no_owner.sql",
'--no-owner', '--no-owner',
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -655,7 +655,7 @@ my %pgdump_runs = (
'pg_dump', '--no-sync', 'pg_dump', '--no-sync',
'--file' => "$tempdir/no_table_access_method.sql", '--file' => "$tempdir/no_table_access_method.sql",
'--no-table-access-method', '--no-table-access-method',
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -664,7 +664,7 @@ my %pgdump_runs = (
'pg_dump', '--no-sync', 'pg_dump', '--no-sync',
'--file' => "$tempdir/only_dump_test_schema.sql", '--file' => "$tempdir/only_dump_test_schema.sql",
'--schema' => 'dump_test', '--schema' => 'dump_test',
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -675,7 +675,7 @@ my %pgdump_runs = (
'--table' => 'dump_test.test_table', '--table' => 'dump_test.test_table',
'--lock-wait-timeout' => '--lock-wait-timeout' =>
(1000 * $PostgreSQL::Test::Utils::timeout_default), (1000 * $PostgreSQL::Test::Utils::timeout_default),
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -686,7 +686,7 @@ my %pgdump_runs = (
'--table-and-children' => 'dump_test.measurement', '--table-and-children' => 'dump_test.measurement',
'--lock-wait-timeout' => '--lock-wait-timeout' =>
(1000 * $PostgreSQL::Test::Utils::timeout_default), (1000 * $PostgreSQL::Test::Utils::timeout_default),
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -696,7 +696,7 @@ my %pgdump_runs = (
'--file' => "$tempdir/role.sql", '--file' => "$tempdir/role.sql",
'--role' => 'regress_dump_test_role', '--role' => 'regress_dump_test_role',
'--schema' => 'dump_test_second_schema', '--schema' => 'dump_test_second_schema',
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -709,13 +709,13 @@ my %pgdump_runs = (
'--file' => "$tempdir/role_parallel", '--file' => "$tempdir/role_parallel",
'--role' => 'regress_dump_test_role', '--role' => 'regress_dump_test_role',
'--schema' => 'dump_test_second_schema', '--schema' => 'dump_test_second_schema',
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
restore_cmd => [ restore_cmd => [
'pg_restore', 'pg_restore',
'--file' => "$tempdir/role_parallel.sql", '--file' => "$tempdir/role_parallel.sql",
'--with-statistics', '--statistics',
"$tempdir/role_parallel", "$tempdir/role_parallel",
], ],
}, },
@@ -744,7 +744,7 @@ my %pgdump_runs = (
'pg_dump', '--no-sync', 'pg_dump', '--no-sync',
'--file' => "$tempdir/section_pre_data.sql", '--file' => "$tempdir/section_pre_data.sql",
'--section' => 'pre-data', '--section' => 'pre-data',
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -753,7 +753,7 @@ my %pgdump_runs = (
'pg_dump', '--no-sync', 'pg_dump', '--no-sync',
'--file' => "$tempdir/section_data.sql", '--file' => "$tempdir/section_data.sql",
'--section' => 'data', '--section' => 'data',
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -762,7 +762,7 @@ my %pgdump_runs = (
'pg_dump', '--no-sync', 'pg_dump', '--no-sync',
'--file' => "$tempdir/section_post_data.sql", '--file' => "$tempdir/section_post_data.sql",
'--section' => 'post-data', '--section' => 'post-data',
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -773,7 +773,7 @@ my %pgdump_runs = (
'--schema' => 'dump_test', '--schema' => 'dump_test',
'--large-objects', '--large-objects',
'--no-large-objects', '--no-large-objects',
'--with-statistics', '--statistics',
'postgres', 'postgres',
], ],
}, },
@@ -789,7 +789,7 @@ my %pgdump_runs = (
'pg_dump', '--no-sync', 'pg_dump', '--no-sync',
"--file=$tempdir/no_data_no_schema.sql", '--no-data', "--file=$tempdir/no_data_no_schema.sql", '--no-data',
'--no-schema', 'postgres', '--no-schema', 'postgres',
'--with-statistics', '--statistics',
], ],
}, },
statistics_only => { statistics_only => {
@@ -803,7 +803,7 @@ my %pgdump_runs = (
dump_cmd => [ dump_cmd => [
'pg_dump', '--no-sync', 'pg_dump', '--no-sync',
"--file=$tempdir/no_schema.sql", '--no-schema', "--file=$tempdir/no_schema.sql", '--no-schema',
'--with-statistics', 'postgres', '--statistics', 'postgres',
], ],
},); },);
@@ -5204,10 +5204,10 @@ command_fails_like(
'--port' => $port, '--port' => $port,
'--strict-names', '--strict-names',
'--schema-only', '--schema-only',
'--with-statistics', '--statistics',
], ],
qr/\Qpg_dump: error: options -s\/--schema-only and --with-statistics cannot be used together\E/, qr/\Qpg_dump: error: options -s\/--schema-only and --statistics cannot be used together\E/,
'cannot use --schema-only and --with-statistics together'); 'cannot use --schema-only and --statistics together');
command_fails_like( command_fails_like(
[ [

View File

@@ -58,7 +58,7 @@ generate_old_dump(void)
(user_opts.transfer_mode == TRANSFER_MODE_SWAP) ? (user_opts.transfer_mode == TRANSFER_MODE_SWAP) ?
"" : "--sequence-data", "" : "--sequence-data",
log_opts.verbose ? "--verbose" : "", log_opts.verbose ? "--verbose" : "",
user_opts.do_statistics ? "--with-statistics" : "--no-statistics", user_opts.do_statistics ? "--statistics" : "--no-statistics",
log_opts.dumpdir, log_opts.dumpdir,
sql_file_name, escaped_connstr.data); sql_file_name, escaped_connstr.data);