Skip to content

Commit a3e8dc1

Browse files
committed
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
1 parent d0c12b9 commit a3e8dc1

File tree

8 files changed

+118
-218
lines changed

8 files changed

+118
-218
lines changed

doc/src/sgml/ref/pg_dump.sgml

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,15 @@ PostgreSQL documentation
13541354
</listitem>
13551355
</varlistentry>
13561356

1357+
<varlistentry>
1358+
<term><option>--statistics</option></term>
1359+
<listitem>
1360+
<para>
1361+
Dump statistics.
1362+
</para>
1363+
</listitem>
1364+
</varlistentry>
1365+
13571366
<varlistentry>
13581367
<term><option>--statistics-only</option></term>
13591368
<listitem>
@@ -1440,33 +1449,6 @@ PostgreSQL documentation
14401449
</listitem>
14411450
</varlistentry>
14421451

1443-
<varlistentry>
1444-
<term><option>--with-data</option></term>
1445-
<listitem>
1446-
<para>
1447-
Dump data. This is the default.
1448-
</para>
1449-
</listitem>
1450-
</varlistentry>
1451-
1452-
<varlistentry>
1453-
<term><option>--with-schema</option></term>
1454-
<listitem>
1455-
<para>
1456-
Dump schema (data definitions). This is the default.
1457-
</para>
1458-
</listitem>
1459-
</varlistentry>
1460-
1461-
<varlistentry>
1462-
<term><option>--with-statistics</option></term>
1463-
<listitem>
1464-
<para>
1465-
Dump statistics.
1466-
</para>
1467-
</listitem>
1468-
</varlistentry>
1469-
14701452
<varlistentry>
14711453
<term><option>-?</option></term>
14721454
<term><option>--help</option></term>
@@ -1682,7 +1664,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
16821664
</para>
16831665

16841666
<para>
1685-
If <option>--with-statistics</option> is specified,
1667+
If <option>--statistics</option> is specified,
16861668
<command>pg_dump</command> will include most optimizer statistics in the
16871669
resulting dump file. However, some statistics may not be included, such as
16881670
those created explicitly with <xref linkend="sql-createstatistics"/> or

doc/src/sgml/ref/pg_dumpall.sgml

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,15 @@ exclude database <replaceable class="parameter">PATTERN</replaceable>
605605
</listitem>
606606
</varlistentry>
607607

608+
<varlistentry>
609+
<term><option>--statistics</option></term>
610+
<listitem>
611+
<para>
612+
Dump statistics.
613+
</para>
614+
</listitem>
615+
</varlistentry>
616+
608617
<varlistentry>
609618
<term><option>--statistics-only</option></term>
610619
<listitem>
@@ -640,33 +649,6 @@ exclude database <replaceable class="parameter">PATTERN</replaceable>
640649
</listitem>
641650
</varlistentry>
642651

643-
<varlistentry>
644-
<term><option>--with-data</option></term>
645-
<listitem>
646-
<para>
647-
Dump data. This is the default.
648-
</para>
649-
</listitem>
650-
</varlistentry>
651-
652-
<varlistentry>
653-
<term><option>--with-schema</option></term>
654-
<listitem>
655-
<para>
656-
Dump schema (data definitions). This is the default.
657-
</para>
658-
</listitem>
659-
</varlistentry>
660-
661-
<varlistentry>
662-
<term><option>--with-statistics</option></term>
663-
<listitem>
664-
<para>
665-
Dump statistics.
666-
</para>
667-
</listitem>
668-
</varlistentry>
669-
670652
<varlistentry>
671653
<term><option>-?</option></term>
672654
<term><option>--help</option></term>
@@ -878,7 +860,7 @@ exclude database <replaceable class="parameter">PATTERN</replaceable>
878860
</para>
879861

880862
<para>
881-
If <option>--with-statistics</option> is specified,
863+
If <option>--statistics</option> is specified,
882864
<command>pg_dumpall</command> will include most optimizer statistics in the
883865
resulting dump file. However, some statistics may not be included, such as
884866
those created explicitly with <xref linkend="sql-createstatistics"/> or

doc/src/sgml/ref/pg_restore.sgml

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,16 @@ PostgreSQL documentation
815815
</listitem>
816816
</varlistentry>
817817

818+
<varlistentry>
819+
<term><option>--statistics</option></term>
820+
<listitem>
821+
<para>
822+
Output commands to restore statistics, if the archive contains them.
823+
This is the default.
824+
</para>
825+
</listitem>
826+
</varlistentry>
827+
818828
<varlistentry>
819829
<term><option>--statistics-only</option></term>
820830
<listitem>
@@ -873,36 +883,6 @@ PostgreSQL documentation
873883
</listitem>
874884
</varlistentry>
875885

