pgsql: Fix pgbench's --progress-timestamp option to print Unix-epoch ti

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix pgbench's --progress-timestamp option to print Unix-epoch ti
Date: 2017-04-11 12:59:48
Message-ID: E1cxvOe-0001rf-5f@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix pgbench's --progress-timestamp option to print Unix-epoch timestamps.

As a consequence of commit 1d63f7d2d, on platforms with CLOCK_MONOTONIC,
you got some random timescale or other instead of standard Unix timestamps
as expected. I'd attempted to fix pgbench for that change in commits
74baa1e3b and 67a875355, but missed this place. Fix in the same way as
those previous commits, ie, just eat the cost of an extra gettimeofday();
one extra syscall per progress report isn't worth sweating over. Per
report from Jeff Janes.

In passing, use snprintf not sprintf for this purpose. I don't think
there's any chance of actual buffer overrun, but it just looks safer.

Discussion: https://postgr.es/m/CAMkU=1zrQaPwBN+NcBd3pWCb=vWaiL=mmWfJjDJjh-a7eVr-Og@mail.gmail.com

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/feffa0e0795a5a99324890a6dd548ba162ec104c

Modified Files
--------------
src/bin/pgbench/pgbench.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2017-04-11 13:18:38 pgsql: Fix possibile deadlock when dropping partitions.
Previous Message Michael Meskes 2017-04-11 12:00:08 pgsql: Document that bytea is best represented as char * in C for ecpg.