@@ -860,6 +860,17 @@ main(int argc, char **argv)
860860	if (with_statistics && no_statistics)
861861		pg_fatal("options --with-statistics and --no-statistics cannot be used together");
862862
863+ 	/* reject conflicting "-only" and "with-" options */
864+ 	if (data_only && (with_schema || with_statistics))
865+ 		pg_fatal("options %s and %s cannot be used together",
866+ 				 "-a/--data-only", with_schema ? "--with-schema" : "--with-statistics");
867+ 	if (schema_only && (with_data || with_statistics))
868+ 		pg_fatal("options %s and %s cannot be used together",
869+ 				 "-s/--schema-only", with_data ? "--with-data" : "--with-statistics");
870+ 	if (statistics_only && (with_data || with_schema))
871+ 		pg_fatal("options %s and %s cannot be used together",
872+ 				 "--statistics-only", with_data ? "--with-data" : "--with-schema");
873+ 
863874	if (schema_only && foreign_servers_include_patterns.head != NULL)
864875		pg_fatal("options -s/--schema-only and --include-foreign-data cannot be used together");
865876
@@ -873,11 +884,9 @@ main(int argc, char **argv)
873884		pg_fatal("option --if-exists requires option -c/--clean");
874885
875886	/*
876- 	 * Set derivative flags. An "-only" option may be overridden by an
877- 	 * explicit "with-" option; e.g. "--schema-only --with-statistics" will
878- 	 * include schema and statistics. Other ambiguous or nonsensical
879- 	 * combinations, e.g. "--schema-only --no-schema", will have already
880- 	 * caused an error in one of the checks above.
887+ 	 * Set derivative flags. Ambiguous or nonsensical combinations, e.g.
888+ 	 * "--schema-only --no-schema", will have already caused an error in one
889+ 	 * of the checks above.
881890	 */
882891	dopt.dumpData = ((dopt.dumpData && !schema_only && !statistics_only) ||
883892					 (data_only || with_data)) && !no_data;
0 commit comments