876-
<varlistentry>
877-
<term><option>--with-data</option></term>
878-
<listitem>
879-
<para>
880-
Output commands to restore data, if the archive contains them.
881-
This is the default.
882-
</para>
883-
</listitem>
884-
</varlistentry>
885-
886-
<varlistentry>
887-
<term><option>--with-schema</option></term>
888-
<listitem>
889-
<para>
890-
Output commands to restore schema (data definitions), if the archive
891-
contains them. This is the default.
892-
</para>
893-
</listitem>
894-
</varlistentry>
895-
896-
<varlistentry>
897-
<term><option>--with-statistics</option></term>
898-
<listitem>
899-
<para>
900-
Output commands to restore statistics, if the archive contains them.
901-
This is the default.
902-
</para>
903-
</listitem>
904-
</varlistentry>
905-
906886
<varlistentry>
907887
<term><option>-?</option></term>
908888
<term><option>--help</option></term>

src/bin/pg_dump/pg_dump.c

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,6 @@ main(int argc, char **argv)
441441
bool data_only = false;
442442
bool schema_only = false;
443443
bool statistics_only = false;
444-
bool with_data = false;
445-
bool with_schema = false;
446444
bool with_statistics = false;
447445
bool no_data = false;
448446
bool no_schema = false;
@@ -506,6 +504,7 @@ main(int argc, char **argv)
506504
{"section", required_argument, NULL, 5},
507505
{"serializable-deferrable", no_argument, &dopt.serializable_deferrable, 1},
508506
{"snapshot", required_argument, NULL, 6},
507+
{"statistics", no_argument, NULL, 22},
509508
{"statistics-only", no_argument, NULL, 18},
510509
{"strict-names", no_argument, &strict_names, 1},
511510
{"use-set-session-authorization", no_argument, &dopt.use_setsessauth, 1},
@@ -520,9 +519,6 @@ main(int argc, char **argv)
520519
{"no-toast-compression", no_argument, &dopt.no_toast_compression, 1},
521520
{"no-unlogged-table-data", no_argument, &dopt.no_unlogged_table_data, 1},
522521
{"no-sync", no_argument, NULL, 7},
523-
{"with-data", no_argument, NULL, 22},
524-
{"with-schema", no_argument, NULL, 23},
525-
{"with-statistics", no_argument, NULL, 24},
526522
{"on-conflict-do-nothing", no_argument, &dopt.do_nothing, 1},
527523
{"rows-per-insert", required_argument, NULL, 10},
528524
{"include-foreign-data", required_argument, NULL, 11},
@@ -790,14 +786,6 @@ main(int argc, char **argv)
790786
break;
791787

792788
case 22:
793-
with_data = true;
794-
break;
795-
796-
case 23:
797-
with_schema = true;
798-
break;
799-
800-
case 24:
801789
with_statistics = true;
802790
break;
803791

@@ -844,24 +832,17 @@ main(int argc, char **argv)
844832
if (statistics_only && no_statistics)
845833
pg_fatal("options --statistics-only and --no-statistics cannot be used together");
846834

847-
/* reject conflicting "with-" and "no-" options */
848-
if (with_data && no_data)
849-
pg_fatal("options --with-data and --no-data cannot be used together");
850-
if (with_schema && no_schema)
851-
pg_fatal("options --with-schema and --no-schema cannot be used together");
835+
/* reject conflicting "no-" options */
852836
if (with_statistics && no_statistics)
853-
pg_fatal("options --with-statistics and --no-statistics cannot be used together");
837+
pg_fatal("options --statistics and --no-statistics cannot be used together");
854838

855-
/* reject conflicting "-only" and "with-" options */
856-
if (data_only && (with_schema || with_statistics))
857-
pg_fatal("options %s and %s cannot be used together",
858-
"-a/--data-only", with_schema ? "--with-schema" : "--with-statistics");
859-
if (schema_only && (with_data || with_statistics))
839+
/* reject conflicting "-only" options */
840+
if (data_only && with_statistics)
860841
pg_fatal("options %s and %s cannot be used together",
861-
"-s/--schema-only", with_data ? "--with-data" : "--with-statistics");
862-
if (statistics_only && (with_data || with_schema))
842+
"-a/--data-only", "--statistics");
843+
if (schema_only && with_statistics)
863844
pg_fatal("options %s and %s cannot be used together",
864-
"--statistics-only", with_data ? "--with-data" : "--with-schema");
845+
"-s/--schema-only", "--statistics");
865846

