Bug #39238 Inconsitencies in documentation for UDFs
Submitted: 4 Sep 2008 11:03 Modified: 18 May 2010 13:45
Reporter: Trond Norbye Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.0 OS:Any
Assigned to: Paul DuBois CPU Architecture:Any

[4 Sep 2008 11:03] Trond Norbye
Description:
According to http://dev.mysql.com/doc/refman/5.0/en/ha-memcached-interfaces-mysqludf.html one should put the library in /usr/local/mysql/lib/mysql/plugins/, but that does not work on the 5.0 server. http://dev.mysql.com/doc/refman/5.0/en/udf-compiling.html contains the correct information on the topic.

That page could also contain a reference to crle on Solaris in the following section: "The dynamic linker name is system-specific (for example, ld-elf.so.1 on FreeBSD, ld.so on Linux, or dyld  on Mac OS X). Consult your system documentation for information about the linker name and how to configure it. "

How to repeat:
Look in my blog for a description: http://blogs.sun.com/trond/entry/memcached_udf_for_mysql_on

Suggested fix:
I see two solutions:
1) Replace the reference to /usr/local/mysql/lib/mysql/plugins with /usr/lib, but that exposes the library to all binaries on the system, and modifies "system" directories.
2) Add a note to solution 1 and with information about overriding LD_LIBRARY_PATH in the startup script for mysqld.
[4 Sep 2008 12:24] Valeriy Kravchuk
Thank you for a reasonable documentation request.
[16 Dec 2009 4:13] Paul DuBois
Trond, is this still an issue with the current 5.0 release?
[16 Dec 2009 8:33] Trond Norbye
I don't know. I didn't see any changes to the documentation that would indicate that it has been fixed. I am currently assigned to other tasks so I haven't looked lately.
[17 Dec 2009 7:26] Valeriy Kravchuk
Manual (http://dev.mysql.com/doc/refman/5.0/en/ha-memcached-interfaces-mysqludf.html) still says:

"You may want to copy the MySQL memcached UDFs into your MySQL plugins directory:

shell> cp /usr/local/lib/libmemcached_functions_mysql* /usr/local/mysql/lib/mysql/plugins/"

while this may be NOT enough. Nothing fixed IMHO.
[18 May 2010 13:45] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.

To http://dev.mysql.com/doc/refman/5.0/en/ha-memcached-interfaces-mysqludf.html I added a note:

The plugin directory is given by the value of the plugin_dir system variable. For more information, see Section 21.2.2.5, “Compiling and Installing User-Defined Functions”.

And in the referenced section, I added the details about what do do if there is no plugin_dir. This includes discussion about setting LD_LIBRARY_PATH:

After you compile a shared object containing UDFs, you must install it and tell MySQL about it. Compiling a shared object from udf_example.c using gcc directly produces a file named udf_example.so. Compiling the shared object using make produces a file named something like udf_example.so.0.0.0 in the .libs directory (the exact name may vary from platform to platform).

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 plugin_dir system variable.

Prior to MySQL 5.0.67, or if the value of plugin_dir is empty, the shared object should be placed in a directory such as /usr/lib that is searched by your system's dynamic (runtime) linker, 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 LD_LIBRARY or LD_LIBRARY_PATH environment variable to point at the directory where you have the files for your UDF. You should set the variable in mysql.server or mysqld_safe startup scripts and restart mysqld. You might do this if you want to place the object file in a directory accessible only to the server and not in a public directory. The dlopen manual page tells you which variable to use on your system.