Oracle 5.0 Reference Manual page 2837

Table of Contents

Advertisement

The immediately following instructions are for Unix. Instructions for Windows are given later in this
section.
The
file contains the following functions:
udf_example.c
returns a metaphon string of the string argument. This is something like a soundex
metaphon()
string, but it is more tuned for English.
myfunc_double()
by the sum of the length of its arguments.
returns the sum of the length of its arguments.
myfunc_int()
sequence([const int])
has been given.
returns the IP address for a host name.
lookup()
reverse_lookup()
with a single string argument of the form
returns an average cost. This is an aggregate function.
avgcost()
A dynamically loadable file should be compiled as a sharable object file, using a command something
like this:
shell>
gcc -shared -o udf_example.so udf_example.c
If you are using
with
gcc
be able to create
udf_example.so
shell>
make udf_example.la
After you compile a shared object containing UDFs, you must install it and tell MySQL about
it. Compiling a shared object from
udf_example.so. Compiling the shared object using
udf_example.so.0.0.0
As of MySQL 5.0.67, copy the shared object to server's plugin directory and name it
udf_example.so. This directory is given by the value of the
Prior to MySQL 5.0.67, or if the value of
placed in a directory such as
or you can add the directory in which you place the shared object to the linker configuration file (for
example, /etc/ld.so.conf).
On many systems, you can also set the
to point at the directory where you have the files for your UDF. You should set the variable in
or
mysql.server
mysqld_safe
to place the object file in a directory accessible only to the server and not in a public directory. The
manual page tells you which variable to use on your system.
dlopen
The dynamic linker name is system-specific (for example,
Linux, or
on Mac OS X). Consult your system documentation for information about the linker
dyld
name and how to configure it.
On some systems, the
a shared object unless its name begins with lib. In this case you should rename a file such as
to libudf_example.so.
udf_example.so
On Windows, you can compile user-defined functions by using the following procedure:
Adding a New User-Defined Function
returns the sum of the ASCII values of the characters in its arguments, divided
returns a sequence starting from the given number or 1 if no number
returns the host name for an IP address. The function may be called either
'xxx.xxx.xxx.xxx'
and
configure
libtool
with a simpler command:
udf_example.c
in the
directory (the exact name may vary from platform to platform).
.libs
plugin_dir
that is searched by your system's dynamic (runtime) linker,
/usr/lib
LD_LIBRARY
startup scripts and restart mysqld. You might do this if you want
program that configures the dynamic linker does not recognize
ldconfig
2817
or with four numbers.
(which is how MySQL is configured), you should
using
directly produces a file named
gcc
produces a file named something like
make
plugin_dir
[481]
is empty, the shared object should be
or
LD_LIBRARY_PATH
on FreeBSD,
ld-elf.so.1
[481]
system variable.
environment variable
on
ld.so

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents