Skip to content

Add Windows build support: shared memory wiring, PGDLLEXPORT, subscriber tool fixes - #528

Open
semihkiroglu wants to merge 1 commit into
2ndQuadrant:REL2_x_STABLEfrom
semihkiroglu:windows-build-support
Open

Add Windows build support: shared memory wiring, PGDLLEXPORT, subscriber tool fixes#528
semihkiroglu wants to merge 1 commit into
2ndQuadrant:REL2_x_STABLEfrom
semihkiroglu:windows-build-support

Conversation

@semihkiroglu

@semihkiroglu semihkiroglu commented Aug 7, 2026

Copy link
Copy Markdown

Summary

This PR adds Windows build and runtime support for pglogical 2.4.8. It builds on the work contributed by @MickeyYadav and @ljackwilson in #442 and makes the extension compile, install and run (including the background worker startup) on Windows.

Provenance

Change Source
random()rand() for MSVC compatibility @MickeyYadav (#442)
sys/stat.h excluded on Windows (#ifndef WIN32) @MickeyYadav (#442)
QuoteWindowsArgv cast fix @MickeyYadav (#442)
Shared-memory startup-hook wiring for PostgreSQL 15+ (shmem startup hooks moved out of postmaster on Windows) @ljackwilson (patch in #442)
PGDLLEXPORT declarations required for Windows DLL builds @ljackwilson (patch in #442)
DWORD exit code for worker threads @ljackwilson (patch in #442)
QuoteWindowsArgv static → non-static linkage fix @ljackwilson (patch in #442)
Empty shared_preload_libraries change so the subscriber catchup start path works @semihkiroglu

All Windows-only behavior is wrapped in #ifdef WIN32, so non-Windows builds are behavior-identical to upstream. Debug logging from the original patch is removed.

Note: the Makefile / .gitignore changes from the 2.4.5-era patch are intentionally not included — they were not validated against 2.4.8 and the build is driven by CMake on Windows.

Testing

  • Linux (PG18): builds clean with the same warning set as the baseline; smoke test passed — CREATE EXTENSION, create_node, and both background workers (pglogical supervisor, pglogical manager) start via the shared-memory hook.
  • Windows: full MSVC/CMake build + smoke pipeline for PostgreSQL 14–18, 5/5 green.
  • #ifdef WIN32 balance and syntax verified across PG14–PG18 with mingw.

I verify the Windows build (CMake/MSVC, PostgreSQL 14–18) in the CI of semihkiroglu/pglogical-windows, where I also package these fixes as per-major Windows releases (zip + checksums).

Fixes #442

Make pglogical 2.4.8 build and run on Windows, based on the work tracked
in upstream issue 2ndQuadrant#442:

- PG15+ shared-memory startup-hook wiring (re-register in the supervisor
  worker; guard against double registration and hook recursion)
- PGDLLEXPORT declarations for _PG_init, _PG_output_plugin_init,
  PGLogicalCtx and the shmem startup hook
- Subscriber tool fixes: exclude sys/stat.h on Windows, rand() instead of
  random(), empty shared_preload_libraries= for the catchup start (cmd.exe
  keeps '' literal), DWORD exit code, QuoteWindowsArgv linkage + cast

Windows-only behavior is wrapped in #ifdef WIN32 so non-Windows builds
are behavior-identical to upstream. Fixes 2ndQuadrant#442.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Getting this error ' The specified module could not be found. ' on creating extention pglogical on windows.

1 participant