prorm API Reference
    Preparing search index...

    Interface ExternalFunctionOptions

    A function whose body is written in something other than SQL.

    Two shapes, because databases offer two:

    1. Compiled — you wrote C (or C++, or Rust with a C ABI), compiled it to a shared library, and want the database to call into it. MySQL calls these loadable functions and takes only the library name; PostgreSQL takes the object file plus the link symbol.
    2. Interpreted — you wrote Python, Perl or JavaScript and want the source stored in the database, run by a procedural-language handler (plpython3u, plperl, plv8).

    Either way the point is the same: write the logic in the language that suits it, and call it from queries like any other function.

    interface ExternalFunctionOptions {
        name: string;
        language: string;
        returns: string;
        params?: StoredProcedureParam[];
        library?: string;
        symbol?: string;
        source?: string;
        aggregate?: boolean;
        replace?: boolean;
        strict?: boolean;
        volatility?: "VOLATILE" | "STABLE" | "IMMUTABLE";
        schema?: string;
    }
    Index
    name: string

    Function name as it will be called in SQL.

    language: string

    The language the body is written in.

    'c' means compiled — supply library (and symbol on PostgreSQL). Anything else is treated as a procedural language handler and needs source. MySQL supports only 'c'.

    returns: string

    Return type.

    MySQL loadable functions accept only STRING, INTEGER, REAL or DECIMAL; anything else is rejected here rather than by the server.

    Parameters. PostgreSQL declares them; MySQL ignores them — a loadable function's arity is checked by its own _init routine at call time, and the CREATE FUNCTION statement has no parameter list.

    library?: string

    Shared library holding the compiled function — 'my_udf.so'. Required when language is 'c'.

    MySQL resolves this against the server's plugin_dir, so pass a bare file name, not a path. PostgreSQL accepts a path or the $libdir/ prefix.

    symbol?: string

    The exported symbol inside library. PostgreSQL only; defaults to name.

    source?: string

    Source code, for an interpreted language. This is your Python/Perl/JS — it is stored verbatim and never parsed as SQL.

    aggregate?: boolean

    MySQL: declare an aggregate (GROUP BY-capable) loadable function.

    replace?: boolean

    PostgreSQL: emit CREATE OR REPLACE FUNCTION.

    strict?: boolean

    PostgreSQL: RETURNS NULL ON NULL INPUT, i.e. skip the call for nulls.

    volatility?: "VOLATILE" | "STABLE" | "IMMUTABLE"

    PostgreSQL: optimizer category. IMMUTABLE is required to index a call.

    schema?: string

    PostgreSQL: schema to create the function in.