Bug #9196 Resolved Error: Got ERROR 2013 on CREATE FUNCTION
Submitted: 15 Mar 2005 13:23 Modified: 15 Mar 2005 15:02
Reporter: Marco Email Updates:
Status: Not a Bug Impact on me:
Category:MySQL Server: User-defined functions ( UDF ) Severity:S3 (Non-critical)
Version:4.1.10a, 4.0.24, 5.0.2 (All Standard) OS:Linux (Linux Fedora Core 3 x86)
Assigned to: CPU Architecture:Any

[15 Mar 2005 13:23] Marco
  I've found a solution to bug #9190 I've posted just a few ago (I open a new "bug-post" since I  can't add comment to that bug).

  The problem was the following: on CREATE FUNCTION command the ERROR 2013 was issued (not allowing to create a new UDF function).

The problem seems to affect only the RPM versions (at least those for x86 arch).

How to repeat:
1. Install a x86 RPM of MySQL (I've tried with versions 4.1.10a, 4.0.21, 4.0.24, 5.0.2)
    E.g.: $ rpm -Uvh MySQL-client-4.1.10a-0.i386.rpm \
                           MySQL-devel-4.1.10a-0.i386.rpm \
                           MySQL-embedded-4.1.10a-0.i386.rpm \
                           MySQL-server-4.1.10a-0.i386.rpm \

2. Download the attachment libhello.tgz and do:
    $ tar zxvf libhello.tgz
   (this will create a directory named libhello)

3. Change dir to libhello and compile the UDF:
   $ cd libhello
   $ make

4. Copy the so file to your system lib patch (e.g. /usr/lib) and register it:
   $ cp libhello.so /usr/lib/.
   $ ldconfig -v

5. Enter to the MySQL console and create the UDF function:
   $ mysql -uroot -p
     mysql> CREATE FUNCTION hello RETURNS STRING SONAME 'libhello.so';

You'll get the error:
ERROR 2013 (HY000): Lost connection to MySQL server during query

Suggested fix:
I've found two way for fixing:

a) Install MySQL from the source code distribution.
   I've just tried to compile the MySQL and all works including the udf_example.so sample

b) Install the Max RPM.
   I used to install only the following RPM:
   * MySQL-client-*-0.i386.rpm
   * MySQL-devel-*-0.i386.rpm
   * MySQL-embedded-*-0.i386.rpm
   * MySQL-server-*.i386.rpm
   * MySQL-shared-compat-*.i386.rpm (or MySQL-shared)

   Well with only this packages you're not be able to create UDF function (at least on my system).
   But if you also install MySQL-Max-*.i386.rpm packages you will be happy!!
[15 Mar 2005 13:24] Marco
Test file to reproduce the error

Attachment: libhello.tgz (application/x-gzip, text), 1.13 KiB.

[15 Mar 2005 15:02] Miguel Solorzano
How mentioned in the download page:

The Max version includes additional features such as the NDB (Cluster) storage engine, the Berkeley DB storage engine, and other features that have not been exhaustively tested or are not required for general usage, such as user-defined functions (UDFs) and BIG_TABLE support. 

Then the use of Max version is true.