From 7d1b74a8c6b0e07c7cd156943f48fc9be16876dc Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Mon, 19 Dec 2022 23:51:57 +0100 Subject: [PATCH] Use rand() instead of random() Use rand() instead of random() cause the latter is not available on Windows and postgres stopped backporting it with PG15. Ideally we switch to the crypto functions added in PG15 but that requires a bit more work and this is the minimal change required to get it to build against PG15 on Windows. --- src/bgw/job_stat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bgw/job_stat.c b/src/bgw/job_stat.c index 8ecbf9a84..246575def 100644 --- a/src/bgw/job_stat.c +++ b/src/bgw/job_stat.c @@ -272,7 +272,7 @@ static float8 calculate_jitter_percent() { /* returns a number in the range [-0.125, 0.125] */ - uint8 percent = random(); + uint8 percent = rand(); return ldexp((double) (16 - (int) (percent % 32)), -7); } @@ -305,7 +305,7 @@ calculate_next_start_on_failure(TimestampTz finish_time, int consecutive_failure MemoryContext oldctx; /* 2^(consecutive_failures) - 1, at most 2^20 */ int64 max_slots = (INT64CONST(1) << (int64) multiplier) - INT64CONST(1); - int64 rand_backoff = random() % (max_slots * USECS_PER_SEC); + int64 rand_backoff = rand() % (max_slots * USECS_PER_SEC); if (!IS_VALID_TIMESTAMP(finish_time)) {