866847
if (schema_only && foreign_servers_include_patterns.head != NULL)
867848
pg_fatal("options -s/--schema-only and --include-foreign-data cannot be used together");
@@ -881,9 +862,9 @@ main(int argc, char **argv)
881862
* of the checks above.
882863
*/
883864
dopt.dumpData = ((dopt.dumpData && !schema_only && !statistics_only) ||
884-
(data_only || with_data)) && !no_data;
865+
data_only) && !no_data;
885866
dopt.dumpSchema = ((dopt.dumpSchema && !data_only && !statistics_only) ||
886-
(schema_only || with_schema)) && !no_schema;
867+
schema_only) && !no_schema;
887868
dopt.dumpStatistics = ((dopt.dumpStatistics && !schema_only && !data_only) ||
888869
(statistics_only || with_statistics)) && !no_statistics;
889870

@@ -1326,6 +1307,7 @@ help(const char *progname)
13261307
printf(_(" --sequence-data include sequence data in dump\n"));
13271308
printf(_(" --serializable-deferrable wait until the dump can run without anomalies\n"));
13281309
printf(_(" --snapshot=SNAPSHOT use given snapshot for the dump\n"));
1310+
printf(_(" --statistics dump the statistics\n"));
13291311
printf(_(" --statistics-only dump only the statistics, not schema or data\n"));
13301312
printf(_(" --strict-names require table and/or schema include patterns to\n"
13311313
" match at least one entity each\n"));
@@ -1334,9 +1316,6 @@ help(const char *progname)
13341316
printf(_(" --use-set-session-authorization\n"
13351317
" use SET SESSION AUTHORIZATION commands instead of\n"
13361318
" ALTER OWNER commands to set ownership\n"));
1337-
printf(_(" --with-data dump the data\n"));
1338-
printf(_(" --with-schema dump the schema\n"));
1339-
printf(_(" --with-statistics dump the statistics\n"));
13401319

13411320
printf(_("\nConnection options:\n"));
13421321
printf(_(" -d, --dbname=DBNAME database to dump\n"));

src/bin/pg_dump/pg_dumpall.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ static int no_subscriptions = 0;
105105
static int no_toast_compression = 0;
106106
static int no_unlogged_table_data = 0;
107107
static int no_role_passwords = 0;
108-
static int with_data = 0;
109-
static int with_schema = 0;
110108
static int with_statistics = 0;
111109
static int server_version;
112110
static int load_via_partition_root = 0;
@@ -180,11 +178,9 @@ main(int argc, char *argv[])
180178
{"no-sync", no_argument, NULL, 4},
181179
{"no-toast-compression", no_argument, &no_toast_compression, 1},
182180
{"no-unlogged-table-data", no_argument, &no_unlogged_table_data, 1},
183-
{"with-data", no_argument, &with_data, 1},
184-
{"with-schema", no_argument, &with_schema, 1},
185-
{"with-statistics", no_argument, &with_statistics, 1},
186181
{"on-conflict-do-nothing", no_argument, &on_conflict_do_nothing, 1},
187182
{"rows-per-insert", required_argument, NULL, 7},
183+
{"statistics", no_argument, &with_statistics, 1},
188184
{"statistics-only", no_argument, &statistics_only, 1},
189185
{"filter", required_argument, NULL, 8},
190186
{"sequence-data", no_argument, &sequence_data, 1},
@@ -475,12 +471,8 @@ main(int argc, char *argv[])
475471
appendPQExpBufferStr(pgdumpopts, " --no-toast-compression");
476472
if (no_unlogged_table_data)
477473
appendPQExpBufferStr(pgdumpopts, " --no-unlogged-table-data");
478-
if (with_data)
479-
appendPQExpBufferStr(pgdumpopts, " --with-data");
480-
if (with_schema)
481-
appendPQExpBufferStr(pgdumpopts, " --with-schema");
482474
if (with_statistics)
483-
appendPQExpBufferStr(pgdumpopts, " --with-statistics");
475+
appendPQExpBufferStr(pgdumpopts, " --statistics");
484476
if (on_conflict_do_nothing)
485477
appendPQExpBufferStr(pgdumpopts, " --on-conflict-do-nothing");
486478
if (statistics_only)
@@ -712,13 +704,11 @@ help(void)
712704
printf(_(" --quote-all-identifiers quote all identifiers, even if not key words\n"));
713705
printf(_(" --rows-per-insert=NROWS number of rows per INSERT; implies --inserts\n"));
714706
printf(_(" --sequence-data include sequence data in dump\n"));
707+
printf(_(" --statistics dump the statistics\n"));
715708
printf(_(" --statistics-only dump only the statistics, not schema or data\n"));
716709
printf(_(" --use-set-session-authorization\n"
717710
" use SET SESSION AUTHORIZATION commands instead of\n"
718711
" ALTER OWNER commands to set ownership\n"));
719-
printf(_(" --with-data dump the data\n"));
720-
printf(_(" --with-schema dump the schema\n"));
721-
printf(_(" --with-statistics dump the statistics\n"));
722712

723713
printf(_("\nConnection options:\n"));
724714
printf(_(" -d, --dbname=CONNSTR connect using connection string\n"));

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy