Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix building against PG15 on windows #5106

Merged
merged 2 commits into from Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/windows-build-and-test.yaml
Expand Up @@ -16,6 +16,7 @@ jobs:
pg12_latest: ${{ steps.config.outputs.pg12_latest }}
pg13_latest: ${{ steps.config.outputs.pg13_latest }}
pg14_latest: ${{ steps.config.outputs.pg14_latest }}
pg15_latest: ${{ steps.config.outputs.pg15_latest }}

steps:
- name: Checkout source code
Expand All @@ -40,7 +41,7 @@ jobs:
strategy:
fail-fast: false
matrix:
pg: [ 12, 13, 14 ]
pg: [ 12, 13, 14, 15 ]
os: [ windows-2022 ]
build_type: ${{ fromJson(needs.config.outputs.build_type) }}
ignores: ["chunk_adaptive metadata"]
Expand All @@ -57,6 +58,9 @@ jobs:
- pg: 14
pkg_version: 14.5.1 # hardcoded due to issues with PG14.6 on chocolatey
tsl_skips_version: dist_partial_agg-14 dist_grant-14
- pg: 15
pkg_version: 15.0.1 # hardcoded due to issues with PG15.1 on chocolatey
tsl_skips_version: dist_partial_agg-15 dist_grant-15
env:
# PostgreSQL configuration
PGPORT: 55432
Expand Down
4 changes: 2 additions & 2 deletions src/bgw/job_stat.c
Expand Up @@ -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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not obvious to me why this change is required?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explanation is in the commit message of the 2nd commit:

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see - sorry I made you repeat yourself here!

return ldexp((double) (16 - (int) (percent % 32)), -7);
}

Expand Down Expand Up @@ -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))
{
Expand Down