@obinexusltd/sqlpolycall
v1.0.0
Published
MySQL UDF source binding for libpolycall 1.5
Maintainers
Readme
@obinexusltd/sqlpolycall
MySQL 8 UDF source binding for libpolycall 1.5. It exposes one SQL function:
SELECT sqlpolycall_run_config('sqlpolycallrc') AS polycall_status;The UDF converts MySQL's length-delimited string into a safe C string, calls
polycall_ffi_run_config(config_path, 1) exactly once, and returns the original
libpolycall status as a SQL integer. It contains no SQL client, config parser,
network stack, or duplicate runtime.
Requirements
- MySQL Server 8.0 headers and a running MySQL server
- libpolycall 1.5 built for the same architecture/toolchain
- Node.js 18+ and npm 9+
- A C11 compiler (
CC, defaultgcc)
This workstation was verified with MySQL Community Server 8.0.45. Its client is
installed at C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe; add that
directory to PATH or invoke the full path.
Install the npm source package
npm install @obinexusltd/sqlpolycallThe npm entry point is a source index, not a database client:
const sqlpolycall = require('@obinexusltd/sqlpolycall');
console.log(sqlpolycall.directories.sql.relativeFiles);
console.log(sqlpolycall.resolve('examples', 'run.sql'));src, include, generated, sql, dist, examples, tests, and scripts
are recursively indexed with package-relative and absolute paths.
Build the MySQL UDF
On PowerShell:
$env:MYSQL_INCLUDE_DIR = 'C:\Program Files\MySQL\MySQL Server 8.0\include'
$env:POLYCALL_LIB_DIR = 'C:\path\to\libpolycall\lib'
$env:POLYCALL_LIB_NAME = 'polycall' # optional default
npm run buildThis produces dist/sqlpolycall_udf.dll on Windows or
dist/sqlpolycall_udf.so on Unix. The libpolycall binary must match the MySQL
server architecture and your selected C compiler.
Install in MySQL
First find the server plugin directory:
& 'C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe' -uroot -p `
-e "SHOW VARIABLES LIKE 'plugin_dir';"Copy the built library into that plugin_dir using an elevated shell. Then
register the UDF with an administrative MySQL account:
& 'C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe' -uroot -p `
-e "SOURCE C:/absolute/path/sqlpolycall/sql/install-windows.sql"Unix users should source sql/install-unix.sql. Remove the function with
sql/uninstall.sql before replacing or deleting the shared library.
Security and path behavior
The config file is opened by libpolycall inside the mysqld process. Paths are
therefore resolved using the MySQL service account's filesystem permissions,
not the SQL client's. Restrict EXECUTE access to trusted database roles and
do not pass untrusted path input to this UDF.
SQL NULL produces SQL NULL. Embedded NUL bytes and allocation failures set
the MySQL UDF error flag without calling libpolycall.
Verification and publishing
npm test
npm pack --dry-run
npm publish --access publicTests compile the adapter against the installed MySQL UDF headers and a mock of the single libpolycall ABI function. They do not connect to MySQL or require a database password.
Author: Nnamdi Michael Okpala [email protected]
License: MIT
