Skip to content

fix(pgdog-plugin): api version check#770

Merged
levkk merged 4 commits intopgdogdev:mainfrom
meskill:pgdog-plugin-comp
Feb 16, 2026
Merged

fix(pgdog-plugin): api version check#770
levkk merged 4 commits intopgdogdev:mainfrom
meskill:pgdog-plugin-comp

Conversation

@meskill
Copy link
Contributor

@meskill meskill commented Feb 15, 2026

pgdog-plugin compatibility check

fixes #600

Adds a compatibility version check for plugins based on the pgdog-plugin crate version. The implementation extracts and validates only the version of pgdog-plugin since it contains the definitions of the bridge layer between PgDog and plugins. Checking only pgdog-plugin avoids tight coupling with the main pgdog version while still enabling a meaningful compatibility check.

Highlights

Compatibility check

Added a new function pgdog_plugin_api_version to the Plugin trait and a corresponding verification step in the initialization code.

For now, this check is not enforced to avoid breaking existing plugins. It can be enabled later to prevent loading older, incompatible plugins.

Integration tests

I added a couple of integration tests to verify the plugins behave as expected. The tests exercise different pgdog-plugin versions (the local repo version, the crates.io version, and a main-branch/dev version) to exercise the compatibility checks and surface potential issues.

Removed pg_query version check

Note: the pg_query version was referenced in docs but not actually enforced.

There were no real checks for the pg_query version despite documentation references, so I removed the separate crate and the export from pgdog-plugin. The pg_query version is important, but the previous check was unused and ineffective.

The current approach is to control the pg_query version via the pgdog-plugin crate and rely on its versioning. We currently use a fork of pg_query pinned by git revision rather than a crates.io version, so this central control makes the most sense.

Cleanup and documentation

I updated documentation and cleaned up some plugin-related dependencies. I also added an LLM-generated doc section for the plugin which should help developers get started.

Future design

I explored the current approach and the challenges around enforcing Rust/Rustc compatibility. While most FFI types use #[repr(C)], there are places that rely on Rust's ABI layout (for example, Vec and some pg_query structures passed as raw pointers). Because of that, using the same Rust toolchain and dependency versions between host and plugin is sensible but it still does not fully guarantee ABI compatibility, especially when compilation flags differ.

For a more robust future solution, consider using a crate like stabby to help enforce ABI compatibility between host and plugins. That approach could add stricter validations and reduce subtle runtime errors, but would likely require reworking parts of the plugin interface and some data representations (notably the pg_query-related types).

TODO

If merged, update the PgDog site documentation to reflect these changes.

@CLAassistant
Copy link

CLAassistant commented Feb 15, 2026

CLA assistant check
All committers have signed the CLA.

@meskill meskill changed the title fix(pgdog): use semver for the pgdog-plugin validation fix(pgdog-plugin): api version check Feb 15, 2026
@codecov
Copy link

codecov bot commented Feb 16, 2026

Codecov Report

❌ Patch coverage is 0% with 29 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pgdog/src/plugin/mod.rs 0.00% 16 Missing ⚠️
pgdog-plugin/src/plugin.rs 0.00% 9 Missing ⚠️
pgdog-plugin/src/comp.rs 0.00% 3 Missing ⚠️
pgdog/src/util.rs 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Collaborator

@levkk levkk left a comment

Choose a reason for hiding this comment

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

Really cool!

@levkk levkk merged commit 6810475 into pgdogdev:main Feb 16, 2026
8 checks passed
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.

[Plugins] Plugin should not run against different PgDog version

3 participants