i am attempting to create a UDF for use in MySQL. I have compiled the function using gcc and it works properly. I then moved the .so file into my plugin directory and entered into the My开发者_如何学PythonSQL server. I attempted to create the function using the following code:
CREATE FUNCTION mynew_udf RETURNS INT SONAME 'mynew_udf.so';
However, instead of creating the function as it should, the server outputs the following error:
ERROR 1127 (HY000): Can't find symbol 'mynew_udf' in library
Does anyone know a solution for this or why this error would occur? Thank you.
This error means exactly what it says: The mynew_udf
symbol can't be found in the shared library.
Without your code, I can only guess why this is the case. Does your source code have function signatures that look like this?
my_bool mynew_udf_init(UDF_INIT *, UDF_ARGS *args, char *message);
int mynew_udf(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error);
As noted on line 151 here: "These must be right or mysqld will not find the symbol!"
If you think you have the right symbols, you could also use nm
to look at the symbols in mynew_udf.so
:
nm mynew_udf.so | grep mynew_udf
With this syntax work fine:
From start folder:
gcc -shared -lstdc++ -fPIC -DMYSQL_DYNAMIC_PLUGIN -I /usr/include/ -I /usr/local/include/ -I /opt/jasperserver-4.5.0-0/mysql/include/ -o nomefile.so nomefile.cc
cp nomefile.so /PATH/mysql/lib/plugin/
DB connection string
/PATH/mysql/bin/mysql -uroot -p test
MYSQL> CREATE AGGREGATE FUNCTION example RETURNS REAL SONAME 'udf_example.so';
精彩评论