@@ -2520,6 +2520,9 @@ main(int argc, char **argv)
2520
2520
char * filename = NULL ;
2521
2521
bool scale_given = false;
2522
2522
2523
+ bool benchmarking_option_set = false;
2524
+ bool initialization_option_set = false;
2525
+
2523
2526
CState * state ; /* status of clients */
2524
2527
TState * threads ; /* array of thread */
2525
2528
@@ -2599,11 +2602,14 @@ main(int argc, char **argv)
2599
2602
break ;
2600
2603
case 'S' :
2601
2604
ttype = 1 ;
2605
+ benchmarking_option_set = true;
2602
2606
break ;
2603
2607
case 'N' :
2604
2608
ttype = 2 ;
2609
+ benchmarking_option_set = true;
2605
2610
break ;
2606
2611
case 'c' :
2612
+ benchmarking_option_set = true;
2607
2613
nclients = atoi (optarg );
2608
2614
if (nclients <= 0 || nclients > MAXCLIENTS )
2609
2615
{
@@ -2629,6 +2635,7 @@ main(int argc, char **argv)
2629
2635
#endif /* HAVE_GETRLIMIT */
2630
2636
break ;
2631
2637
case 'j' : /* jobs */
2638
+ benchmarking_option_set = true;
2632
2639
nthreads = atoi (optarg );
2633
2640
if (nthreads <= 0 )
2634
2641
{
@@ -2637,9 +2644,11 @@ main(int argc, char **argv)
2637
2644
}
2638
2645
break ;
2639
2646
case 'C' :
2647
+ benchmarking_option_set = true;
2640
2648
is_connect = true;
2641
2649
break ;
2642
2650
case 'r' :
2651
+ benchmarking_option_set = true;
2643
2652
is_latencies = true;
2644
2653
break ;
2645
2654
case 's' :
@@ -2652,6 +2661,7 @@ main(int argc, char **argv)
2652
2661
}
2653
2662
break ;
2654
2663
case 't' :
2664
+ benchmarking_option_set = true;
2655
2665
if (duration > 0 )
2656
2666
{
2657
2667
fprintf (stderr , "specify either a number of transactions (-t) or a duration (-T), not both.\n" );
@@ -2665,6 +2675,7 @@ main(int argc, char **argv)
2665
2675
}
2666
2676
break ;
2667
2677
case 'T' :
2678
+ benchmarking_option_set = true;
2668
2679
if (nxacts > 0 )
2669
2680
{
2670
2681
fprintf (stderr , "specify either a number of transactions (-t) or a duration (-T), not both.\n" );
@@ -2681,12 +2692,15 @@ main(int argc, char **argv)
2681
2692
login = pg_strdup (optarg );
2682
2693
break ;
2683
2694
case 'l' :
2695
+ benchmarking_option_set = true;
2684
2696
use_log = true;
2685
2697
break ;
2686
2698
case 'q' :
2699
+ initialization_option_set = true;
2687
2700
use_quiet = true;
2688
2701
break ;
2689
2702
case 'f' :
2703
+ benchmarking_option_set = true;
2690
2704
ttype = 3 ;
2691
2705
filename = pg_strdup (optarg );
2692
2706
if (process_file (filename ) == false || * sql_files [num_files - 1 ] == NULL )
@@ -2696,6 +2710,8 @@ main(int argc, char **argv)
2696
2710
{
2697
2711
char * p ;
2698
2712
2713
+ benchmarking_option_set = true;
2714
+
2699
2715
if ((p = strchr (optarg , '=' )) == NULL || p == optarg || * (p + 1 ) == '\0' )
2700
2716
{
2701
2717
fprintf (stderr , "invalid variable definition: %s\n" , optarg );
@@ -2708,6 +2724,7 @@ main(int argc, char **argv)
2708
2724
}
2709
2725
break ;
2710
2726
case 'F' :
2727
+ initialization_option_set = true;
2711
2728
fillfactor = atoi (optarg );
2712
2729
if ((fillfactor < 10 ) || (fillfactor > 100 ))
2713
2730
{
@@ -2716,6 +2733,7 @@ main(int argc, char **argv)
2716
2733
}
2717
2734
break ;
2718
2735
case 'M' :
2736
+ benchmarking_option_set = true;
2719
2737
if (num_files > 0 )
2720
2738
{
2721
2739
fprintf (stderr , "query mode (-M) should be specifiled before transaction scripts (-f)\n" );
@@ -2731,6 +2749,7 @@ main(int argc, char **argv)
2731
2749
}
2732
2750
break ;
2733
2751
case 'P' :
2752
+ benchmarking_option_set = true;
2734
2753
progress = atoi (optarg );
2735
2754
if (progress <= 0 )
2736
2755
{
@@ -2745,6 +2764,8 @@ main(int argc, char **argv)
2745
2764
/* get a double from the beginning of option value */
2746
2765
double throttle_value = atof (optarg );
2747
2766
2767
+ benchmarking_option_set = true;
2768
+
2748
2769
if (throttle_value <= 0.0 )
2749
2770
{
2750
2771
fprintf (stderr , "invalid rate limit: %s\n" , optarg );
@@ -2756,14 +2777,19 @@ main(int argc, char **argv)
2756
2777
break ;
2757
2778
case 0 :
2758
2779
/* This covers long options which take no argument. */
2780
+ if (foreign_keys || unlogged_tables )
2781
+ initialization_option_set = true;
2759
2782
break ;
2760
2783
case 2 : /* tablespace */
2784
+ initialization_option_set = true;
2761
2785
tablespace = pg_strdup (optarg );
2762
2786
break ;
2763
2787
case 3 : /* index-tablespace */
2788
+ initialization_option_set = true;
2764
2789
index_tablespace = pg_strdup (optarg );
2765
2790
break ;
2766
2791
case 4 :
2792
+ benchmarking_option_set = true;
2767
2793
sample_rate = atof (optarg );
2768
2794
if (sample_rate <= 0.0 || sample_rate > 1.0 )
2769
2795
{
@@ -2776,6 +2802,7 @@ main(int argc, char **argv)
2776
2802
fprintf (stderr , "--aggregate-interval is not currently supported on Windows" );
2777
2803
exit (1 );
2778
2804
#else
2805
+ benchmarking_option_set = true;
2779
2806
agg_interval = atoi (optarg );
2780
2807
if (agg_interval <= 0 )
2781
2808
{
@@ -2808,9 +2835,23 @@ main(int argc, char **argv)
2808
2835
2809
2836
if (is_init_mode )
2810
2837
{
2838
+ if (benchmarking_option_set )
2839
+ {
2840
+ fprintf (stderr , "some options cannot be used in initialization (-i) mode\n" );
2841
+ exit (1 );
2842
+ }
2843
+
2811
2844
init (is_no_vacuum );
2812
2845
exit (0 );
2813
2846
}
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
+ }
2814
2855
2815
2856
/* Use DEFAULT_NXACTS if neither nxacts nor duration is specified. */
2816
2857
if (nxacts <= 0 && duration <= 0 )
@@ -2829,13 +2870,6 @@ main(int argc, char **argv)
2829
2870
exit (1 );
2830
2871
}
2831
2872
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
-
2839
2873
/* --sampling-rate may must not be used with --aggregate-interval */
2840
2874
if (sample_rate > 0.0 && agg_interval > 0 )
2841
2875
{
0 commit comments