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

Plugins built with newer PDKs don't work with pg_extism #7

Open
jrandall opened this issue Jan 7, 2025 · 4 comments · May be fixed by #8
Open

Plugins built with newer PDKs don't work with pg_extism #7

jrandall opened this issue Jan 7, 2025 · 4 comments · May be fixed by #8
Assignees

Comments

@jrandall
Copy link

jrandall commented Jan 7, 2025

I have managed to successfully use pg_extism to build a replacement for a C-language postgres user-defined function by compiling it to webassembly and running it on Amazon RDS using pg_extism with PLV8. This is great, thanks!

However, in order to do this, I had to use a pre-1.0 version of the extism c-pdk, as it seems a number of host interfaces are missing in pg_extism. In case others may find this useful, I found the current version of pg_extism works well with c-pdk commit ref 01064c00d7de7532132e7bf7305c4eaf486b6658.

Some of the things that are used by c-pdk plugins in v1.1 that seem to be missing from pg_extism are host functions in extism:host/env:

  • the input_offset function
  • the log_trace function
  • the get_log_level function

The latter two seem fairly trivial to add (both can just be adopted from current versions in js-sdk: https://github.com/extism/js-sdk/blob/b46fb76549ee006e099129a395926406dde1d122/src/call-context.ts#L415-L419), but the input_offset function in js-sdk seems like it is based around an input data structure that has been changed significantly in js-sdk compared to the version in pg_extism. The current implementation in js-sdk (https://github.com/extism/js-sdk/blob/b46fb76549ee006e099129a395926406dde1d122/src/call-context.ts#L263-L266) is referring to a Block class that pg_extism does not seem to be using.

The extism c-pdk v1.1 high level input loading function extism_load_input has been updated to use the input_offset function, so it is fairly essential to plugin function for this to work with versions of the c-pdk after the v1.0 release.

@mhmd-azeez mhmd-azeez self-assigned this Jan 8, 2025
@mhmd-azeez mhmd-azeez linked a pull request Jan 8, 2025 that will close this issue
@mhmd-azeez
Copy link
Collaborator

Hello @jrandall, thanks for reporting the issue, I have opened a PR (#8) that should fix the problem, can you please take a look at and test it out?

@jrandall
Copy link
Author

jrandall commented Jan 8, 2025

Thanks @mhmd-azeez so much for the rapid work to implement this. I can confirm that PR #8 fixes these issues for me and works with c-pdk 1.1.0.

@mhmd-azeez
Copy link
Collaborator

@jrandall perfect, thanks for trying it out!

@jrandall
Copy link
Author

jrandall commented Jan 8, 2025

@mhmd-azeez while the update does now compile and run with c-pdk 1.1.0, I've found that neither logging nor higher level input functions appear to work properly. My testing earlier was still using the lower-level input loading rather than the extism_load_input function - when I use this, I get empty input.

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 a pull request may close this issue.

2 participants