Function name as it will be called in SQL.
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'.
Return type.
MySQL loadable functions accept only STRING, INTEGER, REAL or
DECIMAL; anything else is rejected here rather than by the server.
OptionalparamsParameters. 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.
OptionallibraryShared 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.
OptionalsymbolThe exported symbol inside library. PostgreSQL only; defaults to name.
OptionalsourceSource code, for an interpreted language. This is your Python/Perl/JS — it is stored verbatim and never parsed as SQL.
OptionalaggregateMySQL: declare an aggregate (GROUP BY-capable) loadable function.
OptionalreplacePostgreSQL: emit CREATE OR REPLACE FUNCTION.
OptionalstrictPostgreSQL: RETURNS NULL ON NULL INPUT, i.e. skip the call for nulls.
OptionalvolatilityPostgreSQL: optimizer category. IMMUTABLE is required to index a call.
OptionalschemaPostgreSQL: schema to create the function in.
A function whose body is written in something other than SQL.
Two shapes, because databases offer two:
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.