Use PG_MODULE_MAGIC_EXT in PostgreSQL 18 and later#3112
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
WalkthroughThe PR updates PostgreSQL module initialization to support version-dependent behavior and consolidates magic declarations. The version module now uses ChangesPostgreSQL Module Version Compatibility
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Infer (1.2.0)src/version/version.csrc/version/version.c:29:10: fatal error: 'c_common/postgres_connection.h' file not found ... [truncated 743 characters] ... t/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/lib/clang/18/include" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/version/version.c`:
- Around line 32-36: Replace the version-based preprocessor check with a feature
test: instead of checking PG_VERSION_NUM use `#ifdef` PG_MODULE_MAGIC_EXT so the
code compiles correctly when PG_MODULE_MAGIC_EXT is available; update the
conditional around PG_MODULE_MAGIC_EXT(.name = "pgrouting", .version =
PROJECT_VERSION) and keep the existing fallback to PG_MODULE_MAGIC so both the
extended macro and older Postgres builds are supported.
In `@src/version/version.h.in`:
- Line 32: The generated header defines PROJECT_VERSION which collides with the
CMake -DPROJECT_VERSION compile define and can drift; rename the header macro
(e.g., change PROJECT_VERSION in version.h.in to GENERATED_PROJECT_VERSION or
PROJECT_VERSION_STRING) and update any source that includes the header and
currently uses PROJECT_VERSION (notably the PG_MODULE_MAGIC_EXT(... .version =
PROJECT_VERSION) usage) to consume the renamed macro instead; keep the existing
CMake -DPROJECT_VERSION define for compile-time overrides if needed, or remove
that -D if you prefer the header value to be authoritative, but do not leave
both named PROJECT_VERSION.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 4c30c67b-b7dd-4a7f-936d-c7eb550ebcff
📒 Files selected for processing (3)
src/dijkstra/dijkstra.csrc/version/version.csrc/version/version.h.in
💤 Files with no reviewable changes (1)
- src/dijkstra/dijkstra.c
The PG_MODULE_MAGIC_EXT macro was added in PostgreSQL 18 and makes it possible to see which version of the library is actually loaded using pg_get_loaded_modules(). This commit also moves the use of PG_MODULE_MAGIC to a less awkward place. While it is not 100% connected to the version functions it is much more connect to them than to Djikstra.
1e5523e to
d4f894e
Compare
The
PG_MODULE_MAGIC_EXTmacro was added in PostgreSQL 18 and makes it possible to see which version of the library is actually loaded usingpg_get_loaded_modules().This commit also moves the use of
PG_MODULE_MAGICto a less awkward place. While it is not 100% connected to the version functions it is much more connect to them than to Djikstra.Changes proposed in this pull request:
PG_MODULE_MAGIC_EXTin PostgreSQL 18PG_MODULE_MAGICtoversion.c@pgRouting/admins
Not sure if you prefer
#if PG_VERSION_NUM >= 180000or#ifdef PG_VERSION_MAGIC_EXT. I personally prefer the former but found no examples of what you normally use when looking at the code.Summary by CodeRabbit