MySQL UDF 5.0.24a

13 Sep

This was installed so that UDF could be used.

If you don’t use the patch and just use the generated .so file you’ll get an error like:

mysql> CREATE FUNCTION lookup RETURNS STRING SONAME ‘udf_example.so’;
ERROR 1126 (HY000): Can’t open shared library ‘udf_example.so’ (errno: 2 /usr/lib/udf_example.so: undefined symbol: __gxx_personality_v0)

To do this:

  1. Install the MySQL 5.0.24a binaries, make sure you use the ‘Max’ server as you need dynamic library loading
  2. Get the MySQL 5.0.24a source, go to the sql/ directory and patch the source using the diff found at http://lists.mysql.com/commits/9750. You will also need to rename udf_example.cc to udf_example.c.

Once you’ve done this, you need to compile the source using:

  1. libtool –mode=compile gcc -I. -I../include/ -c ./udf_example.c
  2. libtool –mode=link gcc -shared -fPIC -o udf_example.so udf_example.lo

Copy the resulting ‘udf_example.so’ to JS Tech Notes › Edit — WordPress/usr/lib. You can run ‘ldconfig -r -s’ to test the library.

Now get into mysql, make sure the server says its ‘5.0.24a-max’.

Test the function:

CREATE FUNCTION lookup RETURNS STRING SONAME 'udf_example.so';
select lookup("imvs.org")

							

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: