diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 9e7cb2c48f..4a2e3e123c 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -818,9 +818,16 @@ main(int argc, char **argv) pg_fatal("option --if-exists requires option -c/--clean"); /* set derivative flags */ - dopt.dumpData = data_only || (!schema_only && !statistics_only && !dopt.no_data); - dopt.dumpSchema = schema_only || (!data_only && !statistics_only && !dopt.no_schema); - dopt.dumpStatistics = statistics_only || (!data_only && !schema_only && !dopt.no_statistics); + dopt.dumpData = data_only || (!schema_only && !statistics_only); + dopt.dumpSchema = schema_only || (!data_only && !statistics_only); + dopt.dumpStatistics = statistics_only || (!data_only && !schema_only); + + if (dopt.no_data) + dopt.dumpData = false; + if (dopt.no_schema) + dopt.dumpSchema = false; + if (dopt.no_statistics) + dopt.dumpStatistics = false; /* * --inserts are already implied above if --column-inserts or diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c index 9586bd032c..4eb40df1cb 100644 --- a/src/bin/pg_dump/pg_restore.c +++ b/src/bin/pg_dump/pg_restore.c @@ -378,9 +378,16 @@ main(int argc, char **argv) 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); + opts->dumpData = data_only || (!schema_only && !statistics_only); + opts->dumpSchema = schema_only || (!data_only && !statistics_only); + opts->dumpStatistics = statistics_only || (!data_only && !schema_only); + + if (opts->no_data) + opts->dumpData = false; + if (opts->no_schema) + opts->dumpSchema = false; + if (opts->no_statistics) + opts->dumpStatistics = false; opts->disable_triggers = disable_triggers; opts->enable_row_security = enable_row_security;