Fix calculation of latency of pgbench backslash commands.
authorHeikki Linnakangas
Thu, 30 Jul 2015 11:50:51 +0000 (14:50 +0300)
committerHeikki Linnakangas
Thu, 30 Jul 2015 11:51:08 +0000 (14:51 +0300)
When we loop back to the top of doCustom after processing a backslash
command, we must reset the "now" timestamp, because that's used to
calculate the time spent executing the previous command.

Report and fix by Fabien Coelho. Backpatch to 9.5, where this was broken.

src/bin/pgbench/pgbench.c

index ceaf14cde16e2424622783bee8c997657b9e91da..d48e5b78443edb49251dd2184e6e76155a3f44dc 100644 (file)
@@ -1154,11 +1154,12 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
     * first time it's needed, and reuse the same value throughout this
     * function after that. This also ensures that e.g. the calculated latency
     * reported in the log file and in the totals are the same. Zero means
-    * "not set yet".
+    * "not set yet". Reset "now" when we step to the next command with "goto
+    * top", though.
     */
+top:
    INSTR_TIME_SET_ZERO(now);
 
-top:
    commands = sql_files[st->use_file];
 
    /*