Skip to content

Commit c427de4

Browse files
committed
Fix another portability bug in recent pgbench commit.
Commit 547f04e produced errors on AIX/xlc while building plpython. The new code appears to be incompatible with the hack installed by commit a11cf43. Without access to an AIX system to check, my guess is that _POSIX_C_SOURCE may be required for <time.h> to declare the things the header needs to see, but plpython.h undefines it. For now, to unbreak build farm animal hoverfly, just move the new pg_time_usec_t support into pgbench.c. Perhaps later we could figure out what to rearrange to put it back into a header for wider use. Discussion: https://postgr.es/m/CA%2BhUKG%2BP%2BjcD%3Dx9%2BagyTdWtjpOT64MYiGic%2Bcbu_TD8CV%3D6A3w%40mail.gmail.com
1 parent 68b34b2 commit c427de4

File tree

2 files changed

+25
-28
lines changed

2 files changed

+25
-28
lines changed

src/bin/pgbench/pgbench.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,13 @@ typedef struct SimpleStats
320320
double sum2; /* sum of squared values */
321321
} SimpleStats;
322322

323+
/*
324+
* The instr_time type is expensive when dealing with time arithmetic. Define
325+
* a type to hold microseconds instead. Type int64 is good enough for about
326+
* 584500 years.
327+
*/
328+
typedef int64 pg_time_usec_t;
329+
323330
/*
324331
* Data structure to hold various statistics: per-thread and per-script stats
325332
* are maintained and merged together.
@@ -658,6 +665,24 @@ static const PsqlScanCallbacks pgbench_callbacks = {
658665
NULL, /* don't need get_variable functionality */
659666
};
660667

668+
static inline pg_time_usec_t
669+
pg_time_now(void)
670+
{
671+
instr_time now;
672+
673+
INSTR_TIME_SET_CURRENT(now);
674+
675+
return (pg_time_usec_t) INSTR_TIME_GET_MICROSEC(now);
676+
}
677+
678+
static inline void
679+
pg_time_now_lazy(pg_time_usec_t *now)
680+
{
681+
if ((*now) == 0)
682+
(*now) = pg_time_now();
683+
}
684+
685+
#define PG_TIME_GET_DOUBLE(t) (0.000001 * (t))
661686

662687
static void
663688
usage(void)

src/include/portability/instr_time.h

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -253,32 +253,4 @@ GetTimerFrequency(void)
253253
#define INSTR_TIME_SET_CURRENT_LAZY(t) \
254254
(INSTR_TIME_IS_ZERO(t) ? INSTR_TIME_SET_CURRENT(t), true : false)
255255

256-
/*
257-
* Simpler convenient interface
258-
*
259-
* The instr_time type is expensive when dealing with time arithmetic.
260-
* Define a type to hold microseconds on top of this, suitable for
261-
* benchmarking performance measures, eg in "pgbench".
262-
*
263-
* Type int64 is good enough for about 584500 years.
264-
*/
265-
typedef int64 pg_time_usec_t;
266-
267-
static inline pg_time_usec_t
268-
pg_time_now(void)
269-
{
270-
instr_time now;
271-
272-
INSTR_TIME_SET_CURRENT(now);
273-
return (pg_time_usec_t) INSTR_TIME_GET_MICROSEC(now);
274-
}
275-
276-
static inline void
277-
pg_time_now_lazy(pg_time_usec_t *now)
278-
{
279-
if ((*now) == 0)
280-
(*now) = pg_time_now();
281-
}
282-
283-
#define PG_TIME_GET_DOUBLE(t) (0.000001 * (t))
284256
#endif /* INSTR_TIME_H */

0 commit comments

Comments
 (0)