WASM plugins
Overview
Section titled “Overview”WASM plugins let you add custom lint rules to pgzest without modifying the core.
A WASM plugin is compiled to .wasm and declared in pgzest.toml (see pgzest.toml).
Required Exports
Section titled “Required Exports”// Plugin identitychar* pgzest_plugin_name(); // null-terminated UTF-8 nameint pgzest_plugin_version(); // 100*major + minor
// Memory management (must expose an allocator)void* pgzest_alloc(int size);void pgzest_free(void* ptr);
// Check hooks (optional — implement what you need)// Input: JSON string (SelectStmt / CreateTable AST node)// Output: JSON array of WasmDiagnostic, null-terminatedchar* pgzest_check_select(char* json, int len);char* pgzest_check_table(char* json, int len);WasmDiagnostic JSON format
Section titled “WasmDiagnostic JSON format”[ { "code": "W099", "message": "custom rule violation", "severity": "warning", "hint": "optional hint string" }]Host Imports
Section titled “Host Imports”// Available as imports from "env"char* pgzest_get_table(char* name, int len); // → JSON TableSchema or nullvoid pgzest_log(char* msg, int len); // log to stderrpgzest.toml
Section titled “pgzest.toml”Paths are relative to the config file. A plugin that fails to load is an error.
[plugins]wasm = [ "plugins/my-custom-rule.wasm", "plugins/naming-enforcer.wasm",]Example (Rust plugin compiled to WASM)
Section titled “Example (Rust plugin compiled to WASM)”See examples/wasm-plugin/ for a minimal Rust plugin.
pgzest is made by Creatiwity, free and open source under the MIT or Apache-2.0 license.