</listitem>
</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. This is the default.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><option>--on-conflict-do-nothing</option></term>
<listitem>
</listitem>
</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. This is the default.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><option>--no-unlogged-table-data</option></term>
<listitem>
</listitem>
</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. This is the default.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><option>--section=<replaceable class="parameter">sectionname</replaceable></option></term>
<listitem>
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;
bool no_statistics = false;
{"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},
no_statistics = true;
break;
+ case 22:
+ with_data = true;
+ break;
+
+ case 23:
+ with_schema = true;
+ break;
+
+ case 24:
+ with_statistics = true;
+ break;
+
default:
/* getopt_long already emitted a complaint */
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
if (dopt.column_inserts && dopt.dump_inserts == 0)
dopt.dump_inserts = DUMP_DEFAULT_ROWS_PER_INSERT;
+ /* reject conflicting "-only" options */
if (data_only && schema_only)
pg_fatal("options -s/--schema-only and -a/--data-only cannot be used together");
if (schema_only && statistics_only)
if (data_only && statistics_only)
pg_fatal("options -a/--data-only and --statistics-only cannot be used together");
+ /* reject conflicting "-only" and "no-" options */
if (data_only && no_data)
pg_fatal("options -a/--data-only and --no-data cannot be used together");
if (schema_only && no_schema)
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");
+ if (with_statistics && no_statistics)
+ pg_fatal("options --with-statistics and --no-statistics cannot be used together");
+
if (schema_only && foreign_servers_include_patterns.head != NULL)
pg_fatal("options -s/--schema-only and --include-foreign-data cannot be used together");
if (dopt.if_exists && !dopt.outputClean)
pg_fatal("option --if-exists requires option -c/--clean");
- /* set derivative flags */
- dopt.dumpData = data_only || (!schema_only && !statistics_only && !no_data);
- dopt.dumpSchema = schema_only || (!data_only && !statistics_only && !no_schema);
- dopt.dumpStatistics = statistics_only || (!data_only && !schema_only && !no_statistics);
+ /*
+ * Set derivative flags. An "-only" option may be overridden by an
+ * explicit "with-" option; e.g. "--schema-only --with-statistics" will
+ * include schema and statistics. Other ambiguous or nonsensical
+ * combinations, e.g. "--schema-only --no-schema", will have already
+ * caused an error in one of the checks above.
+ */
+ dopt.dumpData = ((dopt.dumpData && !schema_only && !statistics_only) ||
+ (data_only || with_data)) && !no_data;
+ dopt.dumpSchema = ((dopt.dumpSchema && !data_only && !statistics_only) ||
+ (schema_only || with_schema)) && !no_schema;
+ dopt.dumpStatistics = ((dopt.dumpStatistics && !schema_only && !data_only) ||
+ (statistics_only || with_statistics)) && !no_statistics;
+
/*
* --inserts are already implied above if --column-inserts or
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"));
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;
static int on_conflict_do_nothing = 0;
{"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-only", no_argument, &statistics_only, 1},
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");
if (on_conflict_do_nothing)
appendPQExpBufferStr(pgdumpopts, " --on-conflict-do-nothing");
if (statistics_only)
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"));
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[] = {
{"clean", 0, NULL, 'c'},
{"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-only", no_argument, &statistics_only, 1},
{"filter", required_argument, NULL, 4},
opts->useDB = 1;
}
+ /* reject conflicting "-only" options */
if (data_only && schema_only)
pg_fatal("options -s/--schema-only and -a/--data-only cannot be used together");
- if (data_only && statistics_only)
- pg_fatal("options -a/--data-only and --statistics-only cannot be used together");
if (schema_only && statistics_only)
pg_fatal("options -s/--schema-only and --statistics-only cannot be used together");
+ if (data_only && statistics_only)
+ pg_fatal("options -a/--data-only and --statistics-only cannot be used together");
+
+ /* reject conflicting "-only" and "no-" options */
+ if (data_only && no_data)
+ pg_fatal("options -a/--data-only and --no-data cannot be used together");
+ if (schema_only && no_schema)
+ pg_fatal("options -s/--schema-only and --no-schema cannot be used together");
+ 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");
+ if (with_statistics && no_statistics)
+ pg_fatal("options --with-statistics and --no-statistics cannot be used together");
if (data_only && opts->dropSchema)
pg_fatal("options -c/--clean and -a/--data-only cannot be used together");
if (opts->single_txn && numWorkers > 1)
pg_fatal("cannot specify both --single-transaction and multiple jobs");
- /* set derivative flags */
- opts->dumpData = data_only || (!no_data && !schema_only && !statistics_only);
- opts->dumpSchema = schema_only || (!no_schema && !data_only && !statistics_only);
- opts->dumpStatistics = statistics_only || (!no_statistics && !data_only && !schema_only);
+ /*
+ * Set derivative flags. An "-only" option may be overridden by an
+ * explicit "with-" option; e.g. "--schema-only --with-statistics" will
+ * include schema and statistics. Other ambiguous or nonsensical
+ * combinations, e.g. "--schema-only --no-schema", will have already
+ * caused an error in one of the checks above.
+ */
+ opts->dumpData = ((opts->dumpData && !schema_only && !statistics_only) ||
+ (data_only || with_data)) && !no_data;
+ opts->dumpSchema = ((opts->dumpSchema && !data_only && !statistics_only) ||
+ (schema_only || with_schema)) && !no_schema;
+ opts->dumpStatistics = ((opts->dumpStatistics && !schema_only && !data_only) ||
+ (statistics_only || with_statistics)) && !no_statistics;
opts->disable_triggers = disable_triggers;
opts->enable_row_security = enable_row_security;
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(_(" -h, --host=HOSTNAME database server host or socket directory\n"));
'postgres',
],
},
+ schema_only_with_statistics => {
+ dump_cmd => [
+ 'pg_dump', '--no-sync',
+ "--file=$tempdir/schema_only_with_statistics.sql", '--schema-only',
+ '--with-statistics', 'postgres',
+ ],
+ },
no_schema => {
dump_cmd => [
'pg_dump', '--no-sync',
no_table_access_method => 1,
pg_dumpall_dbprivs => 1,
pg_dumpall_exclude => 1,
- schema_only => 1,);
+ schema_only => 1,
+ schema_only_with_statistics => 1,);
# This is where the actual tests are defined.
my %tests = (
no_large_objects => 1,
no_owner => 1,
schema_only => 1,
+ schema_only_with_statistics => 1,
},
},
},
unlike => {
schema_only => 1,
+ schema_only_with_statistics => 1,
no_large_objects => 1,
},
},
binary_upgrade => 1,
no_large_objects => 1,
schema_only => 1,
+ schema_only_with_statistics => 1,
},
},
binary_upgrade => 1,
no_large_objects => 1,
schema_only => 1,
+ schema_only_with_statistics => 1,
},
},
unlike => {
no_large_objects => 1,
schema_only => 1,
+ schema_only_with_statistics => 1,
},
},
exclude_test_table => 1,
exclude_test_table_data => 1,
schema_only => 1,
+ schema_only_with_statistics => 1,
only_dump_measurement => 1,
},
},
binary_upgrade => 1,
exclude_dump_test_schema => 1,
schema_only => 1,
+ schema_only_with_statistics => 1,
only_dump_measurement => 1,
},
},
binary_upgrade => 1,
exclude_dump_test_schema => 1,
schema_only => 1,
+ schema_only_with_statistics => 1,
only_dump_measurement => 1,
},
},
binary_upgrade => 1,
exclude_dump_test_schema => 1,
schema_only => 1,
+ schema_only_with_statistics => 1,
only_dump_measurement => 1,
},
},
binary_upgrade => 1,
exclude_dump_test_schema => 1,
schema_only => 1,
+ schema_only_with_statistics => 1,
only_dump_measurement => 1,
},
},
binary_upgrade => 1,
exclude_dump_test_schema => 1,
schema_only => 1,
+ schema_only_with_statistics => 1,
only_dump_measurement => 1,
},
},
binary_upgrade => 1,
exclude_dump_test_schema => 1,
schema_only => 1,
+ schema_only_with_statistics => 1,
only_dump_measurement => 1,
},
},
binary_upgrade => 1,
exclude_dump_test_schema => 1,
schema_only => 1,
+ schema_only_with_statistics => 1,
},
},
unlike => {
binary_upgrade => 1,
schema_only => 1,
+ schema_only_with_statistics => 1,
exclude_measurement => 1,
only_dump_test_schema => 1,
test_schema_plus_large_objects => 1,
no_large_objects => 1,
no_privs => 1,
schema_only => 1,
+ schema_only_with_statistics => 1,
},
},
binary_upgrade => 1,
exclude_dump_test_schema => 1,
schema_only => 1,
+ schema_only_with_statistics => 1,
only_dump_measurement => 1,
},
},
binary_upgrade => 1,
exclude_dump_test_schema => 1,
schema_only => 1,
+ schema_only_with_statistics => 1,
only_dump_measurement => 1,
},
},
no_schema => 1,
section_post_data => 1,
statistics_only => 1,
+ schema_only_with_statistics => 1,
},
unlike => {
exclude_dump_test_schema => 1,
section_data => 1,
section_post_data => 1,
statistics_only => 1,
+ schema_only_with_statistics => 1,
},
unlike => {
no_statistics => 1,