@@ -2520,6 +2520,9 @@ main(int argc, char **argv)
25202520char * filename = NULL ;
25212521bool scale_given = false;
25222522
2523+ bool benchmarking_option_set = false;
2524+ bool initialization_option_set = false;
2525+
25232526CState * state ;/* status of clients */
25242527TState * threads ;/* array of thread */
25252528
@@ -2599,11 +2602,14 @@ main(int argc, char **argv)
25992602break ;
26002603case 'S' :
26012604ttype = 1 ;
2605+ benchmarking_option_set = true;
26022606break ;
26032607case 'N' :
26042608ttype = 2 ;
2609+ benchmarking_option_set = true;
26052610break ;
26062611case 'c' :
2612+ benchmarking_option_set = true;
26072613nclients = atoi (optarg );
26082614if (nclients <=0 || nclients > MAXCLIENTS )
26092615{
@@ -2629,6 +2635,7 @@ main(int argc, char **argv)
26292635#endif /* HAVE_GETRLIMIT */
26302636break ;
26312637case 'j' :/* jobs */
2638+ benchmarking_option_set = true;
26322639nthreads = atoi (optarg );
26332640if (nthreads <=0 )
26342641{
@@ -2637,9 +2644,11 @@ main(int argc, char **argv)
26372644}
26382645break ;
26392646case 'C' :
2647+ benchmarking_option_set = true;
26402648is_connect = true;
26412649break ;
26422650case 'r' :
2651+ benchmarking_option_set = true;
26432652is_latencies = true;
26442653break ;
26452654case 's' :
@@ -2652,6 +2661,7 @@ main(int argc, char **argv)
26522661}
26532662break ;
26542663case 't' :
2664+ benchmarking_option_set = true;
26552665if (duration > 0 )
26562666{
26572667fprintf (stderr ,"specify either a number of transactions (-t) or a duration (-T), not both.\n" );
@@ -2665,6 +2675,7 @@ main(int argc, char **argv)
26652675}
26662676break ;
26672677case 'T' :
2678+ benchmarking_option_set = true;
26682679if (nxacts > 0 )
26692680{
26702681fprintf (stderr ,"specify either a number of transactions (-t) or a duration (-T), not both.\n" );
@@ -2681,12 +2692,15 @@ main(int argc, char **argv)
26812692login = pg_strdup (optarg );
26822693break ;
26832694case 'l' :
2695+ benchmarking_option_set = true;
26842696use_log = true;
26852697break ;
26862698case 'q' :
2699+ initialization_option_set = true;
26872700use_quiet = true;
26882701break ;
26892702case 'f' :
2703+ benchmarking_option_set = true;
26902704ttype = 3 ;
26912705filename = pg_strdup (optarg );
26922706if (process_file (filename )== false|| * sql_files [num_files - 1 ]== NULL )
@@ -2696,6 +2710,8 @@ main(int argc, char **argv)
26962710{
26972711char * p ;
26982712
2713+ benchmarking_option_set = true;
2714+
26992715if ((p = strchr (optarg ,'=' ))== NULL || p == optarg || * (p + 1 )== '\0' )
27002716{
27012717fprintf (stderr ,"invalid variable definition: %s\n" ,optarg );
@@ -2708,6 +2724,7 @@ main(int argc, char **argv)
27082724}
27092725break ;
27102726case 'F' :
2727+ initialization_option_set = true;
27112728fillfactor = atoi (optarg );
27122729if ((fillfactor < 10 )|| (fillfactor > 100 ))
27132730{
@@ -2716,6 +2733,7 @@ main(int argc, char **argv)
27162733}
27172734break ;
27182735case 'M' :
2736+ benchmarking_option_set = true;
27192737if (num_files > 0 )
27202738{
27212739fprintf (stderr ,"query mode (-M) should be specifiled before transaction scripts (-f)\n" );
@@ -2731,6 +2749,7 @@ main(int argc, char **argv)
27312749}
27322750break ;
27332751case 'P' :
2752+ benchmarking_option_set = true;
27342753progress = atoi (optarg );
27352754if (progress <=0 )
27362755{
@@ -2745,6 +2764,8 @@ main(int argc, char **argv)
27452764/* get a double from the beginning of option value */
27462765double throttle_value = atof (optarg );
27472766
2767+ benchmarking_option_set = true;
2768+
27482769if (throttle_value <=0.0 )
27492770{
27502771fprintf (stderr ,"invalid rate limit: %s\n" ,optarg );
@@ -2756,14 +2777,19 @@ main(int argc, char **argv)
27562777break ;
27572778case 0 :
27582779/* This covers long options which take no argument. */
2780+ if (foreign_keys || unlogged_tables )
2781+ initialization_option_set = true;
27592782break ;
27602783case 2 :/* tablespace */
2784+ initialization_option_set = true;
27612785tablespace = pg_strdup (optarg );
27622786break ;
27632787case 3 :/* index-tablespace */
2788+ initialization_option_set = true;
27642789index_tablespace = pg_strdup (optarg );
27652790break ;
27662791case 4 :
2792+ benchmarking_option_set = true;
27672793sample_rate = atof (optarg );
27682794if (sample_rate <=0.0 || sample_rate > 1.0 )
27692795{
@@ -2776,6 +2802,7 @@ main(int argc, char **argv)
27762802fprintf (stderr ,"--aggregate-interval is not currently supported on Windows" );
27772803exit (1 );
27782804#else
2805+ benchmarking_option_set = true;
27792806agg_interval = atoi (optarg );
27802807if (agg_interval <=0 )
27812808{
@@ -2808,9 +2835,23 @@ main(int argc, char **argv)
28082835
28092836if (is_init_mode )
28102837{
2838+ if (benchmarking_option_set )
2839+ {
2840+ fprintf (stderr ,"some options cannot be used in initialization (-i) mode\n" );
2841+ exit (1 );
2842+ }
2843+
28112844init (is_no_vacuum );
28122845exit (0 );
28132846}
2847+ else
2848+ {
2849+ if (initialization_option_set )
2850+ {
2851+ fprintf (stderr ,"some options cannot be used in benchmarking mode\n" );
2852+ exit (1 );
2853+ }
2854+ }
28142855
28152856/* Use DEFAULT_NXACTS if neither nxacts nor duration is specified. */
28162857if (nxacts <=0 && duration <=0 )
@@ -2829,13 +2870,6 @@ main(int argc, char **argv)
28292870exit (1 );
28302871}
28312872
2832- /* -q may be used only with -i */
2833- if (use_quiet && !is_init_mode )
2834- {
2835- fprintf (stderr ,"quiet-logging is allowed only in initialization mode (-i)\n" );
2836- exit (1 );
2837- }
2838-
28392873/* --sampling-rate may must not be used with --aggregate-interval */
28402874if (sample_rate > 0.0 && agg_interval > 0 )
28412875{