DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(mysql.info) create-function

Info Catalog (mysql.info) udf-features (mysql.info) adding-functions (mysql.info) drop-function
 
 24.2.2 `CREATE FUNCTION' Syntax
 -------------------------------
 
      CREATE [AGGREGATE] FUNCTION FUNCTION_NAME RETURNS {STRING|INTEGER|REAL|DECIMAL}
          SONAME SHARED_LIBRARY_NAME
 
 A user-defined function (UDF) is a way to extend MySQL with a new
 function that works like a native (built-in) MySQL function such as
 `ABS()' or `CONCAT()'.
 
 FUNCTION_NAME is the name that should be used in SQL statements to
 invoke the function. The `RETURNS' clause indicates the type of the
 function's return value. As of MySQL 5.0.3, `DECIMAL' is a legal value
 after `RETURNS', but currently `DECIMAL' functions return string values
 and should be written like `STRING' functions.
 
 SHARED_LIBRARY_NAME is the basename of the shared object file that
 contains the code that implements the function. The file must be
 located in a directory that is searched by your system's dynamic linker.
 
 To create a function, you must have the `INSERT' and privilege for the
 `mysql' database. This is necessary because `CREATE FUNCTION' adds a
 row to the `mysql.func' system table that records the function's name,
 type, and shared library name. If you do not have this table, you
 should run the `mysql_upgrade' command to create it. See 
 mysql-upgrade.
 
 An active function is one that has been loaded with `CREATE FUNCTION'
 and not removed with `DROP FUNCTION'. All active functions are reloaded
 each time the server starts, unless you start `mysqld' with the
 -skip-grant-tables option. In this case, UDF initialization is skipped
 and UDFs are unavailable.
 
 For instructions on writing user-defined functions, see 
 adding-udf. For the UDF mechanism to work, functions must be written
 in C or C++, your operating system must support dynamic loading and you
 must have compiled `mysqld' dynamically (not statically).
 
 An `AGGREGATE' function works exactly like a native MySQL aggregate
 (summary) function such as `SUM' or `COUNT()'. For `AGGREGATE' to work,
 your `mysql.func' table must contain a `type' column. If your
 `mysql.func' table does not have this column, you should run the
 `mysql_upgrade' script to create it (see  mysql-upgrade).
 
Info Catalog (mysql.info) udf-features (mysql.info) adding-functions (mysql.info) drop-function
automatically generated byinfo2html