Dear all,
Recently I started digging into PosgreSQL programming.
I'm using a debian sarge kernel, KDE desktop and more.
G++ is used while compiling.
Next piece of code (funcTest.cpp):
#include "postgres.h"
#include <string.h>
#include "fmgr.h"
#include <iostream>
using namespace std;
// postgres syntax version 1.
PG_FUNCTION_INFO_V1(runTest);
Datum runTest(PG_FUNCTION_ARGS) {
// do something
int a;
a = 0;
PG_RETURN_INT32(a);
}
I compiled into a so file, on the prompt I used:
>> $ g++ -c -fPIC -isystem /usr/include/postgresql/server funcTest.cpp
>> $ g++ -shared -o funcTest.so funcTest.o
Then with the SQL syntax:
CREATE FUNCTION test() RETURNS integer
AS '/lib/funcTest.so', 'runTest'
LANGUAGE C STRICT;
and I get the error message:
ERROR: Could not find function 'runTest' in file '/lib/funcTest.so'
As far as I can tell the library should be OK? I used commands like file, nm
and readelf..... But then again....
Does anyone has a good sugestion? Adn how about the fact that type Datum is
used?
With kind regards, Willem Greveling.