@@ -90,7 +90,7 @@ static intpthread_join(pthread_t th, void **thread_return);
9090#define LOG_STEP_SECONDS 5/* seconds between log messages */
9191#define DEFAULT_NXACTS 10/* default nxacts */
9292
93- #define MIN_GAUSSIAN_PARAM 2.0/* minimum parameter for gauss */
93+ #define MIN_GAUSSIAN_PARAM 2.0/* minimum parameter for gauss */
9494
9595int nxacts = 0 ;/* number of transactions per client */
9696int duration = 0 ;/* duration in seconds */
@@ -201,16 +201,15 @@ typedef struct
201201PGconn * con ;/* connection handle to DB */
202202int id ;/* client No. */
203203int state ;/* state No. */
204- int listen ;/*0 indicates that an async query has been
205- * sent */
206- int sleeping ;/*1 indicates that the client is napping */
204+ bool listen ;/*whether an async query has been sent */
205+ bool is_throttled ; /* whether transaction throttling is done */
206+ bool sleeping ;/*whether the client is napping */
207207bool throttling ;/* whether nap is for throttling */
208208Variable * variables ;/* array of variable definitions */
209209int nvariables ;
210210int64 txn_scheduled ;/* scheduled start time of transaction (usec) */
211211instr_time txn_begin ;/* used for measuring schedule lag times */
212212instr_time stmt_begin ;/* used for measuring statement latencies */
213- bool is_throttled ;/* whether transaction throttling is done */
214213int use_file ;/* index in sql_files for this client */
215214bool prepared [MAX_FILES ];
216215
@@ -374,7 +373,7 @@ usage(void)
374373" -f, --file=FILENAME read transaction script from FILENAME\n"
375374" -j, --jobs=NUM number of threads (default: 1)\n"
376375" -l, --log write transaction times to log file\n"
377- " -L, --latency-limit=NUM count transactions lasting more than NUM ms as late\n"
376+ " -L, --latency-limit=NUM count transactions lasting more than NUM ms as late\n"
378377" -M, --protocol=simple|extended|prepared\n"
379378" protocol for submitting queries (default: simple)\n"
380379" -n, --no-vacuum do not run VACUUM before tests\n"
@@ -389,7 +388,7 @@ usage(void)
389388" -v, --vacuum-all vacuum all four standard tables before tests\n"
390389" --aggregate-interval=NUM aggregate data over NUM seconds\n"
391390" --sampling-rate=NUM fraction of transactions to log (e.g. 0.01 for 1%%)\n"
392- " --progress-timestamp use Unix epoch timestamps for progress\n"
391+ " --progress-timestamp use Unix epoch timestamps for progress\n"
393392"\nCommon options:\n"
394393" -d, --debug print debugging output\n"
395394" -h, --host=HOSTNAME database server host or socket directory\n"
@@ -520,16 +519,16 @@ getGaussianRand(TState *thread, int64 min, int64 max, double parameter)
520519double rand ;
521520
522521/*
523- * Get user specified random number from this loop,
524- *with -parameter < stdev <= parameter
522+ * Get user specified random number from this loop, with -parameter <
523+ * stdev <= parameter
525524 *
526525 * This loop is executed until the number is in the expected range.
527526 *
528527 * As the minimum parameter is 2.0, the probability of looping is low:
529528 * sqrt(-2 ln(r)) <= 2 => r >= e^{-2} ~ 0.135, then when taking the
530529 * average sinus multiplier as 2/pi, we have a 8.6% looping probability in
531- * the worst case. For a parameter value of 5.0, the looping probability is
532- * about e^{-5} * 2 / pi ~ 0.43%.
530+ * the worst case. For a parameter value of 5.0, the looping probability
531+ *is about e^{-5} * 2 / pi ~ 0.43%.
533532 */
534533do
535534{
@@ -1191,7 +1190,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
11911190}
11921191}
11931192
1194- st -> sleeping = 1 ;
1193+ st -> sleeping = true ;
11951194st -> throttling = true;
11961195st -> is_throttled = true;
11971196if (debug )
@@ -1208,7 +1207,8 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
12081207now_us = INSTR_TIME_GET_MICROSEC (now );
12091208if (st -> txn_scheduled <=now_us )
12101209{
1211- st -> sleeping = 0 ;/* Done sleeping, go ahead with next command */
1210+ /* Done sleeping, go ahead with next command */
1211+ st -> sleeping = false;
12121212if (st -> throttling )
12131213{
12141214/* Measure lag of throttled transaction relative to target */
@@ -1337,9 +1337,9 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
13371337 * nothing to listen to right now. When throttling rate limits
13381338 * are active, a sleep will happen next, as the next transaction
13391339 * starts. And then in any case the next SQL command will set
1340- * listen back to1 .
1340+ * listen back totrue .
13411341 */
1342- st -> listen = 0 ;
1342+ st -> listen = false ;
13431343trans_needs_throttle = (throttle_delay > 0 );
13441344}
13451345}
@@ -1462,7 +1462,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
14621462st -> ecnt ++ ;
14631463}
14641464else
1465- st -> listen = 1 ;/* flags that should be listened */
1465+ st -> listen = true ;/* flags that should be listened */
14661466}
14671467else if (commands [st -> state ]-> type == META_COMMAND )
14681468{
@@ -1585,8 +1585,8 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
15851585if (parameter <=0.0 )
15861586{
15871587fprintf (stderr ,
1588- "exponential parameter must be greater than zero (not \"%s\")\n" ,
1589- argv [5 ]);
1588+ "exponential parameter must be greater than zero (not \"%s\")\n" ,
1589+ argv [5 ]);
15901590st -> ecnt ++ ;
15911591return true;
15921592}
@@ -1613,7 +1613,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
16131613return true;
16141614}
16151615
1616- st -> listen = 1 ;
1616+ st -> listen = true ;
16171617}
16181618else if (pg_strcasecmp (argv [0 ],"set" )== 0 )
16191619{
@@ -1634,7 +1634,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
16341634return true;
16351635}
16361636
1637- st -> listen = 1 ;
1637+ st -> listen = true ;
16381638}
16391639else if (pg_strcasecmp (argv [0 ],"sleep" )== 0 )
16401640{
@@ -1668,9 +1668,9 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
16681668
16691669INSTR_TIME_SET_CURRENT (now );
16701670st -> txn_scheduled = INSTR_TIME_GET_MICROSEC (now )+ usec ;
1671- st -> sleeping = 1 ;
1671+ st -> sleeping = true ;
16721672
1673- st -> listen = 1 ;
1673+ st -> listen = true ;
16741674}
16751675else if (pg_strcasecmp (argv [0 ],"setshell" )== 0 )
16761676{
@@ -1684,7 +1684,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
16841684return true;
16851685}
16861686else /* succeeded */
1687- st -> listen = 1 ;
1687+ st -> listen = true ;
16881688}
16891689else if (pg_strcasecmp (argv [0 ],"shell" )== 0 )
16901690{
@@ -1698,7 +1698,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
16981698return true;
16991699}
17001700else /* succeeded */
1701- st -> listen = 1 ;
1701+ st -> listen = true ;
17021702}
17031703gototop ;
17041704}
@@ -2207,7 +2207,8 @@ parseQuery(Command *cmd, const char *raw_sql)
22072207return true;
22082208}
22092209
2210- void pg_attribute_noreturn ()
2210+ void
2211+ pg_attribute_noreturn ()
22112212syntax_error (const char * source ,const int lineno ,
22122213const char * line ,const char * command ,
22132214const char * msg ,const char * more ,const int column )
@@ -2289,10 +2290,10 @@ process_commands(char *buf, const char *source, const int lineno)
22892290
22902291if (pg_strcasecmp (my_commands -> argv [0 ],"setrandom" )== 0 )
22912292{
2292- /*
2293+ /*--------
22932294 * parsing:
2294- * \setrandom variable min max [uniform]
2295- * \setrandom variable min max (gaussian|exponential) parameter
2295+ * \setrandom variable min max [uniform]
2296+ * \setrandom variable min max (gaussian|exponential) parameter
22962297 */
22972298
22982299if (my_commands -> argc < 4 )
@@ -2317,7 +2318,7 @@ process_commands(char *buf, const char *source, const int lineno)
23172318if (my_commands -> argc < 6 )
23182319{
23192320syntax_error (source ,lineno ,my_commands -> line ,my_commands -> argv [0 ],
2320- "missing parameter" ,my_commands -> argv [4 ],-1 );
2321+ "missing parameter" ,my_commands -> argv [4 ],-1 );
23212322}
23222323else if (my_commands -> argc > 6 )
23232324{
@@ -2762,12 +2763,14 @@ main(int argc, char **argv)
27622763{"initialize" ,no_argument ,NULL ,'i' },
27632764{"jobs" ,required_argument ,NULL ,'j' },
27642765{"log" ,no_argument ,NULL ,'l' },
2766+ {"latency-limit" ,required_argument ,NULL ,'L' },
27652767{"no-vacuum" ,no_argument ,NULL ,'n' },
27662768{"port" ,required_argument ,NULL ,'p' },
27672769{"progress" ,required_argument ,NULL ,'P' },
27682770{"protocol" ,required_argument ,NULL ,'M' },
27692771{"quiet" ,no_argument ,NULL ,'q' },
27702772{"report-latencies" ,no_argument ,NULL ,'r' },
2773+ {"rate" ,required_argument ,NULL ,'R' },
27712774{"scale" ,required_argument ,NULL ,'s' },
27722775{"select-only" ,no_argument ,NULL ,'S' },
27732776{"skip-some-updates" ,no_argument ,NULL ,'N' },
@@ -2782,8 +2785,6 @@ main(int argc, char **argv)
27822785{"unlogged-tables" ,no_argument ,& unlogged_tables ,1 },
27832786{"sampling-rate" ,required_argument ,NULL ,4 },
27842787{"aggregate-interval" ,required_argument ,NULL ,5 },
2785- {"rate" ,required_argument ,NULL ,'R' },
2786- {"latency-limit" ,required_argument ,NULL ,'L' },
27872788{"progress-timestamp" ,no_argument ,NULL ,6 },
27882789{NULL ,0 ,NULL ,0 }
27892790};
@@ -3627,7 +3628,7 @@ threadRun(void *arg)
36273628{
36283629/* interrupt client which has not started a transaction */
36293630remains -- ;
3630- st -> sleeping = 0 ;
3631+ st -> sleeping = false ;
36313632st -> throttling = false;
36323633PQfinish (st -> con );
36333634st -> con = NULL ;