Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have been looking for creating a user defined function in MariaDB to perform a simple task


What I have tried:

For that I created a sample c++ program for adding two numbers,and compiled using the below command
 g++ -fPIC -shared Hello.cc -o add.so
after that I copied the shared object file to plugin directory.


When Iam calling the Create function syntax 
 
CREATE FUNCTION add RETURNS integer SONAME 'add.so';

it gives the below error
 ERROR 1127 (HY000): Can't find symbol 'add ' in library.

Kindly give a solution for the same.
Posted
Updated 4-Oct-18 2:55am

1 solution

Probably is due to C++ function name mangling. Try to surround function declaration with
C++
extern "C" {
// your function declaration here...
}

See, for instance, Name mangling (C++ only) - IBM Knowledge Center[^].
 
Share this answer
 
v2
Comments
Maciej Los 4-Oct-18 16:18pm    
5ed!
CPallini 4-Oct-18 16:24pm    
Thank you, Maciej!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900