pgbench-script-stats-13-e.patch
text/x-diff
Filename: pgbench-script-stats-13-e.patch
Type: text/x-diff
Part: 4
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/bin/pgbench/pgbench.c | 17 | 18 |
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 23256fb..0b2a2f9 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -229,16 +229,15 @@ typedef struct
PGconn *con; /* connection handle to DB */
int id; /* client No. */
int state; /* state No. */
- int listen; /* 0 indicates that an async query has been
- * sent */
- int sleeping; /* 1 indicates that the client is napping */
+ bool listen; /* whether an async query has been sent */
+ bool is_throttled; /* whether transaction throttling is done */
+ bool sleeping; /* whether the client is napping */
bool throttling; /* whether nap is for throttling */
Variable *variables; /* array of variable definitions */
int nvariables;
int64 txn_scheduled; /* scheduled start time of transaction (usec) */
instr_time txn_begin; /* used for measuring schedule lag times */
instr_time stmt_begin; /* used for measuring statement latencies */
- bool is_throttled; /* whether transaction throttling is done */
int use_file; /* index in sql_scripts for this client */
bool prepared[MAX_SCRIPTS]; /* whether client prepared the script */
@@ -1264,7 +1263,7 @@ top:
}
}
- st->sleeping = 1;
+ st->sleeping = true;
st->throttling = true;
st->is_throttled = true;
if (debug)
@@ -1279,7 +1278,7 @@ top:
if (INSTR_TIME_GET_MICROSEC(now) < st->txn_scheduled)
return true; /* Still sleeping, nothing to do here */
/* Else done sleeping, go ahead with next command */
- st->sleeping = 0;
+ st->sleeping = false;
st->throttling = false;
}
@@ -1375,9 +1374,9 @@ top:
* nothing to listen to right now. When throttling rate limits
* are active, a sleep will happen next, as the next transaction
* starts. And then in any case the next SQL command will set
- * listen back to 1.
+ * listen back to true.
*/
- st->listen = 0;
+ st->listen = false;
trans_needs_throttle = (throttle_delay > 0);
}
}
@@ -1500,7 +1499,7 @@ top:
st->ecnt++;
}
else
- st->listen = 1; /* flags that should be listened */
+ st->listen = true; /* flags that should be listened */
}
else if (commands[st->state]->type == META_COMMAND)
{
@@ -1651,7 +1650,7 @@ top:
return true;
}
- st->listen = 1;
+ st->listen = true;
}
else if (pg_strcasecmp(argv[0], "set") == 0)
{
@@ -1672,7 +1671,7 @@ top:
return true;
}
- st->listen = 1;
+ st->listen = true;
}
else if (pg_strcasecmp(argv[0], "sleep") == 0)
{
@@ -1706,9 +1705,9 @@ top:
INSTR_TIME_SET_CURRENT(now);
st->txn_scheduled = INSTR_TIME_GET_MICROSEC(now) + usec;
- st->sleeping = 1;
+ st->sleeping = true;
- st->listen = 1;
+ st->listen = true;
}
else if (pg_strcasecmp(argv[0], "setshell") == 0)
{
@@ -1722,7 +1721,7 @@ top:
return true;
}
else /* succeeded */
- st->listen = 1;
+ st->listen = true;
}
else if (pg_strcasecmp(argv[0], "shell") == 0)
{
@@ -1736,7 +1735,7 @@ top:
return true;
}
else /* succeeded */
- st->listen = 1;
+ st->listen = true;
}
/* after a meta command, immediately proceed with next command */
@@ -2822,12 +2821,14 @@ main(int argc, char **argv)
{"initialize", no_argument, NULL, 'i'},
{"jobs", required_argument, NULL, 'j'},
{"log", no_argument, NULL, 'l'},
+ {"latency-limit", required_argument, NULL, 'L'},
{"no-vacuum", no_argument, NULL, 'n'},
{"port", required_argument, NULL, 'p'},
{"progress", required_argument, NULL, 'P'},
{"protocol", required_argument, NULL, 'M'},
{"quiet", no_argument, NULL, 'q'},
{"report-latencies", no_argument, NULL, 'r'},
+ {"rate", required_argument, NULL, 'R'},
{"scale", required_argument, NULL, 's'},
{"select-only", no_argument, NULL, 'S'},
{"skip-some-updates", no_argument, NULL, 'N'},
@@ -2842,8 +2843,6 @@ main(int argc, char **argv)
{"unlogged-tables", no_argument, &unlogged_tables, 1},
{"sampling-rate", required_argument, NULL, 4},
{"aggregate-interval", required_argument, NULL, 5},
- {"rate", required_argument, NULL, 'R'},
- {"latency-limit", required_argument, NULL, 'L'},
{"progress-timestamp", no_argument, NULL, 6},
{NULL, 0, NULL, 0}
};
@@ -3652,7 +3651,7 @@ threadRun(void *arg)
{
/* interrupt client which has not started a transaction */
remains--;
- st->sleeping = 0;
+ st->sleeping = false;
st->throttling = false;
PQfinish(st->con);
st->con = NULL;