Use pg_prng_uint32 for Postgres 15

This commit is contained in:
Andrew Kane
2022-12-07 15:28:11 -08:00
parent cd7cab804f
commit 573200c188
3 changed files with 16 additions and 14 deletions

View File

@@ -10,6 +10,12 @@
#include "utils/tuplesort.h"
#include "vector.h"
#if PG_VERSION_NUM >= 150000
#include "common/pg_prng.h"
#else
#include "port.h"
#endif
#ifdef IVFFLAT_BENCH
#include "portability/instr_time.h"
#endif
@@ -62,6 +68,14 @@
#define IvfflatBench(name, code) (code)
#endif
#if PG_VERSION_NUM >= 150000
#define RandomDouble() pg_prng_double(&pg_global_prng_state)
#define RandomInt() pg_prng_uint32(&pg_global_prng_state)
#else
#define RandomDouble() (((double) random()) / MAX_RANDOM_VALUE)
#define RandomInt() random()
#endif
/* Variables */
extern int ivfflat_probes;