mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-01 12:21:18 +02:00
Fix another portability bug in recent pgbench commit.
Commit547f04e7
produced errors on AIX/xlc while building plpython. The new code appears to be incompatible with the hack installed by commita11cf433
. 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
This commit is contained in:
parent
68b34b2338
commit
c427de427a
@ -320,6 +320,13 @@ typedef struct SimpleStats
|
|||||||
double sum2; /* sum of squared values */
|
double sum2; /* sum of squared values */
|
||||||
} SimpleStats;
|
} SimpleStats;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The instr_time type is expensive when dealing with time arithmetic. Define
|
||||||
|
* a type to hold microseconds instead. Type int64 is good enough for about
|
||||||
|
* 584500 years.
|
||||||
|
*/
|
||||||
|
typedef int64 pg_time_usec_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Data structure to hold various statistics: per-thread and per-script stats
|
* Data structure to hold various statistics: per-thread and per-script stats
|
||||||
* are maintained and merged together.
|
* are maintained and merged together.
|
||||||
@ -658,6 +665,24 @@ static const PsqlScanCallbacks pgbench_callbacks = {
|
|||||||
NULL, /* don't need get_variable functionality */
|
NULL, /* don't need get_variable functionality */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline pg_time_usec_t
|
||||||
|
pg_time_now(void)
|
||||||
|
{
|
||||||
|
instr_time now;
|
||||||
|
|
||||||
|
INSTR_TIME_SET_CURRENT(now);
|
||||||
|
|
||||||
|
return (pg_time_usec_t) INSTR_TIME_GET_MICROSEC(now);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
pg_time_now_lazy(pg_time_usec_t *now)
|
||||||
|
{
|
||||||
|
if ((*now) == 0)
|
||||||
|
(*now) = pg_time_now();
|
||||||
|
}
|
||||||
|
|
||||||
|
#define PG_TIME_GET_DOUBLE(t) (0.000001 * (t))
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
|
@ -253,32 +253,4 @@ GetTimerFrequency(void)
|
|||||||
#define INSTR_TIME_SET_CURRENT_LAZY(t) \
|
#define INSTR_TIME_SET_CURRENT_LAZY(t) \
|
||||||
(INSTR_TIME_IS_ZERO(t) ? INSTR_TIME_SET_CURRENT(t), true : false)
|
(INSTR_TIME_IS_ZERO(t) ? INSTR_TIME_SET_CURRENT(t), true : false)
|
||||||
|
|
||||||
/*
|
|
||||||
* Simpler convenient interface
|
|
||||||
*
|
|
||||||
* The instr_time type is expensive when dealing with time arithmetic.
|
|
||||||
* Define a type to hold microseconds on top of this, suitable for
|
|
||||||
* benchmarking performance measures, eg in "pgbench".
|
|
||||||
*
|
|
||||||
* Type int64 is good enough for about 584500 years.
|
|
||||||
*/
|
|
||||||
typedef int64 pg_time_usec_t;
|
|
||||||
|
|
||||||
static inline pg_time_usec_t
|
|
||||||
pg_time_now(void)
|
|
||||||
{
|
|
||||||
instr_time now;
|
|
||||||
|
|
||||||
INSTR_TIME_SET_CURRENT(now);
|
|
||||||
return (pg_time_usec_t) INSTR_TIME_GET_MICROSEC(now);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
pg_time_now_lazy(pg_time_usec_t *now)
|
|
||||||
{
|
|
||||||
if ((*now) == 0)
|
|
||||||
(*now) = pg_time_now();
|
|
||||||
}
|
|
||||||
|
|
||||||
#define PG_TIME_GET_DOUBLE(t) (0.000001 * (t))
|
|
||||||
#endif /* INSTR_TIME_H */
|
#endif /* INSTR_TIME_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user