pgsql: Avoid assuming that instr_time == struct timeval in pgbench logg

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Avoid assuming that instr_time == struct timeval in pgbench logg
Date: 2017-01-01 20:17:22
Message-ID: E1cNmZG-0005GY-Rm@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid assuming that instr_time == struct timeval in pgbench logging.

This code was presuming undue familiarity with the contents of the
instr_time struct. That was already broken on Windows, and it's about
to get broken on most other platforms as well. The simplest solution
that preserves the current output definition is to just do our own
gettimeofday() call here. Realistically, the extra cost is probably
negligible in comparison to everything else that's going on in a
pgbench transaction, so it's not worth sweating over.

On Windows, the precision delivered by gettimeofday() is lower than
one could wish, but this is still a big improvement over printing
zeroes, as the code did before.

Discussion: https://postgr.es/m/8837.1483216839@sss.pgh.pa.us

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/74baa1e3b89c1651ade1afeffc715cac24041e2f

Modified Files
--------------
src/bin/pgbench/pgbench.c | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2017-01-02 17:26:19 pgsql: In pgbench logging, avoid assuming that instr_times match Unix t
Previous Message Magnus Hagander 2017-01-01 12:25:23 pgsql: Silence compiler warning