1、C语言函数编写
编写一个名为textgbase.c的C函数的文件,
代码内容为:
#include<stdio.h>
int add(int a, int b)
{
int c = a + b;
return c;
}
- 2、编译
编译指令:
gcc -shared -fpic -o libtextgbase.so textgbase.c
3、创建函数
CREATE FUNCTION add(a int, b int) RETURNS int EXTERNAL NAME '/路径/libtextgbase.so(add)' LANGUAGE C;
4、使用函数
execute FUNCTION add(1,1);
5、删除函数
drop function add;